WSL/SLF GitLab Repository

Commit 8d77f7f1 authored by Mathias Bavay's avatar Mathias Bavay
Browse files

The example data snow heights were given in cm instead of m. Using the...

The example data snow heights were given in cm instead of m. Using the "units_multiplier" of SMET, this has been fixed.

The plugin_nodata of SMET was not remapped to IOUtils::nodata. This is now done (both for header fields, ascii data and binary data).
parent ea31ba56
......@@ -11,6 +11,7 @@ epsg = 21781
nodata = -999
tz = 1
fields = timestamp TA RH VW DW OSWR HS PSUM TSG TSS
units_multiplier = 1 1 1 1 1 1 0.01 1 1 1
[DATA]
2008-12-01T00:00 269.15 0.520 2.0 265 0 85.000 0.000 273.85 261.75
2008-12-01T01:00 269.95 0.450 1.9 262 0 85.000 0.000 273.85 261.65
......
......@@ -11,6 +11,7 @@ epsg = 21781
nodata = -999
tz = 1
fields = timestamp TA RH VW DW OSWR HS TSG TSS
units_multiplier = 1 1 1 1 1 1 0.01 1 1
[DATA]
2008-12-01T00:00 265.35 1.000 6.0 134 0 36.000 273.15 265.75
2008-12-01T01:00 265.35 0.989 7.1 129 0 35.000 273.15 265.65
......
......@@ -11,6 +11,7 @@ epsg = 21781
nodata = -999
tz = 1
fields = timestamp TA RH VW DW OSWR HS TSG TSS
units_multiplier = 1 1 1 1 1 1 0.01 1 1
[DATA]
2008-12-01T00:00 266.75 1.000 0.9 214 -1 158.000 273.45 266.85
2008-12-01T01:00 267.15 1.000 1.2 100 -1 160.000 273.45 267.45
......
......@@ -11,6 +11,7 @@ epsg = 21781
nodata = -999
tz = 1
fields = timestamp TA RH VW DW OSWR HS PSUM TSG TSS
units_multiplier = 1 1 1 1 1 1 0.01 1 1 1
[DATA]
2008-12-01T00:00 273.05 0.442 0.6 222 0 117.000 0.000 274.15 264.65
2008-12-01T01:00 273.05 0.451 0.3 195 0 117.000 0.000 274.15 263.95
......
......@@ -11,6 +11,7 @@ epsg = 21781
nodata = -999
tz = 1
fields = timestamp TA RH VW DW OSWR HS PSUM TSG TSS
units_multiplier = 1 1 1 1 1 1 0.01 1 1 1
[DATA]
2008-12-01T00:00 269.45 0.369 1.2 171 0 31.000 0.000 273.55 263.35
2008-12-01T01:00 269.25 0.383 1.1 299 0 31.000 0.000 273.55 263.65
......
......@@ -11,6 +11,7 @@ epsg = 21781
nodata = -999
tz = 1
fields = timestamp TA RH VW DW OSWR HS PSUM TSG TSS
units_multiplier = 1 1 1 1 1 1 0.01 1 1 1
[DATA]
2008-12-01T00:00 269.65 0.443 0.4 91 0 68.000 0.000 274.45 263.95
2008-12-01T01:00 269.15 0.520 1.4 15 0 68.000 0.000 274.45 264.35
......
......@@ -11,6 +11,7 @@ epsg = 21781
nodata = -999
tz = 1
fields = timestamp TA RH VW DW OSWR HS PSUM TSG TSS
units_multiplier = 1 1 1 1 1 1 0.01 1 1 1
[DATA]
2008-12-01T00:00 265.95 0.988 0.0 335 0 142.000 0.000 273.55 264.45
2008-12-01T01:00 265.95 0.987 0.0 196 0 142.000 0.000 273.55 264.25
......
......@@ -137,16 +137,19 @@ void SMETIO::checkColumnNames(const std::vector<std::string>& vecColumns, const
SMETIO::SMETIO(void (*delObj)(void*), const Config& i_cfg) : IOInterface(delObj), cfg(i_cfg)
{
parseInputOutputSection();
plugin_nodata = IOUtils::nodata;
}
SMETIO::SMETIO(const std::string& configfile) : IOInterface(NULL), cfg(configfile)
{
parseInputOutputSection();
plugin_nodata = IOUtils::nodata;
}
SMETIO::SMETIO(const Config& cfgreader) : IOInterface(NULL), cfg(cfgreader)
{
parseInputOutputSection();
plugin_nodata = IOUtils::nodata;
}
SMETIO::~SMETIO() throw()
......@@ -164,7 +167,7 @@ void SMETIO::cleanup() throw()
}
if (fout.is_open()) {//close fout if open
fout.close();
}
}
}
void SMETIO::read2DGrid(Grid2DObject& /*grid_out*/, const std::string& /*_name*/)
......@@ -437,7 +440,10 @@ void SMETIO::readDataBinary(const char&, const std::string&, const double& timez
alt = val;
poscounter++;
} else {
SMETIO::getParameter(vecDataSequence[ii], md) = (val + vecUnitsOffset[ii]) * vecUnitsMultiplier[ii];
if(val==plugin_nodata)
SMETIO::getParameter(vecDataSequence[ii], md) = IOUtils::nodata;
else
SMETIO::getParameter(vecDataSequence[ii], md) = (val + vecUnitsOffset[ii]) * vecUnitsMultiplier[ii];
}
}
}
......@@ -447,8 +453,12 @@ void SMETIO::readDataBinary(const char&, const std::string&, const double& timez
if (c != '\n')
throw InvalidFormatException("Corrupted data in section [DATA]", AT);
if (poscounter == 3)
if (poscounter == 3) {
lat=IOUtils::standardizeNodata(lat, plugin_nodata);
lon=IOUtils::standardizeNodata(lon, plugin_nodata);
alt=IOUtils::standardizeNodata(alt, plugin_nodata);
tmpsd.position.setLatLon(lat, lon, alt);
}
if (md.date >= dateStart){
md.meta = tmpsd;
......@@ -484,7 +494,7 @@ void SMETIO::readDataAscii(const char& eoln, const std::string& filename, const
MeteoData md;
StationData tmpsd = sd;
double lat, lon, alt;
double lat=IOUtils::nodata, lon=IOUtils::nodata, alt=IOUtils::nodata;
unsigned int poscounter = 0;
for (unsigned int ii=0; ii<nrOfColumns; ii++){
if (vecDataSequence[ii] == "timestamp"){
......@@ -511,12 +521,19 @@ void SMETIO::readDataAscii(const char& eoln, const std::string& filename, const
double val;
if (!IOUtils::convertString(val, tmpvec[ii]))
throw InvalidFormatException("In "+filename+": Invalid value for param", AT);
SMETIO::getParameter(vecDataSequence[ii], md) = (val + vecUnitsOffset[ii]) * vecUnitsMultiplier[ii];
if(val==plugin_nodata)
SMETIO::getParameter(vecDataSequence[ii], md) = IOUtils::nodata;
else
SMETIO::getParameter(vecDataSequence[ii], md) = (val + vecUnitsOffset[ii]) * vecUnitsMultiplier[ii];
}
}
if (poscounter == 3)
if (poscounter == 3) {
lat=IOUtils::standardizeNodata(lat, plugin_nodata);
lon=IOUtils::standardizeNodata(lon, plugin_nodata);
alt=IOUtils::standardizeNodata(alt, plugin_nodata);
tmpsd.position.setLatLon(lat, lon, alt);
}
if (md.date >= dateStart){
md.meta = tmpsd;
......@@ -560,6 +577,8 @@ void SMETIO::readHeader(const char& eoln, const std::string& filename, bool& loc
IOUtils::getValueForKey(mapHeader, "station_name", sd.stationName, IOUtils::nothrow);
timezone = in_dflt_TZ;
IOUtils::getValueForKey(mapHeader, "tz", timezone, IOUtils::nothrow);
if(timezone==plugin_nodata) //if a nodata was given in the header, we replace it with the io.ini timezone
timezone = in_dflt_TZ;
sd.position.setProj(coordin, coordinparam); //set the default projection from config file
//trying to read easting/northing
......@@ -571,9 +590,12 @@ void SMETIO::readHeader(const char& eoln, const std::string& filename, bool& loc
}
IOUtils::getValueForKey(mapHeader, "easting", easting, IOUtils::nothrow);
easting=IOUtils::standardizeNodata(easting, plugin_nodata);
if (easting != IOUtils::nodata){
IOUtils::getValueForKey(mapHeader, "northing", northing);
IOUtils::getValueForKey(mapHeader, "altitude", alt);
northing=IOUtils::standardizeNodata(northing, plugin_nodata);
alt=IOUtils::standardizeNodata(alt, plugin_nodata);
sd.position.setXY(easting, northing, alt);
locationInHeader = true;
} else {
......@@ -583,9 +605,12 @@ void SMETIO::readHeader(const char& eoln, const std::string& filename, bool& loc
//now trying to read lat/long (second, so that it has precedence over east/north coordinates)
double lat=IOUtils::nodata, lon=IOUtils::nodata;
IOUtils::getValueForKey(mapHeader, "latitude", lat, IOUtils::nothrow);
lat=IOUtils::standardizeNodata(lat, plugin_nodata);
if (lat != IOUtils::nodata){
IOUtils::getValueForKey(mapHeader, "longitude", lon);
IOUtils::getValueForKey(mapHeader, "altitude", alt);
lon=IOUtils::standardizeNodata(lon, plugin_nodata);
alt=IOUtils::standardizeNodata(alt, plugin_nodata);
sd.position.setLatLon(lat, lon, alt);
locationInHeader = true;
}
......
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