WSL/SLF GitLab Repository

Commit bf27531f authored by Mathias Bavay's avatar Mathias Bavay
Browse files

Added some documentation to GRIBIO, fixed the documentation of FilterStdDev,...

Added some documentation to GRIBIO, fixed the documentation of FilterStdDev, improved the regex for the sun test, significantly improved code coverage by adding lots of different filters and interpolations (both 1D and 2D). The meteo files have been tweaked in order to contain precipitation for the reference time step.
parent 20694125
......@@ -35,9 +35,9 @@ namespace mio {
* Values outside of mean ± 2 std_dev are rejected.
* @code
* Valid examples for the io.ini file:
* TA::filter1 = stddev
* TA::filter1 = std_dev
* TA::arg1 = soft left 1 1800 (1800 seconds time span for the left leaning window)
* RH::filter1 = stddev
* RH::filter1 = std_dev
* RH::arg1 = 10 6000 (strictly centered window spanning 6000 seconds and at least 10 points)
* @endcode
*/
......
......@@ -35,7 +35,7 @@ namespace mio {
* This plugin reads GRIB (https://en.wikipedia.org/wiki/GRIB) files as produced by meteorological models.
* Being based on GRIB API (http://www.ecmwf.int/products/data/software/grib_api.html), it should support both version 1 and 2 of the format (please note that grib_api must be compiled with Position Independent Code ("fPIC" flag)).
* Fields are read based on their marsParam code (this is built as {grib parameter number}.{grib table number} the table being preferably table 2, the parameter being preferably WMO standardized, as in http://dss.ucar.edu/docs/formats/grib/gribdoc/params.html) and levels
* (levels description is available at http://www.nco.ncep.noaa.gov/pmb/docs/on388/).
* (levels description is available at http://www.nco.ncep.noaa.gov/pmb/docs/on388/). Standard COSMO grids are listed at http://zephyr.ucd.ie/mediawiki/index.php/COSMO_GRIB .
*
* Several assumptions/approximations are held/made when reading grids:
* - since models usually use rotated latitude/longitude (see http://www.cosmo-model.org/content/model/documentation/core/default.htm, part I, chapter 3.3), the center of the domain can be approximated by a tangential cartesian coordinate system. We therefore don't re-project the lat/lon grid and use it "as is".
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -5,6 +5,7 @@ using namespace mio; //The MeteoIO namespace is called mio
using namespace std;
const double epsilon = 1e-3; //1e-4 is still too tight because of truncated results when writing data out for the ref.
const bool gen_ref = false; //wether to generate ref files or to test
int main(int /*argc*/, char** argv) {
Date d1;
......@@ -25,31 +26,81 @@ int main(int /*argc*/, char** argv) {
//performing spatial interpolations
Grid2DObject param, ref;
io.interpolate(d1, dem, MeteoData::TA, param);
io.read2DGrid(ref, date_str+"_TA_ref.asc");
if(ref.grid2D.checkEpsilonEquality(param.grid2D, epsilon)==false) {
cout << "TA grids don't match!\n"; return EXIT_FAILURE;
if(gen_ref) io.write2DGrid(param, MeteoGrids::TA, d1);
else {
io.read2DGrid(ref, date_str+"_TA_ref.asc");
if(ref.grid2D.checkEpsilonEquality(param.grid2D, epsilon)==false) {
cout << "TA grids don't match!\n"; return EXIT_FAILURE;
}
}
io.interpolate(d1, dem, MeteoData::TSS, param);
if(gen_ref) io.write2DGrid(param, MeteoGrids::TSS, d1);
else {
io.read2DGrid(ref, date_str+"_TSS_ref.asc");
if(ref.grid2D.checkEpsilonEquality(param.grid2D, epsilon)==false) {
cout << "TSS grids don't match!\n"; return EXIT_FAILURE;
}
}
io.interpolate(d1, dem, MeteoData::TSG, param);
if(gen_ref) io.write2DGrid(param, MeteoGrids::TSG, d1);
else {
io.read2DGrid(ref, date_str+"_TSG_ref.asc");
if(ref.grid2D.checkEpsilonEquality(param.grid2D, epsilon)==false) {
cout << "TSG grids don't match!\n"; return EXIT_FAILURE;
}
}
io.interpolate(d1, dem, MeteoData::HNW, param);
io.read2DGrid(ref, date_str+"_HNW_ref.asc");
if(ref.grid2D.checkEpsilonEquality(param.grid2D, epsilon)==false) {
cout << "HNW grids don't match!\n"; return EXIT_FAILURE;
if(gen_ref) io.write2DGrid(param, MeteoGrids::HNW, d1);
else {
io.read2DGrid(ref, date_str+"_HNW_ref.asc");
if(ref.grid2D.checkEpsilonEquality(param.grid2D, epsilon)==false) {
cout << "HNW grids don't match!\n"; return EXIT_FAILURE;
}
}
io.interpolate(d1, dem, MeteoData::RH, param);
io.read2DGrid(ref, date_str+"_RH_ref.asc");
if(ref.grid2D.checkEpsilonEquality(param.grid2D, epsilon)==false) {
cout << "RH grids don't match!\n"; return EXIT_FAILURE;
if(gen_ref) io.write2DGrid(param, MeteoGrids::RH, d1);
else {
io.read2DGrid(ref, date_str+"_RH_ref.asc");
if(ref.grid2D.checkEpsilonEquality(param.grid2D, epsilon)==false) {
cout << "RH grids don't match!\n"; return EXIT_FAILURE;
}
}
//io.write2DGrid(param, MeteoGrids::RH, d1);
io.interpolate(d1, dem, MeteoData::VW, param);
if(gen_ref) io.write2DGrid(param, MeteoGrids::VW, d1);
else {
io.read2DGrid(ref, date_str+"_VW_ref.asc");
if(ref.grid2D.checkEpsilonEquality(param.grid2D, epsilon)==false) {
cout << "VW grids don't match!\n"; return EXIT_FAILURE;
}
}
io.interpolate(d1, dem, MeteoData::RSWR, param);
io.read2DGrid(ref, date_str+"_RSWR_ref.asc");
if(ref.grid2D.checkEpsilonEquality(param.grid2D, epsilon)==false) {
cout << "RSWR grids don't match!\n"; return EXIT_FAILURE;
if(gen_ref) io.write2DGrid(param, MeteoGrids::RSWR, d1);
else {
io.read2DGrid(ref, date_str+"_RSWR_ref.asc");
if(ref.grid2D.checkEpsilonEquality(param.grid2D, epsilon)==false) {
cout << "RSWR grids don't match!\n"; return EXIT_FAILURE;
}
}
io.write2DGrid(param, MeteoGrids::RSWR, d1); //trying to write one grid out
io.interpolate(d1, dem, MeteoData::P, param);
if(gen_ref) io.write2DGrid(param, MeteoGrids::P, d1);
else {
io.read2DGrid(ref, date_str+"_P_ref.asc");
if(ref.grid2D.checkEpsilonEquality(param.grid2D, epsilon)==false) {
cout << "P grids don't match!\n"; return EXIT_FAILURE;
}
}
if(!gen_ref) io.write2DGrid(param, MeteoGrids::P, d1); //trying to write one grid out
return 0;
}
......@@ -36,8 +36,14 @@ METEO = SMET
METEOPATH = ./
[Filters]
TA::filter1 = min_max
TA::arg1 = 240 320
#trying to use as many different filters as possible, to increase code coverage
#the filters might not end up being so extremely relevant though...
TA::filter1 = min
TA::arg1 = 240
TA::filter2 = max
TA::arg2 = 320
TA::filter3 = unventilated_T
TA::arg3 = soft 0.23
RH::filter1 = min_max
RH::arg1 = 0.01 1.2
......@@ -48,6 +54,10 @@ HNW::filter1 = min
HNW::arg1 = -0.1
HNW::filter2 = min
HNW::arg2 = soft 0.
HNW::filter3 = unheated_raingauge
HNW::arg3 = soft 0.5 3.
HNW::filter4 = undercatch
HNW::arg4 = Hellmannsh
ISWR::filter1 = min_max
ISWR::arg1 = -10. 1500.
......@@ -58,31 +68,43 @@ RSWR::filter1 = min_max
RSWR::arg1 = -10 1500
RSWR::filter2 = min
RSWR::arg2 = soft 0
RSWR::filter3 = median_avg
RSWR::arg3 = soft center 3 14400
#for TA between 240 and 320 K
ILWR::filter1 = min_max
ILWR::arg1 = 188 600
ILWR::filter2 = min_max
ILWR::arg2 = soft 200 400
ILWR::filter3 = mean_avg
ILWR::arg3 = soft right 3 14400
#we need to consider time with no snow -> TSS>0
#min(TSS) in db since 1998: -50C
TSS::filter1 = min_max
TSS::arg1 = 200 320
TSS::filter2 = add
TSS::arg2 = 0.25
TSS::filter3 = exp_smoothing
TSS::arg3 = right 3 3600 0.8
#idem
TSG::filter1 = min_max
TSG::arg1 = 200 320
TSG::filter2 = mult
TSG::arg2 = 1.002
TSG::filter3 = wma_smoothing
TSG::arg3 = right 3 3600
HS::filter1 = min
HS::arg1 = soft 0.0
HS::filter2 = rate
HS::arg2 = 5.55e-5 ;0.20 m/h
HS::filter3 = mad
HS::arg3 = soft left 10 21600
VW::filter1 = min_max
VW::arg1 = -2 70
VW::filter2 = min_max
VW::arg2 = soft 0.2 50.0
VW::filter3 = std_dev
VW::arg3 = soft center 6 21600
[Interpolations1D]
WINDOW_SIZE = 86400
......@@ -90,29 +112,38 @@ WINDOW_SIZE = 86400
TA::resample = linear
RH::resample = linear
RH::args = extrapolate
HS::resample = linear
HNW::resample = accumulate
HNW::args = 3600
VW::resample = nearest_neighbour
VW::args = extrapolate
HNW::resample = linear
[Interpolations2D]
TA::algorithms = IDW_LAPSE CST_LAPSE
TA::cst_lapse = -0.008
TA::algorithms = IDW_LAPSE
TA::idw_lapse = -0.008 soft
TSS::algorithms = CST_LAPSE
TSS::cst_lapse = -0.008
TSG::algorithms = CST
TSG::cst = 273.15
RH::algorithms = RH IDW_LAPSE CST
HNW::algorithms = IDW_LAPSE CST_LAPSE CST
HNW::cst_lapse = 0.0005 frac
HNW::algorithms = HNW_SNOW
HNW::hnw_snow = cst_lapse
HNW::cst_lapse = 0.0005 frac
VW::algorithms = IDW_LAPSE CST
VW::algorithms = WIND_CURV
P::algorithms = STD_PRESS
DW::algorithms = IDW
ILWR::algorithms = CST_LAPSE
ILWR::cst_lapse = -0.03125
P::algorithms = STD_PRESS
RSWR::algorithms = IDW CST
RSWR::algorithms = IDW
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -19,8 +19,14 @@ STATION6 = OTT2.smet
STATION7 = TUJ3.smet
[Filters]
TA::filter1 = min_max
TA::arg1 = 240 320
#trying to use as many different filters as possible, to increase code coverage
#the filters might not end up being so extremely relevant though...
TA::filter1 = min
TA::arg1 = 240
TA::filter2 = max
TA::arg2 = 320
TA::filter3 = unventilated_T
TA::arg3 = soft 0.23
RH::filter1 = min_max
RH::arg1 = 0.01 1.2
......@@ -31,6 +37,10 @@ HNW::filter1 = min
HNW::arg1 = -0.1
HNW::filter2 = min
HNW::arg2 = soft 0.
HNW::filter3 = unheated_raingauge
HNW::arg3 = soft 0.5 3.
HNW::filter4 = undercatch
HNW::arg4 = Hellmannsh
ISWR::filter1 = min_max
ISWR::arg1 = -10. 1500.
......@@ -41,31 +51,43 @@ RSWR::filter1 = min_max
RSWR::arg1 = -10 1500
RSWR::filter2 = min
RSWR::arg2 = soft 0
RSWR::filter3 = median_avg
RSWR::arg3 = soft center 3 14400
#for TA between 240 and 320 K
ILWR::filter1 = min_max
ILWR::arg1 = 188 600
ILWR::filter2 = min_max
ILWR::arg2 = soft 200 400
ILWR::filter3 = mean_avg
ILWR::arg3 = soft right 3 14400
#we need to consider time with no snow -> TSS>0
#min(TSS) in db since 1998: -50C
TSS::filter1 = min_max
TSS::arg1 = 200 320
TSS::filter2 = add
TSS::arg2 = 0.25
TSS::filter3 = exp_smoothing
TSS::arg3 = right 3 3600 0.8
#idem
TSG::filter1 = min_max
TSG::arg1 = 200 320
TSG::filter2 = mult
TSG::arg2 = 1.002
TSG::filter3 = wma_smoothing
TSG::arg3 = right 3 3600
HS::filter1 = min
HS::arg1 = soft 0.0
HS::filter2 = rate
HS::arg2 = 5.55e-5 ;0.20 m/h
HS::filter3 = mad
HS::arg3 = soft left 10 21600
VW::filter1 = min_max
VW::arg1 = -2 70
VW::filter2 = min_max
VW::arg2 = soft 0.2 50.0
VW::filter3 = std_dev
VW::arg3 = soft center 6 21600
[Interpolations1D]
WINDOW_SIZE = 86400
......@@ -73,9 +95,13 @@ WINDOW_SIZE = 86400
TA::resample = linear
RH::resample = linear
RH::args = extrapolate
HS::resample = linear
HNW::resample = accumulate
HNW::args = 3600
VW::resample = nearest_neighbour
VW::args = extrapolate
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment