WSL/SLF GitLab Repository

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

Another bug in the parameter name mapping in SMETIO has been found and some...

Another bug in the parameter name mapping in SMETIO has been found and some error messages made clearer (with more information).

A bug in convertString<Date> has been found that was preventing it from corretly processing dates containing seconds. A quick fix has been implemented that reads seconds (even if they are later ignored because the Date class would need to support seconds)
parent 3e406fd0
......@@ -315,9 +315,15 @@ template<> bool IOUtils::convertString<Date>(Date& t, const std::string& str, st
trim(s); //delete trailing and leading whitespaces and tabs
(void)f;
unsigned int year, month, day, hour, minute;
unsigned int year, month, day, hour, minute, second;
char rest[32] = "";
if (sscanf(s.c_str(), "%u-%u-%u %u:%u%31s", &year, &month, &day, &hour, &minute, rest) >= 5) {
//HACK: we read the seconds, but we ignore them...
if (sscanf(s.c_str(), "%u-%u-%u %u:%u:%u%31s", &year, &month, &day, &hour, &minute, &second, rest) >= 6) {
t.setDate(year, month, day, hour, minute);
} else if (sscanf(s.c_str(), "%u-%u-%uT%u:%u:%u%31s", &year, &month, &day, &hour, &minute, &second, rest) >= 6) {
t.setDate(year, month, day, hour, minute);
} else if (sscanf(s.c_str(), "%u-%u-%u %u:%u%31s", &year, &month, &day, &hour, &minute, rest) >= 5) {
t.setDate(year, month, day, hour, minute);
} else if (sscanf(s.c_str(), "%u-%u-%uT%u:%u%31s", &year, &month, &day, &hour, &minute, rest) >= 5) {
t.setDate(year, month, day, hour, minute);
......
......@@ -66,7 +66,7 @@ double& SMETIO::getParameter(const std::string& columnName, MeteoData& md)
return md.param(paramindex);
}
if(columnName=="PSUM") {
MeteoData::Parameters paramindex = mapParameterByName["RSWR"];
MeteoData::Parameters paramindex = mapParameterByName["HNW"];
return md.param(paramindex);
}
......@@ -411,7 +411,7 @@ void SMETIO::readDataAscii(const char& eoln, const std::string& filename, const
unsigned int ncols = IOUtils::readLineToVec(line, tmpvec);
if (ncols != nrOfColumns)
throw InvalidFormatException("In "+ filename + ": Invalid amount of data in data line", AT);
throw InvalidFormatException("In "+ filename + ": Invalid amount of data in data line "+line, AT);
MeteoData md;
StationData tmpsd = sd;
......@@ -420,7 +420,7 @@ void SMETIO::readDataAscii(const char& eoln, const std::string& filename, const
for (unsigned int ii=0; ii<nrOfColumns; ii++){
if (vecDataSequence[ii] == "timestamp"){
if (!IOUtils::convertString(md.date, tmpvec[ii]))
throw InvalidFormatException("In "+filename+": Timestamp invalid in data line", AT);
throw InvalidFormatException("In "+filename+": Timestamp "+tmpvec[ii]+" invalid in data line", AT);
if ((timezone != IOUtils::nodata) && (timezone != 0.0))
md.date.setTimeZone(timezone);
......@@ -515,7 +515,7 @@ void SMETIO::readHeader(const char& eoln, const std::string& filename, bool& loc
}
IOUtils::getValueForKey(mapHeader, "fields", vecDataSequence);
//IOUtils::getValueForKey(mapHeader, "units_offset", vecUnitsOffset, IOUtils::nothrow);
//IOUtils::getValueForKey(mapHeader, "units_offset", vecUnitsOffset, IOUtils::nothrow); //TODO: implement these!!
//IOUtils::getValueForKey(mapHeader, "units_multiplier", vecUnitsMultiplier, IOUtils::nothrow);
//Read [DATA] section tag
......
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