WSL/SLF GitLab Repository

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

More detailed error messages when the timestamps are not properly sorted....

More detailed error messages when the timestamps are not properly sorted. Better behavior of the GSN plugin when the data is missing but the metadata could be retrieved (so at least we know that the station is valid).
parent 7841d7f3
......@@ -416,7 +416,10 @@ void IOHandler::checkTimestamps(const std::vector<METEO_SET>& vecVecMeteo) const
const Date& current_date = vecVecMeteo[stat_idx][ii].date;
if (current_date<=previous_date) {
const StationData& station = vecVecMeteo[stat_idx][ii].meta;
throw IOException("Error at time "+current_date.toString(Date::ISO)+" for station \""+station.stationName+"\" ("+station.stationID+") : timestamps must be in increasing order and unique!", AT);
if (current_date==previous_date)
throw IOException("Error for station \""+station.stationName+"\" ("+station.stationID+") at time "+current_date.toString(Date::ISO)+": timestamps must be unique!", AT);
else
throw IOException("Error for station \""+station.stationName+"\" ("+station.stationID+"): jumping from "+previous_date.toString(Date::ISO)+" to "+current_date.toString(Date::ISO), AT);
}
previous_date = current_date;
}
......
......@@ -160,7 +160,7 @@ void GSNIO::readStationData(const Date& date, std::vector<StationData>& vecStati
const size_t nrStations = vecStationName.size();
vector<MeteoData> vecMeteo;
for (size_t ii=0; ii<nrStations; ii++){ //loop through stations
for (size_t ii=0; ii<nrStations; ii++) { //loop through stations
vecMeteo.clear();
readData(date, date, vecMeteo, ii);
vecStation.push_back( vecMeteo[0].meta );
......@@ -304,8 +304,11 @@ void GSNIO::readData(const Date& dateStart, const Date& dateEnd, std::vector<Met
do { //parse data section, the first line should already be buffered
if (line.empty() || (line[0] == '#') || !isdigit(line[0])) continue; //skip empty lines
parse_streamElement(line, index, vecMeteo, tmpmeteo);
parse_streamElement(line, index, tmpmeteo);
vecMeteo.push_back( tmpmeteo );
} while (getline(ss, line));
if (vecMeteo.empty()) //ie the data section was empty
vecMeteo.push_back( tmpmeteo );
} else {
if (gsn_debug)
std::cout << "****\nRequest: " << request << "\n****\n";
......@@ -388,7 +391,7 @@ void GSNIO::map_parameters(const std::string& fields, const std::string& units,
}
}
void GSNIO::parse_streamElement(const std::string& line, const std::vector<size_t>& index, std::vector<MeteoData>& vecMeteo, MeteoData& tmpmeteo) const
void GSNIO::parse_streamElement(const std::string& line, const std::vector<size_t>& index, MeteoData& tmpmeteo) const
{
static vector<string> data;
static double timestamp;
......@@ -408,13 +411,10 @@ void GSNIO::parse_streamElement(const std::string& line, const std::vector<size_
if (value.empty()) continue; //skip empty values
const size_t idx = index[valid_idx++];
if (value != GSNIO::null_string){
IOUtils::convertString(tmpmeteo(idx), value);
}
if (value != GSNIO::null_string) IOUtils::convertString(tmpmeteo(idx), value);
}
convertUnits(tmpmeteo);
vecMeteo.push_back( tmpmeteo );
}
void GSNIO::readAssimilationData(const Date&, Grid2DObject&)
......
......@@ -73,8 +73,7 @@ class GSNIO : public IOInterface {
bool parseMetadata(std::stringstream& ss, StationData &sd, std::string &fields, std::string &units) const;
void readData(const Date& dateStart, const Date& dateEnd, std::vector<MeteoData>& vecMeteo, const size_t& stationindex);
void map_parameters(const std::string& fields, const std::string& units, MeteoData& md, std::vector<size_t>& index);
void parse_streamElement(const std::string& line, const std::vector<size_t>& index,
std::vector<MeteoData>& vecMeteo, MeteoData& tmpmeteo) const;
void parse_streamElement(const std::string& line, const std::vector<size_t>& index, MeteoData& tmpmeteo) const;
void initGSNConnection();
static size_t data_write(void* buf, size_t size, size_t nmemb, void* userp);
......
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