From 7ca5d63ce57010c9e1cbea73a906e2b60cadcfab Mon Sep 17 00:00:00 2001 From: Roland Winklmeier Date: Fri, 10 Jun 2016 10:27:53 +0200 Subject: [PATCH] Retrieve precipitation rate from GFS data refs #663 --- src/blackmisc/weather/cloudlayer.cpp | 2 +- src/blackmisc/weather/cloudlayer.h | 8 ++--- src/blackmisc/weather/weathergrid.cpp | 2 +- .../weatherdata/gfs/weatherdatagfs.cpp | 30 +++++++++++-------- src/plugins/weatherdata/gfs/weatherdatagfs.h | 7 +++-- 5 files changed, 29 insertions(+), 20 deletions(-) diff --git a/src/blackmisc/weather/cloudlayer.cpp b/src/blackmisc/weather/cloudlayer.cpp index 8d46fbb00..be61f9981 100644 --- a/src/blackmisc/weather/cloudlayer.cpp +++ b/src/blackmisc/weather/cloudlayer.cpp @@ -30,7 +30,7 @@ namespace BlackMisc CCloudLayer::CCloudLayer(BlackMisc::Aviation::CAltitude base, BlackMisc::Aviation::CAltitude top, - int precipitationRate, + double precipitationRate, Precipitation precipitation, Clouds clouds, Coverage coverage) : diff --git a/src/blackmisc/weather/cloudlayer.h b/src/blackmisc/weather/cloudlayer.h index 58151e49d..12dff0047 100644 --- a/src/blackmisc/weather/cloudlayer.h +++ b/src/blackmisc/weather/cloudlayer.h @@ -85,7 +85,7 @@ namespace BlackMisc //! Constructor CCloudLayer(BlackMisc::Aviation::CAltitude base, BlackMisc::Aviation::CAltitude top, - int precipitationRate, + double precipitationRate, Precipitation precipitation, Clouds clouds, Coverage coverage); @@ -103,10 +103,10 @@ namespace BlackMisc BlackMisc::Aviation::CAltitude getTop() const { return m_top; } //! Set precipitation rate - void setPrecipitationRate(int rate) { m_precipitationRate = rate; } + void setPrecipitationRate(double rate) { m_precipitationRate = rate; } //! Get precipitation rate - int getPrecipitationRate() const { return m_precipitationRate; } + double getPrecipitationRate() const { return m_precipitationRate; } //! Set precipitation void setPrecipitation(Precipitation type) { m_precipitation = type; } @@ -144,7 +144,7 @@ namespace BlackMisc private: BlackMisc::Aviation::CAltitude m_base; BlackMisc::Aviation::CAltitude m_top; - int m_precipitationRate = 0; + double m_precipitationRate = 0; Precipitation m_precipitation = NoPrecipitation; Clouds m_clouds = NoClouds; int m_coveragePercent; diff --git a/src/blackmisc/weather/weathergrid.cpp b/src/blackmisc/weather/weathergrid.cpp index 7ba220566..31cf99ed4 100644 --- a/src/blackmisc/weather/weathergrid.cpp +++ b/src/blackmisc/weather/weathergrid.cpp @@ -93,7 +93,7 @@ namespace BlackMisc static const CCloudLayer cloudLayer( CAltitude(0, CAltitude::MeanSeaLevel, CLengthUnit::m()), CAltitude(5000, CAltitude::MeanSeaLevel, CLengthUnit::m()), - 5, CCloudLayer::NoPrecipitation, CCloudLayer::NoClouds, + 0, CCloudLayer::NoPrecipitation, CCloudLayer::NoClouds, CCloudLayer::None); static const CWindLayer windLayer( diff --git a/src/plugins/weatherdata/gfs/weatherdatagfs.cpp b/src/plugins/weatherdata/gfs/weatherdatagfs.cpp index 5d745a167..c7e2925fe 100644 --- a/src/plugins/weatherdata/gfs/weatherdatagfs.cpp +++ b/src/plugins/weatherdata/gfs/weatherdatagfs.cpp @@ -33,6 +33,7 @@ namespace BlackWxPlugin { { { {0, 0} }, { TMP, "Temperature", "K" } }, { { {1, 1} }, { RH, "Relative Humidity", "%" } }, + { { {1, 7} }, { PRATE, "Precipitation Rate", "kg m-2 s-1" } }, { { {1, 192} }, { CRAIN, "Categorical Rain", "-" } }, { { {1, 195} }, { CSNOW, "Categorical Snow", "-" } }, { { {2, 2} }, { UGRD, "U-Component of Wind", "m s-1" } }, @@ -133,6 +134,7 @@ namespace BlackWxPlugin static const QStringList grib2Variables = { + "PRATE", "PRES", "PRMSL", "RH", @@ -280,16 +282,9 @@ namespace BlackWxPlugin cloudLayer.setBase(CAltitude(cloudLayerIt.value().bottomLevel, CAltitude::MeanSeaLevel, CLengthUnit::ft())); cloudLayer.setTop(CAltitude(cloudLayerIt.value().topLevel, CAltitude::MeanSeaLevel, CLengthUnit::ft())); cloudLayer.setCoveragePercent(cloudLayerIt.value().totalCoverage); - if (gfsGridPoint.surfaceSnowRate > 0.0) - { - cloudLayer.setPrecipitation(CCloudLayer::Snow); - cloudLayer.setPrecipitationRate(gfsGridPoint.surfaceSnowRate); - } - if (gfsGridPoint.surfaceRainRate > 0.0) - { - cloudLayer.setPrecipitation(CCloudLayer::Rain); - cloudLayer.setPrecipitationRate(gfsGridPoint.surfaceRainRate); - } + if (gfsGridPoint.surfaceSnow > 0.0) { cloudLayer.setPrecipitation(CCloudLayer::Snow); } + if (gfsGridPoint.surfaceRain > 0.0) { cloudLayer.setPrecipitation(CCloudLayer::Rain); } + cloudLayer.setPrecipitationRate(gfsGridPoint.surfacePrecipitationRate); cloudLayer.setClouds(CCloudLayer::CloudsUnknown); cloudLayers.insert(cloudLayer); } @@ -576,6 +571,9 @@ namespace BlackWxPlugin case PRES: setCloudLevel(gfld->fld, typeFirstFixedSurface, grib2CloudLevelHash.value(typeFirstFixedSurface)); break; + case PRATE: + setPrecipitationRate(gfld->fld); + break; case CRAIN: setSurfaceRain(gfld->fld); break; @@ -665,7 +663,7 @@ namespace BlackWxPlugin { for (auto &gridPoint : m_gfsWeatherGrid) { - gridPoint.surfaceRainRate = fld[gridPoint.fieldPosition]; + gridPoint.surfaceRain = fld[gridPoint.fieldPosition]; } } @@ -673,7 +671,15 @@ namespace BlackWxPlugin { for (auto &gridPoint : m_gfsWeatherGrid) { - gridPoint.surfaceSnowRate = fld[gridPoint.fieldPosition]; + gridPoint.surfaceSnow = fld[gridPoint.fieldPosition]; + } + } + + void CWeatherDataGfs::setPrecipitationRate(const g2float *fld) + { + for (auto &gridPoint : m_gfsWeatherGrid) + { + gridPoint.surfacePrecipitationRate = fld[gridPoint.fieldPosition]; } } diff --git a/src/plugins/weatherdata/gfs/weatherdatagfs.h b/src/plugins/weatherdata/gfs/weatherdatagfs.h index b6a2cd143..f77692307 100644 --- a/src/plugins/weatherdata/gfs/weatherdatagfs.h +++ b/src/plugins/weatherdata/gfs/weatherdatagfs.h @@ -71,6 +71,7 @@ namespace BlackWxPlugin RH, UGRD, VGRD, + PRATE, PRES, PRMSL, TCDC, @@ -124,8 +125,9 @@ namespace BlackWxPlugin int fieldPosition = 0; QHash cloudLayers; QHash isobaricLayers; - double surfaceRainRate = 0; - double surfaceSnowRate = 0; + double surfaceRain = 0; + double surfaceSnow = 0; + double surfacePrecipitationRate = 0; double surfacePressure = 0; double surfaceTemperature = 0; }; @@ -146,6 +148,7 @@ namespace BlackWxPlugin void setCloudPressure(const g2float *fld, double level); void setSurfaceRain(const g2float *fld); void setSurfaceSnow(const g2float *fld); + void setPrecipitationRate(const g2float *fld); BlackMisc::PhysicalQuantities::CTemperature calculateDewPoint(const BlackMisc::PhysicalQuantities::CTemperature &temperature, double relativeHumidity);