WSL/SLF GitLab Repository

Commit 83e55804 authored by Mathias Bavay's avatar Mathias Bavay
Browse files

Non-applicable units specs have been replaced by "-" in smet files. A...

Non-applicable units specs have been replaced by "-" in smet files. A toString() method has been implemented in SmetWriter for easier debugging and an error message improved for clarity.
parent 06859ba9
......@@ -552,7 +552,7 @@ void SMETIO::getPlotProperties(const size_t& param, std::ostringstream &plot_uni
plot_units << "K "; plot_description << "air_temperature ";
plot_color << "#8324A4 "; plot_min << "253.15 "; plot_max << "283.15 ";
} else if (param==MeteoData::RH) {
plot_units << "na "; plot_description << "relative_humidity ";
plot_units << "- "; plot_description << "relative_humidity ";
plot_color << "#50CBDB "; plot_min << "0 "; plot_max << "1 ";
} else if (param==MeteoData::TSG) {
plot_units << "K "; plot_description << "ground_surface_temperature ";
......@@ -582,16 +582,16 @@ void SMETIO::getPlotProperties(const size_t& param, std::ostringstream &plot_uni
plot_units << "W/m2 "; plot_description << "incoming_long_wave_radiation ";
plot_color << "#D99521 "; plot_min << "150 "; plot_max << "400 ";
} else if (param==MeteoData::TAU_CLD) {
plot_units << "na "; plot_description << "cloud_transmissivity ";
plot_units << "- "; plot_description << "cloud_transmissivity ";
plot_color << "#D9A48F "; plot_min << "0 "; plot_max << "1 ";
} else if (param==MeteoData::PSUM) {
plot_units << "kg/m2 "; plot_description << "water_equivalent_precipitation_sum ";
plot_color << "#2431A4 "; plot_min << "0 "; plot_max << "20 ";
} else if (param==MeteoData::PSUM_PH) {
plot_units << "na "; plot_description << "precipitation_phase ";
plot_units << "- "; plot_description << "precipitation_phase ";
plot_color << "#7E8EDF "; plot_min << "0 "; plot_max << "1 ";
} else {
plot_units << "na "; plot_description << "na ";
plot_units << "- "; plot_description << "- ";
plot_color << "#A0A0A0 "; plot_min << IOUtils::nodata << " "; plot_max << IOUtils::nodata << " ";
}
}
......
......@@ -369,6 +369,20 @@ SMETWriter::SMETWriter(const std::string& in_filename, const std::string& in_fie
if (julian_present) nr_of_fields++;
}
const std::string SMETWriter::toString() const {
ostringstream os;
os << "<SMETWriter>\n";
os << "\tfilename: " << filename << "\n";
os << "\ttype: " << ((smet_type==ASCII)? "Ascii" : "Binary") << " append_mode: " << std::boolalpha << append_mode << " append_possible: " << append_possible << "\n";
os << "\ttimestamp_present: " << timestamp_present << " field: " << timestamp_field << " julian_present: " << julian_present << " field: " << julian_field << "\n";
os << "\tlocation: in header? " << location_in_header << " in data_wgs84? " << location_in_data_wgs84 << " in data_epsg? " << location_in_data_epsg << "\n";
os << "\tlocation_wgs84: " << location_wgs84 << " location_epsg: " << location_epsg << "\n";
os << "\tnodata: " << nodata_value << " = \"" << nodata_string << "\"\n";
os << "\tnr_of_fields: " << nr_of_fields << "\n";
os << "</SMETWriter>\n";
return os.str();
}
void SMETWriter::set_header_value(const std::string& key, const double& value)
{
//check if key is decimal, transform to string and add to header
......@@ -468,7 +482,7 @@ bool SMETWriter::check_fields(const std::string& key, const std::string& value)
}
if (key == "fields"){
size_t count_wgs84 = 0, count_epsg = 0;
size_t count_wgs84 = 0, count_epsg = 0;
//check if location is in data and if timestamp is present
for (size_t ii = 0; ii<tmp_vec.size(); ii++){
......@@ -582,7 +596,7 @@ void SMETWriter::write(const std::vector<std::string>& vec_timestamp, const std:
if ((nr_of_lines != vec_timestamp.size()) || ((data.size() % (nr_of_fields-1)) != 0)) {
fout.close();
ostringstream os;
os << "Inconsistency between the number of timestamp (" << vec_timestamp.size() << ") and number of data points (" << data.size() << "/" << nr_of_fields-1 << ") detected for file \""+filename+"\", recheck your data";
os << "Inconsistency between the number of timestamp (" << vec_timestamp.size() << ") and number of data points (" << data.size() << " for " << nr_of_fields-1 << " fields) detected for file \""+filename+"\", recheck your data";
throw SMETException(os.str(), SMET_AT);
}
......
......@@ -155,6 +155,8 @@ class SMETWriter {
* (timestamp is not counted if present)
*/
void set_width(const std::vector<int>& vec_width);
const std::string toString() const;
private:
void print_if_exists(const std::string& header_field, std::ofstream& fout) const;
......
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