WSL/SLF GitLab Repository

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

Finally, the proper handling of virtual stations is taking shape: using two...

Finally, the proper handling of virtual stations is taking shape: using two tsmanagers, it is possible to temporally resample the data between spatially interpolated time steps. The strategy to decide which timesteps should be temporally resampled is still buggy, this will have to be improved (currently, it resamples and then spatially interpolates at time when it should resample the spatial interpolations instead).
parent c526bff1
......@@ -53,6 +53,13 @@ class GridsManager {
*/
const Config getConfig() const {return cfg;}
/**
* @brief Returns a copy of the internal IOHandler object.
* This is convenient to clone an iomanager
* @return new IOHandler object as a copy of the internal IOHandler
*/
IOHandler& getIOHandler() const {return iohandler;}
const std::string toString() const;
private:
......
......@@ -24,14 +24,14 @@ namespace mio {
IOManager::IOManager(const std::string& filename_in) : cfg(filename_in), iohandler(cfg),
tsmanager(iohandler, cfg), gridsmanager(iohandler, cfg), interpolator(cfg, tsmanager, gridsmanager),
downscaling(false), virtual_stations(false)
vstations_refresh_rate(IOUtils::unodata), downscaling(false), virtual_stations(false)
{
initIOManager();
}
IOManager::IOManager(const Config& i_cfg) : cfg(i_cfg), iohandler(cfg),
tsmanager(iohandler, cfg), gridsmanager(iohandler, cfg), interpolator(cfg, tsmanager, gridsmanager),
downscaling(false), virtual_stations(false)
vstations_refresh_rate(IOUtils::unodata), downscaling(false), virtual_stations(false)
{
initIOManager();
}
......@@ -40,12 +40,19 @@ void IOManager::initIOManager()
{
cfg.getValue("Virtual_stations", "Input", virtual_stations, IOUtils::nothrow);
cfg.getValue("Downscaling", "Input", downscaling, IOUtils::nothrow);
if (virtual_stations || downscaling) { //in this case, we do not want to re-apply the filters
tsmanager.setProcessingLevel(IOUtils::resampled | IOUtils::generated);
gridsmanager.setProcessingLevel(IOUtils::resampled | IOUtils::generated);
cfg.getValue("VSTATIONS_REFRESH_RATE", "Input", vstations_refresh_rate, IOUtils::nothrow);
}
}
void IOManager::setProcessingLevel(const unsigned int& i_level)
{
tsmanager.setProcessingLevel(i_level);
gridsmanager.setProcessingLevel(i_level);
if (!virtual_stations && !downscaling) {
tsmanager.setProcessingLevel(i_level);
gridsmanager.setProcessingLevel(i_level);
}
}
void IOManager::setMinBufferRequirements(const double& buffer_size, const double& buff_before)
......@@ -100,10 +107,39 @@ size_t IOManager::getMeteoData(const Date& i_date, METEO_SET& vecMeteo)
if (!virtual_stations && !downscaling) { //this is the usual case
tsmanager.getMeteoData(i_date, vecMeteo);
} else {
if (virtual_stations)
interpolator.getVirtualMeteoData(Meteo2DInterpolator::VSTATIONS, i_date, vecMeteo);
if (downscaling)
interpolator.getVirtualMeteoData(Meteo2DInterpolator::SMART_DOWNSCALING, i_date, vecMeteo);
//std::cerr << "Calling getMeteoData @ " << i_date.toString(Date::ISO) << "\n";
Date buff_start( tsmanager.getRawBufferStart() ), buff_end( tsmanager.getRawBufferEnd() );
Date request_date( i_date );
bool rebuffer = false;
if (buff_start.isUndef()) { //the buffer is empty
//request_date.rnd(vstations_refresh_rate, Date::CLOSEST);
rebuffer = true;
} else {
buff_start.rnd(vstations_refresh_rate, Date::UP);
buff_end.rnd(vstations_refresh_rate, Date::DOWN);
if (i_date<buff_start || i_date>buff_end) { //we need to read more data in the buffer
const Date::RND rnd_direction = (i_date<buff_start)? Date::DOWN : Date::UP;
request_date.rnd(vstations_refresh_rate, rnd_direction);
rebuffer = true;
}
}
if (rebuffer) {
const double half_range = (vstations_refresh_rate)/(3600.*24.*2.); //we add 1s to account for rounding errors
const Date range_start = request_date - half_range;
const Date range_end = request_date + half_range;
//if ( vstations_refresh_rate!=IOUtils::unodata && Date::mod(i_date, vstations_refresh_rate) != 0) return vecMeteo.size();
if (virtual_stations)
interpolator.getVirtualMeteoData(Meteo2DInterpolator::VSTATIONS, request_date, vecMeteo);
if (downscaling)
interpolator.getVirtualMeteoData(Meteo2DInterpolator::SMART_DOWNSCALING, request_date, vecMeteo);
tsmanager.push_meteo_data(IOUtils::raw, range_start, range_end, vecMeteo);
//std::cerr << "Rebuffering, pushed data point @ " << request_date.toString(Date::ISO) << " buffer: [" << range_start.toString(Date::ISO) << " - " << range_end.toString(Date::ISO) << "]\n";
} /*else
std::cerr << "No rebuffer @ " << request_date.toString(Date::ISO) << "\n";*/
tsmanager.getMeteoData(i_date, vecMeteo);
}
return vecMeteo.size();
......@@ -117,7 +153,7 @@ void IOManager::writeMeteoData(const std::vector< METEO_SET >& vecMeteo, const s
bool IOManager::getMeteoData(const Date& date, const DEMObject& dem, const MeteoData::Parameters& meteoparam,
Grid2DObject& result)
{
string info_string;
std::string info_string;
const bool status = getMeteoData(date, dem, meteoparam, result, info_string);
cerr << "[i] Interpolating " << MeteoData::getParameterName(meteoparam);
cerr << " (" << info_string << ") " << endl;
......
......@@ -222,6 +222,7 @@ class IOManager {
TimeSeriesManager tsmanager;
GridsManager gridsmanager;
Meteo2DInterpolator interpolator;
unsigned int vstations_refresh_rate; ///< when using virtual stations, how often should the data be spatially re-interpolated?
bool downscaling; ///< Are we downscaling meteo grids instead of interpolating stations' data?
bool virtual_stations; ///< compute the meteo values at virtual stations
};
......
......@@ -75,31 +75,58 @@ namespace mio {
*/
Meteo2DInterpolator::Meteo2DInterpolator(const Config& i_cfg, TimeSeriesManager& i_tsmanager, GridsManager& i_gridsmanager)
: cfg(i_cfg), tsmanager(i_tsmanager), gridsmanager(i_gridsmanager),
: cfg(i_cfg), tsmanager(&i_tsmanager), gridsmanager(&i_gridsmanager),
grid_buffer(0), mapAlgorithms(),
v_params(), v_coords(), v_stations(), virtual_point_cache(),
vstations_refresh_rate(IOUtils::unodata), algorithms_ready(false), use_full_dem(false)
v_params(), v_coords(), v_stations(),
algorithms_ready(false), use_full_dem(false), use_internal_managers(false)
{
size_t max_grids = 10; //default number of grids to keep in buffer
cfg.getValue("BUFF_GRIDS", "Interpolations2D", max_grids, IOUtils::nothrow);
grid_buffer.setMaxGrids(max_grids);
setAlgorithms();
bool virtual_stations = false; ///< compute the meteo values at virtual stations
cfg.getValue("Virtual_stations", "Input", virtual_stations, IOUtils::nothrow);
if (virtual_stations) {
cfg.getValue("VSTATIONS_REFRESH_RATE", "Input", vstations_refresh_rate, IOUtils::nothrow);
cfg.getValue("Interpol_Use_Full_DEM", "Input", use_full_dem, IOUtils::nothrow);
}
bool downscaling = false; ///< Are we downscaling meteo grids instead of interpolating stations' data?
cfg.getValue("Downscaling", "Input", downscaling, IOUtils::nothrow);
if (virtual_stations && downscaling)
throw InvalidArgumentException("It is not possible to use both Virtual_stations and Downscaling!", AT);
if (virtual_stations || downscaling) {
use_internal_managers = (virtual_stations || downscaling);
if (use_internal_managers) {
tsmanager = new TimeSeriesManager(i_tsmanager.getIOHandler(), i_cfg);
gridsmanager = new GridsManager(i_gridsmanager.getIOHandler(), i_cfg);
initVirtualStations(downscaling); //adjust the coordinates if downscaling
}
size_t max_grids = 10; //default number of grids to keep in buffer
cfg.getValue("BUFF_GRIDS", "Interpolations2D", max_grids, IOUtils::nothrow);
grid_buffer.setMaxGrids(max_grids);
setAlgorithms();
}
Meteo2DInterpolator::Meteo2DInterpolator(const Meteo2DInterpolator& source)
: cfg(source.cfg), tsmanager(source.tsmanager), gridsmanager(source.gridsmanager),
grid_buffer(source.grid_buffer), mapAlgorithms(source.mapAlgorithms),
v_params(source.v_params), v_coords(source.v_coords), v_stations(source.v_stations),
algorithms_ready(source.algorithms_ready), use_full_dem(source.use_full_dem), use_internal_managers(source.use_internal_managers)
{}
Meteo2DInterpolator& Meteo2DInterpolator::operator=(const Meteo2DInterpolator& source) {
if (this != &source) {
//cfg = source.cfg;
tsmanager = source.tsmanager;
gridsmanager = source.gridsmanager;
grid_buffer = source.grid_buffer;
mapAlgorithms = source.mapAlgorithms;
v_params = source.v_params;
v_coords = source.v_coords;
v_stations = source.v_stations;
algorithms_ready = source.algorithms_ready;
use_full_dem = source.use_full_dem;
use_internal_managers = source.use_internal_managers;
}
return *this;
}
Meteo2DInterpolator::~Meteo2DInterpolator()
......@@ -110,6 +137,10 @@ Meteo2DInterpolator::~Meteo2DInterpolator()
for (size_t ii=0; ii<vecAlgs.size(); ++ii)
delete vecAlgs[ii];
}
if (use_internal_managers) {
delete tsmanager;
delete gridsmanager;
}
}
/* By reading the Config object build up a list of user configured algorithms
......@@ -132,7 +163,7 @@ void Meteo2DInterpolator::setAlgorithms()
for (size_t jj=0; jj<nrOfAlgorithms; jj++) {
std::vector<std::string> vecArgs;
getArgumentsForAlgorithm(parname, tmpAlgorithms[jj], vecArgs);
vecAlgorithms[jj] = AlgorithmFactory::getAlgorithm( tmpAlgorithms[jj], *this, vecArgs, tsmanager, gridsmanager);
vecAlgorithms[jj] = AlgorithmFactory::getAlgorithm( tmpAlgorithms[jj], *this, vecArgs, *tsmanager, *gridsmanager);
}
if (nrOfAlgorithms>0) {
......@@ -357,7 +388,7 @@ void Meteo2DInterpolator::initVirtualStations(const bool& adjust_coordinates)
throw NoDataException("In order to use virtual stations, please provide a DEM!", AT);
DEMObject dem;
dem.setUpdatePpt( DEMObject::SLOPE ); //we only need the elevation
gridsmanager.readDEM(dem);
gridsmanager->readDEM(dem);
//get virtual stations coordinates
std::string coordin, coordinparam, coordout, coordoutparam;
......@@ -421,16 +452,9 @@ size_t Meteo2DInterpolator::getVirtualStationsData(const Date& i_date, METEO_SET
{
vecMeteo.clear();
// Check if data is available in cache
const std::map<Date, vector<MeteoData> >::const_iterator it = virtual_point_cache.find(i_date);
if (it != virtual_point_cache.end()){
vecMeteo = it->second;
return vecMeteo.size();
}
//get data from real input stations
METEO_SET vecTrueMeteo;
tsmanager.getMeteoData(i_date, vecTrueMeteo);
tsmanager->getMeteoData(i_date, vecTrueMeteo);
if (vecTrueMeteo.empty()) return 0;
if (v_params.empty()) {
......@@ -448,11 +472,10 @@ size_t Meteo2DInterpolator::getVirtualStationsData(const Date& i_date, METEO_SET
MeteoData md(i_date, v_stations[ii]);
vecMeteo.push_back( md );
}
if ( vstations_refresh_rate!=IOUtils::unodata && Date::mod(i_date, vstations_refresh_rate) != 0) return vecMeteo.size();
//fill meteo parameters
DEMObject dem;
gridsmanager.readDEM(dem); //this is not a big deal since it will be in the buffer
gridsmanager->readDEM(dem); //this is not a big deal since it will be in the buffer
std::string info_string;
for (size_t param=0; param<v_params.size(); param++) {
std::vector<double> result;
......@@ -467,14 +490,7 @@ size_t Meteo2DInterpolator::getVirtualStationsData(const Date& i_date, METEO_SET
size_t Meteo2DInterpolator::getVirtualStationsFromGrid(const Date& i_date, METEO_SET& vecMeteo)
{
vecMeteo.clear();
// Check if data is available in cache
const map<Date, vector<MeteoData> >::const_iterator it = virtual_point_cache.find(i_date);
if (it != virtual_point_cache.end()){
vecMeteo = it->second;
return vecMeteo.size();
}
if (v_params.empty()) { //get parameters to interpolate if not already done
std::vector<std::string> vecStr;
cfg.getValue("Virtual_parameters", "Input", vecStr);
......@@ -494,12 +510,12 @@ size_t Meteo2DInterpolator::getVirtualStationsFromGrid(const Date& i_date, METEO
DEMObject dem;
dem.setUpdatePpt( DEMObject::NO_UPDATE ); //we only need the elevation
gridsmanager.readDEM(dem); //this is not a big deal since it will be in the buffer
gridsmanager->readDEM(dem); //this is not a big deal since it will be in the buffer
for (size_t param=0; param<v_params.size(); param++) { //loop over required parameters
const MeteoGrids::Parameters grid_param = static_cast<MeteoGrids::Parameters>(v_params[param]);
Grid2DObject grid;
gridsmanager.read2DGrid(grid, grid_param, i_date);
gridsmanager->read2DGrid(grid, grid_param, i_date);
if (!grid.isSameGeolocalization(dem))
throw InvalidArgumentException("In SMART_DOWNSCALING, the DEM and the source grid don't match for '"+MeteoGrids::getParameterName(grid_param)+"' on "+i_date.toString(Date::ISO));
......
......@@ -102,6 +102,8 @@ class Meteo2DInterpolator {
* @brief Constructor.
*/
Meteo2DInterpolator(const Config& i_cfg, TimeSeriesManager& i_tsmanager, GridsManager& i_gridsmanager);
Meteo2DInterpolator(const Meteo2DInterpolator&);
Meteo2DInterpolator& operator=(const Meteo2DInterpolator&); ///<Assignement operator
~Meteo2DInterpolator();
......@@ -180,8 +182,8 @@ class Meteo2DInterpolator {
void initVirtualStations(const bool& adjust_coordinates);
const Config& cfg; ///< Reference to Config object, initialized during construction
TimeSeriesManager& tsmanager; ///< Reference to TimeSeriesManager object, used for callbacks, initialized during construction
GridsManager& gridsmanager; ///< Reference to GridsManager object, used for callbacks, initialized during construction
TimeSeriesManager *tsmanager; ///< Reference to TimeSeriesManager object, used for callbacks, initialized during construction
GridsManager *gridsmanager; ///< Reference to GridsManager object, used for callbacks, initialized during construction
GridBuffer grid_buffer;
std::map< std::string, std::vector<InterpolationAlgorithm*> > mapAlgorithms; //per parameter interpolation algorithms
......@@ -189,12 +191,10 @@ class Meteo2DInterpolator {
std::vector<size_t> v_params; ///< Parameters for virtual stations
std::vector<Coords> v_coords; ///< Coordinates for virtual stations
std::vector<StationData> v_stations; ///< metadata for virtual stations
std::map<Date, METEO_SET > virtual_point_cache; ///< stores already resampled virtual data points
unsigned int vstations_refresh_rate; ///< how often to refresh the spatial interpolations for virtual stations? (in seconds)
bool algorithms_ready; ///< Have the algorithms objects been constructed?
bool use_full_dem; ///< use full dem for point-wise spatial interpolations
bool use_internal_managers; ///< When using virtual stations or downsampling, the ts and grids managers need to be private
};
} //end namespace
......
......@@ -28,7 +28,7 @@ TimeSeriesManager::TimeSeriesManager(IOHandler& in_iohandler, const Config& in_c
meteoprocessor(in_cfg), dataGenerator(in_cfg),
proc_properties(), point_cache(), raw_buffer(), filtered_cache(),
chunk_size(), buff_before(),
processing_level(IOUtils::filtered | IOUtils::resampled | IOUtils::generated)
processing_level(IOUtils::raw | IOUtils::filtered | IOUtils::resampled | IOUtils::generated)
{
meteoprocessor.getWindowSize(proc_properties);
setDfltBufferProperties();
......@@ -87,10 +87,6 @@ void TimeSeriesManager::setProcessingLevel(const unsigned int& i_level)
if (i_level >= IOUtils::num_of_levels)
throw InvalidArgumentException("The processing level is invalid", AT);
if (((i_level & IOUtils::raw) == IOUtils::raw)
&& ((i_level & IOUtils::filtered) == IOUtils::filtered))
throw InvalidArgumentException("The processing level is invalid (raw and filtered at the same time)", AT);
processing_level = i_level;
}
......@@ -115,9 +111,33 @@ void TimeSeriesManager::push_meteo_data(const IOUtils::ProcessingLevel& level, c
}
point_cache.clear(); //clear point cache, so that we don't return resampled values of deprecated data
//if (invalidate_cache) point_cache.clear(); //clear point cache, so that we don't return resampled values of deprecated data
}
void TimeSeriesManager::push_meteo_data(const IOUtils::ProcessingLevel& level, const Date& date_start, const Date& date_end,
const std::vector< MeteoData >& vecMeteo, const bool& invalidate_cache)
{
//perform check on date_start and date_end
if (date_end < date_start) {
std::ostringstream ss;
ss << "Trying to push data set from " << date_start.toString(Date::ISO) << " to " << date_end.toString(Date::ISO) << ". ";
ss << " Obviously, date_start should be less than date_end!";
throw InvalidArgumentException(ss.str(), AT);
}
if (level == IOUtils::filtered) {
filtered_cache.push(date_start, date_end, vecMeteo);
} else if (level == IOUtils::raw) {
filtered_cache.clear();
raw_buffer.push(date_start, date_end, vecMeteo);
} else {
throw InvalidArgumentException("The processing level is invalid (should be raw OR filtered)", AT);
}
if (invalidate_cache) point_cache.clear(); //clear point cache, so that we don't return resampled values of deprecated data
}
size_t TimeSeriesManager::getStationData(const Date& date, STATIONS_SET& vecStation)
size_t TimeSeriesManager::getStationData(const Date& date, STATIONS_SET& vecStation) //HACK HACK HACK
{
vecStation.clear();
......@@ -141,7 +161,7 @@ size_t TimeSeriesManager::getMeteoData(const Date& dateStart, const Date& dateEn
if (!success) {
std::vector< std::vector<MeteoData> > tmp_meteo;
fillRawBuffer(dateStart, dateEnd);
if ((IOUtils::raw & processing_level) == IOUtils::raw) fillRawBuffer(dateStart, dateEnd);
raw_buffer.get(dateStart, dateEnd, tmp_meteo);
//now it needs to be secured that the data is actually filtered, if configured
......@@ -192,12 +212,12 @@ size_t TimeSeriesManager::getMeteoData(const Date& i_date, METEO_SET& vecMeteo)
const bool cached = (!filtered_cache.empty()) && (filtered_cache.getBufferStart() <= buffer_start) && (filtered_cache.getBufferEnd() >= buffer_end);
if (!cached) {
//explicit caching, rebuffer if necessary
fillRawBuffer(buffer_start, buffer_end);
if ((IOUtils::raw & processing_level) == IOUtils::raw) fillRawBuffer(buffer_start, buffer_end);
fill_filtered_cache();
}
data = &filtered_cache.getBuffer();
} else { //data to be resampled should be IOUtils::raw
fillRawBuffer(buffer_start, buffer_end);
if ((IOUtils::raw & processing_level) == IOUtils::raw) fillRawBuffer(buffer_start, buffer_end);
data = &raw_buffer.getBuffer();
}
......
......@@ -82,6 +82,9 @@ class TimeSeriesManager {
void push_meteo_data(const IOUtils::ProcessingLevel& level, const Date& date_start, const Date& date_end,
const std::vector< METEO_SET >& vecMeteo);
void push_meteo_data(const IOUtils::ProcessingLevel& level, const Date& date_start, const Date& date_end,
const std::vector< MeteoData >& vecMeteo, const bool& invalidate_cache=true);
/**
* @brief Set the desired ProcessingLevel of the TimeSeriesManager instance
* The processing level affects the way meteo data is read and processed
......@@ -142,6 +145,29 @@ class TimeSeriesManager {
* @return new Config object as a copy of the internal Config
*/
const Config getConfig() const {return cfg;}
/**
* @brief Returns a copy of the internal IOHandler object.
* This is convenient to clone an iomanager
* @return new IOHandler object as a copy of the internal IOHandler
*/
IOHandler& getIOHandler() const {return iohandler;}
/**
* @brief Returns the begining of the raw buffer.
* This is the start date of the <b>request</b> that was given to the IOHandler. If there was no data
* at this date, then the date of the first data would be greater.
* @return start date of the buffer
*/
Date getRawBufferStart() const {return raw_buffer.getBufferStart();}
/**
* @brief Returns the end of the raw buffer.
* This is the end date of the <b>request</b> that was given to the IOHandler. If there was no data
* at this date, then the date of the last data would be less.
* @return end date of the buffer
*/
Date getRawBufferEnd() const {return raw_buffer.getBufferEnd();}
private:
void setDfltBufferProperties();
......
......@@ -84,19 +84,24 @@ void MeteoBuffer::clear()
ts_end.setUndef(true);
}
void MeteoBuffer::push(const std::vector<MeteoData>& vecMeteo)
void MeteoBuffer::push(const Date& date_start, const Date& date_end, const std::vector<MeteoData>& vecMeteo)
{
const size_t nrStationsPush = vecMeteo.size();
if (nrStationsPush==0) return;
if (empty()) {
ts_start = vecMeteo.front().date;
ts_end = vecMeteo.front().date;
ts_start = date_start;
ts_end = date_end;
ts_buffer.resize(nrStationsPush); //allocate the memory
for (size_t ii=0; ii<nrStationsPush; ii++)
ts_buffer[ii].push_back( vecMeteo[ii] );
return;
} else {
if (date_start>ts_end || date_end<ts_start) {
std::cerr << "Clearing buffer [" << ts_start.toString(Date::ISO) << " - " << ts_end.toString(Date::ISO) << "] to accommodate date [";
std::cerr << date_start.toString(Date::ISO) << " - " << date_end.toString(Date::ISO) << "]\n";
}
const size_t nrStationsBuffer = ts_buffer.size();
//check that we are dealing with the same stations
......@@ -104,23 +109,13 @@ void MeteoBuffer::push(const std::vector<MeteoData>& vecMeteo)
ostringstream ss;
ss << "The number of stations changed over time from " << nrStationsBuffer << " to " << nrStationsPush << ", ";
ss << "this is not handled yet!";
std::cerr << "trying to push: ";
for (size_t ii=0; ii<nrStationsPush; ii++) //for all stations
std::cerr << vecMeteo[ii].meta.stationID << " ";
std::cerr << "\nWas before: ";
for (size_t ii=0; ii<nrStationsBuffer; ii++) //for all stations
std::cerr << ts_buffer[ii].front().meta.stationID << " ";
throw IOException(ss.str(), AT);
}
for (size_t ii=0; ii<nrStationsPush; ii++) { //for all stations
if (ts_buffer[ii].empty()) continue;
if (ts_buffer[ii].front().meta.getHash()!=vecMeteo[ii].meta.getHash()) {
ostringstream ss;
ss << "The stations changed over time from " << ts_buffer[ii].front().meta.getHash() << " to " << vecMeteo[ii].meta.getHash() << ", ";
ss << "this is not handled yet!";
throw IOException(ss.str(), AT);
}
if (ts_buffer[ii].front().meta.getHash()!=vecMeteo[ii].meta.getHash())
throw IOException("A station changed over time from "+ts_buffer[ii].front().meta.getHash()+" to "+vecMeteo[ii].meta.getHash(), AT);
}
}
......@@ -129,6 +124,10 @@ void MeteoBuffer::push(const std::vector<MeteoData>& vecMeteo)
const Date buffer_start = ts_buffer[ii].front().date;
const Date buffer_end = ts_buffer[ii].back().date;
const Date data_ts = vecMeteo[ii].date;
if (data_ts<date_start || data_ts>date_end) {
const std::string msg( "Trying to insert data point at "+data_ts.toString(Date::ISO)+" in while declaring it to be between "+date_start.toString(Date::ISO)+" and "+date_end.toString(Date::ISO));
throw InvalidArgumentException(msg, AT);
}
if (data_ts<buffer_start) { //the data simply fits at the start
ts_buffer[ii].insert(ts_buffer[ii].begin(), vecMeteo[ii]);
......@@ -144,17 +143,8 @@ void MeteoBuffer::push(const std::vector<MeteoData>& vecMeteo)
ts_buffer[ii].insert(ts_buffer[ii].begin()+insert_pos, vecMeteo[ii]); //insert takes place at element *before* insert_pos
else
ts_buffer[ii][insert_pos] = vecMeteo[ii]; //if the element already existed, replace it
ts_start = min(ts_start, data_ts);
ts_end = max(ts_end, data_ts);
}
}
void MeteoBuffer::push(const Date& date_start, const Date& date_end, const std::vector<MeteoData>& vecMeteo)
{
//HACK: check that the provided data is between date_start and date_end?
push(vecMeteo);
//take the data validity range into account for buffer validity
ts_start = min(ts_start, date_start);
ts_end = max(ts_end, date_end);
}
......
......@@ -111,12 +111,6 @@ class MeteoBuffer {
*/
void push(const Date& date_start, const Date& date_end, const std::vector<MeteoData>& vecMeteo);
/**
* @brief Add a data point for several stations. The date is taken from the data itself
* @param vecMeteo A vector of <MeteoData> objects providing the data
*/
void push(const std::vector<MeteoData>& vecMeteo);
const std::string toString() const;
//HACK: these should be removed in order to hide the internals! But this requires a re-write of MeteoProcessor
......
Markdown is supported
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