WSL/SLF GitLab Repository

Commit 398a70e4 authored by Mathias Bavay's avatar Mathias Bavay
Browse files

More changes to digest second time resolution in Date.

parent 841d9337
......@@ -45,6 +45,7 @@ void IOManager::initIOManager()
void IOManager::setProcessingLevel(const unsigned int& i_level)
{
tsmanager.setProcessingLevel(i_level);
gridsmanager.setProcessingLevel(i_level);
}
void IOManager::setMinBufferRequirements(const double& buffer_size, const double& buff_before)
......
......@@ -509,6 +509,28 @@ void Date::getTime(int& hour_out, int& minute_out, const bool& gmt) const {
}
}
/**
* @brief Return time of the day.
* @param hour_out
* @param minute_out
* @param second_out
* @param gmt convert returned value to GMT? (default: false)
*/
void Date::getTime(int& hour_out, int& minute_out, int& second_out, const bool& gmt) const {
if(undef==true)
throw UnknownValueException("Date object is undefined!", AT);
if(gmt) {
hour_out = gmt_hour;
minute_out = gmt_minute;
second_out = gmt_second;
} else {
const double local_julian = GMTToLocal(gmt_julian);
int local_year, local_month, local_day;
calculateValues(local_julian, local_year, local_month, local_day, hour_out, minute_out, second_out);
}
}
/**
* @brief Return year, month, day.
* @param year_out
......@@ -581,6 +603,33 @@ void Date::getDate(int& year_out, int& month_out, int& day_out, int& hour_out, i
}
}
/**
* @brief Return year, month, day.
* @param year_out
* @param month_out
* @param day_out
* @param hour_out
* @param minute_out
* @param second_out
* @param gmt convert returned value to GMT? (default: false)
*/
void Date::getDate(int& year_out, int& month_out, int& day_out, int& hour_out, int& minute_out, int& second_out, const bool& gmt) const {
if(undef==true)
throw UnknownValueException("Date object is undefined!", AT);
if(gmt) {
year_out = gmt_year;
month_out = gmt_month;
day_out = gmt_day;
hour_out = gmt_hour;
minute_out = gmt_minute;
second_out = gmt_second;
} else {
const double local_julian = GMTToLocal(gmt_julian);
calculateValues(local_julian, year_out, month_out, day_out, hour_out, minute_out, second_out);
}
}
/**
* @brief Return the julian day for the current date.
* Return the day of the year index for the current Date object
......
......@@ -116,7 +116,9 @@ class Date {
void getDate(int& year, int& month, int& day, const bool& gmt=false) const;
void getDate(int& year, int& month, int& day, int& hour, const bool& gmt=false) const;
void getDate(int& year, int& month, int& day, int& hour, int& minute, const bool& gmt=false) const;
void getDate(int& year, int& month, int& day, int& hour, int& minute, int& second, const bool& gmt=false) const;
void getTime(int& hour_out, int& minute_out, const bool& gmt=false) const;
void getTime(int& hour_out, int& minute_out, int& second_out, const bool& gmt=false) const;
int getYear(const bool& gmt=false) const;
int getJulianDayNumber(const bool& gmt=false) const;
......
......@@ -92,25 +92,21 @@ void A3DIO::read2DGrid(Grid2DObject&, const MeteoGrids::Parameters&, const Date&
throw IOException("Nothing implemented here", AT);
}
void A3DIO::readDEM(DEMObject& dem_out)
void A3DIO::readDEM(DEMObject& /*dem_out*/)
{
//Nothing so far
(void)dem_out;
throw IOException("Nothing implemented here", AT);
}
void A3DIO::readLanduse(Grid2DObject& landuse_out)
void A3DIO::readLanduse(Grid2DObject& /*landuse_out*/)
{
//Nothing so far
(void)landuse_out;
throw IOException("Nothing implemented here", AT);
}
void A3DIO::readAssimilationData(const Date& date_in, Grid2DObject& da_out)
void A3DIO::readAssimilationData(const Date& /*date_in*/, Grid2DObject& /*da_out*/)
{
//Nothing so far
(void)date_in;
(void)da_out;
throw IOException("Nothing implemented here", AT);
}
......@@ -454,9 +450,8 @@ void A3DIO::constructMeteo2DFilenames(const Date& startDate, const Date& endDate
{
filenames.clear();
int startyear=0, endyear=0, dummy=0;
startDate.getDate(startyear, dummy, dummy, dummy, dummy);
endDate.getDate(endyear, dummy, dummy, dummy, dummy);
const int startyear = startDate.getYear();
const int endyear = endDate.getYear();
std::string tmp;
cfg.getValue("METEOPATH", "Input", tmp);
......
......@@ -248,7 +248,7 @@ void GRIBIO::getDate(grib_handle* h, Date &base, double &d1, double &d2) {
GRIB_CHECK(grib_get_long(h,"dataTime",&dataTime),0);
const int year=static_cast<int>(dataDate/10000), month=static_cast<int>(dataDate/100-year*100), day=static_cast<int>(dataDate-month*100-year*10000);
const int hour=static_cast<int>(dataTime/100), minutes=static_cast<int>(dataTime-hour*100);
const int hour=static_cast<int>(dataTime/100), minutes=static_cast<int>(dataTime-hour*100); //HACK: handle seconds!
base.setDate(year, month, day, hour, minutes, tz_in);
//reading offset to base date/time, as used for forecast, computed at time t for t+offset
......
......@@ -277,8 +277,8 @@ void GSNIO::readMeteoData(const Date& dateStart, const Date& dateEnd,
void GSNIO::readData(const Date& dateStart, const Date& dateEnd, std::vector<MeteoData>& vecMeteo, const size_t& stationindex)
{
const std::string station_id = vecStationName[stationindex];
const string anon_request = sensors_endpoint + "/" + station_id + "?" + sensors_format + "&from=" + dateStart.toString(Date::ISO) + ":00"
+ "&to=" + dateEnd.toString(Date::ISO) + ":00";
const string anon_request = sensors_endpoint + "/" + station_id + "?" + sensors_format + "&from=" + dateStart.toString(Date::ISO)
+ "&to=" + dateEnd.toString(Date::ISO);
const string auth = "&username=" + userid + "&password=" + passwd;
const string request = (!userid.empty())? anon_request+auth : anon_request;
......
......@@ -721,11 +721,11 @@ void ImisIO::readSWE(const Date& dateStart, const Date& dateEnd, std::vector< st
stmt->setPrefetchRowCount(max_row);
// construct the oracle specific Date object: year, month, day, hour, minutes
int year, month, day, hour, minutes;
dateS.getDate(year, month, day, hour, minutes);
const occi::Date begindate(env, year, month, day, hour, minutes);
dateE.getDate(year, month, day, hour, minutes);
const occi::Date enddate(env, year, month, day, hour, minutes);
int year, month, day, hour, minutes, seconds;
dateS.getDate(year, month, day, hour, minutes, seconds);
const occi::Date begindate(env, year, month, day, hour, minutes, seconds);
dateE.getDate(year, month, day, hour, minutes, seconds);
const occi::Date enddate(env, year, month, day, hour, minutes, seconds);
stmt->setString(1, stat_abk); // set 1st variable's value (station name)
stmt->setString(2, stao_nr); // set 2nd variable's value (station number)
stmt->setDate(3, begindate); // set 3rd variable's value (begin date)
......@@ -998,11 +998,11 @@ bool ImisIO::getStationData(const std::string& stat_abk, const std::string& stao
stmt->setPrefetchRowCount(max_row);
// construct the oracle specific Date object: year, month, day, hour, minutes
int year, month, day, hour, minutes;
dateS.getDate(year, month, day, hour, minutes);
const occi::Date begindate(env, year, month, day, hour, minutes);
dateE.getDate(year, month, day, hour, minutes);
const occi::Date enddate(env, year, month, day, hour, minutes);
int year, month, day, hour, minutes, seconds;
dateS.getDate(year, month, day, hour, minutes, seconds);
const occi::Date begindate(env, year, month, day, hour, minutes, seconds);
dateE.getDate(year, month, day, hour, minutes, seconds);
const occi::Date enddate(env, year, month, day, hour, minutes, seconds);
stmt->setString(1, stat_abk); // set 1st variable's value (station name)
stmt->setString(2, stao_nr); // set 2nd variable's value (station number)
stmt->setDate(3, begindate); // set 3rd variable's value (begin date)
......
......@@ -869,7 +869,7 @@ void NetCDFIO::create_meta_data(const int& ncid, const int& did, std::map<std::s
// Create the parameter variables in the NetCDF dataset, allocate memory for the
// respective C arrays and store the variable ids in the varid map.
void NetCDFIO::create_parameters(const int& ncid, const int& did_time, const int& did_points, const size_t& number_of_records,
const size_t& number_of_stations, std::map<size_t, std::string>& map_param_name,
const size_t& number_of_stations, std::map<size_t, std::string>& map_param_name,
std::map<std::string, double*>& map_data_2D, std::map<std::string, int>& varid)
{
// At this point map_param_name holds all parameters that have values different from nodata
......
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