WSL/SLF GitLab Repository

Commit 8791efc7 authored by Mathias Bavay's avatar Mathias Bavay
Browse files

One more step closer to the goal: the dem is now only passed when calling...

One more step closer to the goal: the dem is now only passed when calling calculate() and the simpleDEMWindInterpolate now computes the curvatures if necessary.

Small optimizations in IOHandler.
parent 88e7cb8e
......@@ -229,7 +229,7 @@ IOInterface* IOHandler::getPlugin(const std::string& cfgkey, const std::string&
std::string op_src;
cfg.getValue(cfgkey, cfgsection, op_src);
std::map<std::string, IOPlugin>::iterator mapit = mapPlugins.find(op_src);
const std::map<std::string, IOPlugin>::iterator mapit = mapPlugins.find(op_src);
if (mapit == mapPlugins.end())
throw IOException("Cannot find plugin " + op_src + " as requested in file " + cfg.getSourceName() + ". Has it been activated through ccmake? Is it registered in IOHandler::registerPlugins?", AT);
if ((mapit->second).io == NULL){
......@@ -283,7 +283,7 @@ void IOHandler::readMeteoData(const Date& date, METEO_SET& vecMeteo)
vecMeteo.clear();
vecMeteo.reserve( meteoTmpBuffer.size() );
for (size_t ii=0; ii<meteoTmpBuffer.size(); ii++) {//stations
for (size_t ii=0; ii<meteoTmpBuffer.size(); ++ii) {//stations
if (!meteoTmpBuffer[ii].empty())
vecMeteo.push_back( meteoTmpBuffer[ii].front() );
}
......@@ -291,12 +291,12 @@ void IOHandler::readMeteoData(const Date& date, METEO_SET& vecMeteo)
void IOHandler::checkTimestamps(const std::vector<METEO_SET>& vecVecMeteo) const
{
for(size_t stat_idx=0; stat_idx<vecVecMeteo.size(); stat_idx++) {
for(size_t stat_idx=0; stat_idx<vecVecMeteo.size(); ++stat_idx) {
const size_t nr_timestamps = vecVecMeteo[stat_idx].size();
if(nr_timestamps==0) continue;
Date previous_date( vecVecMeteo[stat_idx][0].date );
for(size_t ii=1; ii<nr_timestamps; ii++) {
for(size_t ii=1; ii<nr_timestamps; ++ii) {
const StationData& station = vecVecMeteo[stat_idx][ii].meta;
const Date& current_date = vecVecMeteo[stat_idx][ii].date;
if(current_date<=previous_date) {
......@@ -361,7 +361,7 @@ void IOHandler::parse_copy_config()
vector<string> copy_keys;
const size_t nrOfMatches = cfg.findKeys(copy_keys, "COPY::", "Input");
for (size_t ii=0; ii<nrOfMatches; ii++) {
for (size_t ii=0; ii<nrOfMatches; ++ii) {
const string name_of_copy = copy_keys[ii].substr(6);
string initial_name;
cfg.getValue(copy_keys[ii], "Input", initial_name);
......@@ -374,17 +374,17 @@ void IOHandler::parse_copy_config()
}
}
/**
* This procedure runs through the MeteoData objects in vecMeteo and according to user
* configuration copies a certain present meteo parameter to another one, named by the
* user in the [Input] section of the io.ini, e.g.
* [Input]
* COPY::TA2 = TA
* means that TA2 will be the name of a new parameter in MeteoData with the copied value
* of the meteo parameter MeteoData::TA
*/
void IOHandler::copy_parameters(const size_t& stationindex, std::vector< METEO_SET >& vecMeteo) const
{
/**
* This procedure runs through the MeteoData objects in vecMeteo and according to user
* configuration copies a certain present meteo parameter to another one, named by the
* user in the [Input] section of the io.ini, e.g.
* [Input]
* COPY::TA2 = TA
* means that TA2 will be the name of a new parameter in MeteoData with the copied value
* of the meteo parameter MeteoData::TA
*/
if (!enable_copying) return; //Nothing configured
size_t station_start=0, station_end=vecMeteo.size();
......@@ -400,11 +400,11 @@ void IOHandler::copy_parameters(const size_t& stationindex, std::vector< METEO_S
const size_t nr_of_params = copy_parameter.size();
vector<size_t> indices; //will hold the indices of the parameters to be copied
for (size_t ii=station_start; ii<station_end; ii++) { //for each station
for (size_t jj=0; jj<vecMeteo[ii].size(); jj++) { //for each MeteoData object of one station
for (size_t ii=station_start; ii<station_end; ++ii) { //for each station
for (size_t jj=0; jj<vecMeteo[ii].size(); ++jj) { //for each MeteoData object of one station
if (jj==0) { //buffer the index numbers
for (size_t kk=0; kk<nr_of_params; kk++) {
for (size_t kk=0; kk<nr_of_params; ++kk) {
const size_t param_index = vecMeteo[ii][jj].getParameterIndex(copy_parameter[kk]);
if (param_index == IOUtils::npos) {
std::stringstream ss;
......@@ -417,7 +417,7 @@ void IOHandler::copy_parameters(const size_t& stationindex, std::vector< METEO_S
}
}
for (size_t kk=0; kk<nr_of_params; kk++) {
for (size_t kk=0; kk<nr_of_params; ++kk) {
const size_t newparam = vecMeteo[ii][jj].addParameter(copy_name[kk]);
vecMeteo[ii][jj](newparam) = vecMeteo[ii][jj](indices[kk]);
}
......
......@@ -193,7 +193,7 @@ void InterpolationAlgorithm::detrend(const Fit1D& trend, const std::vector<doubl
}
}
void InterpolationAlgorithm::retrend(const Fit1D& trend, Grid2DObject &grid) const
void InterpolationAlgorithm::retrend(const DEMObject& dem, const Fit1D& trend, Grid2DObject &grid) const
{
const size_t nxy = grid.getNx()*grid.getNy();
const size_t dem_nxy = dem.grid2D.getNx()*dem.grid2D.getNy();
......@@ -214,9 +214,8 @@ void InterpolationAlgorithm::retrend(const Fit1D& trend, Grid2DObject &grid) con
/**********************************************************************************/
/* Implementation of the various algorithms */
/**********************************************************************************/
double StandardPressureAlgorithm::getQualityRating(const DEMObject& i_dem, const Date& i_date, const MeteoData::Parameters& in_param)
double StandardPressureAlgorithm::getQualityRating(const Date& i_date, const MeteoData::Parameters& in_param)
{
dem = i_dem;
date = i_date;
param = in_param;
nrOfMeasurments = getData(date, param, vecData, vecMeta);
......@@ -230,13 +229,12 @@ double StandardPressureAlgorithm::getQualityRating(const DEMObject& i_dem, const
return 0.1;
}
void StandardPressureAlgorithm::calculate(Grid2DObject& grid) {
void StandardPressureAlgorithm::calculate(const DEMObject& dem, Grid2DObject& grid) {
Interpol2D::stdPressure(dem, grid);
}
double ConstAlgorithm::getQualityRating(const DEMObject& i_dem, const Date& i_date, const MeteoData::Parameters& in_param)
double ConstAlgorithm::getQualityRating(const Date& i_date, const MeteoData::Parameters& in_param)
{
dem = i_dem;
date = i_date;
param = in_param;
nrOfMeasurments = getData(date, param, vecData, vecMeta);
......@@ -252,13 +250,12 @@ double ConstAlgorithm::getQualityRating(const DEMObject& i_dem, const Date& i_da
return 0.0;
}
void ConstAlgorithm::calculate(Grid2DObject& grid) {
void ConstAlgorithm::calculate(const DEMObject& dem, Grid2DObject& grid) {
Interpol2D::constant(Interpol1D::arithmeticMean(vecData), dem, grid);
}
double ConstLapseRateAlgorithm::getQualityRating(const DEMObject& i_dem, const Date& i_date, const MeteoData::Parameters& in_param)
double ConstLapseRateAlgorithm::getQualityRating(const Date& i_date, const MeteoData::Parameters& in_param)
{
dem = i_dem;
date = i_date;
param = in_param;
nrOfMeasurments = getData(date, param, vecData, vecMeta);
......@@ -280,7 +277,7 @@ double ConstLapseRateAlgorithm::getQualityRating(const DEMObject& i_dem, const D
return 0.2;
}
void ConstLapseRateAlgorithm::calculate(Grid2DObject& grid)
void ConstLapseRateAlgorithm::calculate(const DEMObject& dem, Grid2DObject& grid)
{
vector<double> vecAltitudes;
getStationAltitudes(vecMeta, vecAltitudes);
......@@ -292,12 +289,11 @@ void ConstLapseRateAlgorithm::calculate(Grid2DObject& grid)
info << trend.getInfo();
detrend(trend, vecAltitudes, vecData);
Interpol2D::constant(Interpol1D::arithmeticMean(vecData), dem, grid);
retrend(trend, grid);
retrend(dem, trend, grid);
}
double IDWAlgorithm::getQualityRating(const DEMObject& i_dem, const Date& i_date, const MeteoData::Parameters& in_param)
double IDWAlgorithm::getQualityRating(const Date& i_date, const MeteoData::Parameters& in_param)
{
dem = i_dem;
date = i_date;
param = in_param;
nrOfMeasurments = getData(date, param, vecData, vecMeta);
......@@ -313,14 +309,13 @@ double IDWAlgorithm::getQualityRating(const DEMObject& i_dem, const Date& i_date
return 0.2;
}
void IDWAlgorithm::calculate(Grid2DObject& grid)
void IDWAlgorithm::calculate(const DEMObject& dem, Grid2DObject& grid)
{
Interpol2D::IDW(vecData, vecMeta, dem, grid);
}
double IDWLapseAlgorithm::getQualityRating(const DEMObject& i_dem, const Date& i_date, const MeteoData::Parameters& in_param)
double IDWLapseAlgorithm::getQualityRating(const Date& i_date, const MeteoData::Parameters& in_param)
{
dem = i_dem;
date = i_date;
param = in_param;
nrOfMeasurments = getData(date, param, vecData, vecMeta);
......@@ -331,7 +326,7 @@ double IDWLapseAlgorithm::getQualityRating(const DEMObject& i_dem, const Date& i
return 0.7;
}
void IDWLapseAlgorithm::calculate(Grid2DObject& grid)
void IDWLapseAlgorithm::calculate(const DEMObject& dem, Grid2DObject& grid)
{
vector<double> vecAltitudes;
getStationAltitudes(vecMeta, vecAltitudes);
......@@ -343,12 +338,11 @@ void IDWLapseAlgorithm::calculate(Grid2DObject& grid)
info << trend.getInfo();
detrend(trend, vecAltitudes, vecData);
Interpol2D::IDW(vecData, vecMeta, dem, grid); //the meta should NOT be used for elevations!
retrend(trend, grid);
retrend(dem, trend, grid);
}
double LocalIDWLapseAlgorithm::getQualityRating(const DEMObject& i_dem, const Date& i_date, const MeteoData::Parameters& in_param)
double LocalIDWLapseAlgorithm::getQualityRating(const Date& i_date, const MeteoData::Parameters& in_param)
{
dem = i_dem;
date = i_date;
param = in_param;
nrOfMeasurments = getData(date, param, vecData, vecMeta);
......@@ -359,7 +353,7 @@ double LocalIDWLapseAlgorithm::getQualityRating(const DEMObject& i_dem, const Da
return 0.7;
}
void LocalIDWLapseAlgorithm::calculate(Grid2DObject& /*grid*/)
void LocalIDWLapseAlgorithm::calculate(const DEMObject& /*dem*/, Grid2DObject& /*grid*/)
{
/*if (nrOfMeasurments == 0)
throw IOException("Interpolation FAILED for parameter " + MeteoData::getParameterName(param), AT);
......@@ -380,13 +374,12 @@ void LocalIDWLapseAlgorithm::calculate(Grid2DObject& /*grid*/)
info << "r^2=" << Optim::pow2( r2 );*/
}
double RHAlgorithm::getQualityRating(const DEMObject& i_dem, const Date& i_date, const MeteoData::Parameters& in_param)
double RHAlgorithm::getQualityRating(const Date& i_date, const MeteoData::Parameters& in_param)
{
//This algorithm is only valid for RH
if (in_param != MeteoData::RH)
return 0.0;
dem = i_dem;
date = i_date;
param = in_param;
vecData.clear();
......@@ -411,7 +404,7 @@ double RHAlgorithm::getQualityRating(const DEMObject& i_dem, const Date& i_date,
return 0.9;
}
void RHAlgorithm::calculate(Grid2DObject& grid)
void RHAlgorithm::calculate(const DEMObject& dem, Grid2DObject& grid)
{
vector<double> vecAltitudes;
getStationAltitudes(vecMeta, vecAltitudes);
......@@ -434,7 +427,7 @@ void RHAlgorithm::calculate(Grid2DObject& grid)
info << trend.getInfo();
detrend(trend, vecAltitudes, vecTd);
Interpol2D::IDW(vecTd, vecMeta, dem, grid); //the meta should NOT be used for elevations!
retrend(trend, grid);
retrend(dem, trend, grid);
//Recompute Rh from the interpolated td
for (unsigned int jj=0; jj<grid.nrows; jj++) {
......@@ -446,13 +439,12 @@ void RHAlgorithm::calculate(Grid2DObject& grid)
}
}
double ILWRAlgorithm::getQualityRating(const DEMObject& i_dem, const Date& i_date, const MeteoData::Parameters& in_param)
double ILWRAlgorithm::getQualityRating(const Date& i_date, const MeteoData::Parameters& in_param)
{
//This algorithm is only valid for ILWR
if (in_param != MeteoData::ILWR)
return 0.0;
dem = i_dem;
date = i_date;
param = in_param;
vecData.clear();
......@@ -473,7 +465,7 @@ double ILWRAlgorithm::getQualityRating(const DEMObject& i_dem, const Date& i_dat
return 0.9;
}
void ILWRAlgorithm::calculate(Grid2DObject& grid)
void ILWRAlgorithm::calculate(const DEMObject& dem, Grid2DObject& grid)
{
vector<double> vecAltitudes;
getStationAltitudes(vecMeta, vecAltitudes);
......@@ -488,7 +480,7 @@ void ILWRAlgorithm::calculate(Grid2DObject& grid)
info << trend.getInfo();
detrend(trend, vecAltitudes, vecDataEA);
Interpol2D::IDW(vecDataEA, vecMeta, dem, grid); //the meta should NOT be used for elevations!
retrend(trend, grid);
retrend(dem, trend, grid);
//Recompute Rh from the interpolated td
for (unsigned int jj=0; jj<grid.nrows; jj++) {
......@@ -499,13 +491,12 @@ void ILWRAlgorithm::calculate(Grid2DObject& grid)
}
}
double SimpleWindInterpolationAlgorithm::getQualityRating(const DEMObject& i_dem, const Date& i_date, const MeteoData::Parameters& in_param)
double SimpleWindInterpolationAlgorithm::getQualityRating(const Date& i_date, const MeteoData::Parameters& in_param)
{
//This algorithm is only valid for VW
if (in_param != MeteoData::VW)
return 0.0;
dem = i_dem;
date = i_date;
param = in_param;
vecData.clear();
......@@ -522,12 +513,6 @@ double SimpleWindInterpolationAlgorithm::getQualityRating(const DEMObject& i_dem
}
}
//This algorithm requires the curvatures
if (dem.curvature.isEmpty()) {
std::cerr << "[W] WIND_CURV spatial interpolations algorithm selected but no dem curvature available! Skipping algorithm...\n";
return 0.0;
}
if (vecDataVW.empty() || vecDataDW.empty() || nrOfMeasurments==0)
return 0.0;
if( (nrOfMeasurments<vecDataVW.size()/2) || ( nrOfMeasurments<2 ) )
......@@ -536,7 +521,7 @@ double SimpleWindInterpolationAlgorithm::getQualityRating(const DEMObject& i_dem
return 0.9;
}
void SimpleWindInterpolationAlgorithm::calculate(Grid2DObject& grid)
void SimpleWindInterpolationAlgorithm::calculate(const DEMObject& dem, Grid2DObject& grid)
{
vector<double> vecAltitudes;
getStationAltitudes(vecMeta, vecAltitudes);
......@@ -551,7 +536,7 @@ void SimpleWindInterpolationAlgorithm::calculate(Grid2DObject& grid)
info << trend.getInfo();
detrend(trend, vecAltitudes, vecDataVW);
Interpol2D::IDW(vecDataVW, vecMeta, dem, grid); //the meta should NOT be used for elevations!
retrend(trend, grid);
retrend(dem, trend, grid);
Interpol2D::SimpleDEMWindInterpolate(dem, grid, dw);
}
......@@ -575,9 +560,8 @@ std::string USERInterpolation::getGridFileName() const
return gridname;
}
double USERInterpolation::getQualityRating(const DEMObject& i_dem, const Date& i_date, const MeteoData::Parameters& in_param)
double USERInterpolation::getQualityRating(const Date& i_date, const MeteoData::Parameters& in_param)
{
dem = i_dem;
date = i_date;
param = in_param;
nrOfMeasurments = 0;
......@@ -594,7 +578,7 @@ double USERInterpolation::getQualityRating(const DEMObject& i_dem, const Date& i
}
}
void USERInterpolation::calculate(Grid2DObject& grid)
void USERInterpolation::calculate(const DEMObject& dem, Grid2DObject& grid)
{
const std::string filename = getGridFileName();
......@@ -604,9 +588,8 @@ void USERInterpolation::calculate(Grid2DObject& grid)
}
}
double SnowHNWInterpolation::getQualityRating(const DEMObject& i_dem, const Date& i_date, const MeteoData::Parameters& in_param)
double SnowHNWInterpolation::getQualityRating(const Date& i_date, const MeteoData::Parameters& in_param)
{
dem = i_dem;
date = i_date;
param = in_param;
nrOfMeasurments = getData(date, param, vecData, vecMeta);
......@@ -617,7 +600,7 @@ double SnowHNWInterpolation::getQualityRating(const DEMObject& i_dem, const Date
return 0.9;
}
void SnowHNWInterpolation::calculate(Grid2DObject& grid)
void SnowHNWInterpolation::calculate(const DEMObject& dem, Grid2DObject& grid)
{
//retrieve optional arguments
std::string base_algo;
......@@ -634,8 +617,8 @@ void SnowHNWInterpolation::calculate(Grid2DObject& grid)
vector<string> vecArgs2;
mi.getArgumentsForAlgorithm(MeteoData::getParameterName(param), base_algo, vecArgs2); //HACK
auto_ptr<InterpolationAlgorithm> algorithm(AlgorithmFactory::getAlgorithm(base_algo, mi, vecArgs2, iomanager));
algorithm->getQualityRating(dem, date, param);
algorithm->calculate(grid);
algorithm->getQualityRating(date, param);
algorithm->calculate(dem, grid);
info << algorithm->getInfo();
const double orig_mean = grid.grid2D.getMean();
......@@ -704,9 +687,8 @@ bool OrdinaryKrigingAlgorithm::computeVariogram()
return false;
}
double OrdinaryKrigingAlgorithm::getQualityRating(const DEMObject& i_dem, const Date& i_date, const MeteoData::Parameters& in_param)
double OrdinaryKrigingAlgorithm::getQualityRating(const Date& i_date, const MeteoData::Parameters& in_param)
{
dem = i_dem;
date = i_date;
param = in_param;
nrOfMeasurments = getData(date, param, vecData, vecMeta);
......@@ -716,7 +698,7 @@ double OrdinaryKrigingAlgorithm::getQualityRating(const DEMObject& i_dem, const
return 0.1;
}
void OrdinaryKrigingAlgorithm::calculate(Grid2DObject& grid)
void OrdinaryKrigingAlgorithm::calculate(const DEMObject& dem, Grid2DObject& grid)
{
//optimization: getRange (from variogram fit -> exclude stations that are at distances > range (-> smaller matrix)
//or, get max range from io.ini, build variogram from this user defined max range
......@@ -725,7 +707,7 @@ void OrdinaryKrigingAlgorithm::calculate(Grid2DObject& grid)
Interpol2D::ODKriging(vecData, vecMeta, dem, variogram, grid);
}
void LapseOrdinaryKrigingAlgorithm::calculate(Grid2DObject& grid)
void LapseOrdinaryKrigingAlgorithm::calculate(const DEMObject& dem, Grid2DObject& grid)
{
//optimization: getRange (from variogram fit -> exclude stations that are at distances > range (-> smaller matrix)
//or, get max range from io.ini, build variogram from this user defined max range
......@@ -744,8 +726,7 @@ void LapseOrdinaryKrigingAlgorithm::calculate(Grid2DObject& grid)
throw IOException("The variogram for parameter " + MeteoData::getParameterName(param) + " could not be computed!", AT);
Interpol2D::ODKriging(vecData, vecMeta, dem, variogram, grid);
retrend(trend, grid);
retrend(dem, trend, grid);
}
} //namespace
......@@ -138,12 +138,12 @@ class InterpolationAlgorithm {
InterpolationAlgorithm(Meteo2DInterpolator& i_mi,
const std::vector<std::string>& i_vecArgs,
const std::string& i_algo, IOManager& iom) :
mi(i_mi), date(0.), dem(), vecArgs(i_vecArgs), algo(i_algo), iomanager(iom),
mi(i_mi), date(0.), vecArgs(i_vecArgs), algo(i_algo), iomanager(iom),
param(MeteoData::firstparam), vecMeteo(), vecData(), vecMeta(), info(), nrOfMeasurments(0) {};
virtual ~InterpolationAlgorithm() {};
//if anything is not ok (wrong parameter for this algo, insufficient data, etc) -> return zero
virtual double getQualityRating(const DEMObject& i_dem, const Date& i_date, const MeteoData::Parameters& in_param) = 0;
virtual void calculate(Grid2DObject& grid) = 0;
virtual double getQualityRating(const Date& i_date, const MeteoData::Parameters& in_param) = 0;
virtual void calculate(const DEMObject& dem, Grid2DObject& grid) = 0;
std::string getInfo() const;
protected:
size_t getData(const Date& i_date, const MeteoData::Parameters& i_param, std::vector<double>& o_vecData);
......@@ -152,13 +152,10 @@ class InterpolationAlgorithm {
size_t getStationAltitudes(const std::vector<StationData>& i_vecMeta, std::vector<double>& o_vecData) const;
void getTrend(const std::vector<double>& vecAltitudes, const std::vector<double>& vecDat, Fit1D &trend) const;
void detrend(const Fit1D& trend, const std::vector<double>& vecAltitudes, std::vector<double> &vecDat) const;
void retrend(const Fit1D& trend, Grid2DObject &grid) const;
void retrend(const DEMObject& dem, const Fit1D& trend, Grid2DObject &grid) const;
Meteo2DInterpolator& mi;
/*const Date& date;
const DEMObject& dem;*/ //HACK
Date date;
DEMObject dem;
const std::vector<std::string> vecArgs; //we must keep our own copy, it is different for each algorithm!
const std::string algo;
IOManager& iomanager;
......@@ -190,8 +187,8 @@ class ConstAlgorithm : public InterpolationAlgorithm {
const std::vector<std::string>& i_vecArgs,
const std::string& i_algo, IOManager& iom)
: InterpolationAlgorithm(i_mi, i_vecArgs, i_algo, iom) {}
virtual double getQualityRating(const DEMObject& i_dem, const Date& i_date, const MeteoData::Parameters& in_param);
virtual void calculate(Grid2DObject& grid);
virtual double getQualityRating(const Date& i_date, const MeteoData::Parameters& in_param);
virtual void calculate(const DEMObject& dem, Grid2DObject& grid);
};
/**
......@@ -205,8 +202,8 @@ class StandardPressureAlgorithm : public InterpolationAlgorithm {
const std::vector<std::string>& i_vecArgs,
const std::string& i_algo, IOManager& iom)
: InterpolationAlgorithm(i_mi, i_vecArgs, i_algo, iom) {}
virtual double getQualityRating(const DEMObject& i_dem, const Date& i_date, const MeteoData::Parameters& in_param);
virtual void calculate(Grid2DObject& grid);
virtual double getQualityRating(const Date& i_date, const MeteoData::Parameters& in_param);
virtual void calculate(const DEMObject& dem, Grid2DObject& grid);
};
/**
......@@ -227,8 +224,8 @@ class ConstLapseRateAlgorithm : public InterpolationAlgorithm {
const std::vector<std::string>& i_vecArgs,
const std::string& i_algo, IOManager& iom)
: InterpolationAlgorithm(i_mi, i_vecArgs, i_algo, iom) {}
virtual double getQualityRating(const DEMObject& i_dem, const Date& i_date, const MeteoData::Parameters& in_param);
virtual void calculate(Grid2DObject& grid);
virtual double getQualityRating(const Date& i_date, const MeteoData::Parameters& in_param);
virtual void calculate(const DEMObject& dem, Grid2DObject& grid);
};
/**
......@@ -244,8 +241,8 @@ class IDWAlgorithm : public InterpolationAlgorithm {
const std::vector<std::string>& i_vecArgs,
const std::string& i_algo, IOManager& iom)
: InterpolationAlgorithm(i_mi, i_vecArgs, i_algo, iom) {}
virtual double getQualityRating(const DEMObject& i_dem, const Date& i_date, const MeteoData::Parameters& in_param);
virtual void calculate(Grid2DObject& grid);
virtual double getQualityRating(const Date& i_date, const MeteoData::Parameters& in_param);
virtual void calculate(const DEMObject& dem, Grid2DObject& grid);
};
/**
......@@ -268,8 +265,8 @@ class IDWLapseAlgorithm : public InterpolationAlgorithm {
const std::vector<std::string>& i_vecArgs,
const std::string& i_algo, IOManager& iom)
: InterpolationAlgorithm(i_mi, i_vecArgs, i_algo, iom) {}
virtual double getQualityRating(const DEMObject& i_dem, const Date& i_date, const MeteoData::Parameters& in_param);
virtual void calculate(Grid2DObject& grid);
virtual double getQualityRating(const Date& i_date, const MeteoData::Parameters& in_param);
virtual void calculate(const DEMObject& dem, Grid2DObject& grid);
};
......@@ -287,8 +284,8 @@ class LocalIDWLapseAlgorithm : public InterpolationAlgorithm {
const std::vector<std::string>& i_vecArgs,
const std::string& i_algo, IOManager& iom)
: InterpolationAlgorithm(i_mi, i_vecArgs, i_algo, iom) {}
virtual double getQualityRating(const DEMObject& i_dem, const Date& i_date, const MeteoData::Parameters& in_param);
virtual void calculate(Grid2DObject& grid);
virtual double getQualityRating(const Date& i_date, const MeteoData::Parameters& in_param);
virtual void calculate(const DEMObject& dem, Grid2DObject& grid);
};
/**
......@@ -307,8 +304,8 @@ class RHAlgorithm : public InterpolationAlgorithm {
const std::vector<std::string>& i_vecArgs,
const std::string& i_algo, IOManager& iom)
: InterpolationAlgorithm(i_mi, i_vecArgs, i_algo, iom), vecDataTA(), vecDataRH() {}
virtual double getQualityRating(const DEMObject& i_dem, const Date& i_date, const MeteoData::Parameters& in_param);
virtual void calculate(Grid2DObject& grid);
virtual double getQualityRating(const Date& i_date, const MeteoData::Parameters& in_param);
virtual void calculate(const DEMObject& dem, Grid2DObject& grid);
private:
std::vector<double> vecDataTA, vecDataRH; ///<vectors of extracted TA and RH
};
......@@ -328,8 +325,8 @@ class ILWRAlgorithm : public InterpolationAlgorithm {
const std::vector<std::string>& i_vecArgs,
const std::string& i_algo, IOManager& iom)
: InterpolationAlgorithm(i_mi, i_vecArgs, i_algo, iom), vecDataEA() {}
virtual double getQualityRating(const DEMObject& i_dem, const Date& i_date, const MeteoData::Parameters& in_param);
virtual void calculate(Grid2DObject& grid);
virtual double getQualityRating(const Date& i_date, const MeteoData::Parameters& in_param);
virtual void calculate(const DEMObject& dem, Grid2DObject& grid);
private:
std::vector<double> vecDataEA; ///<vectors of extracted emissivities
};
......@@ -349,8 +346,8 @@ class SimpleWindInterpolationAlgorithm : public InterpolationAlgorithm {
const std::vector<std::string>& i_vecArgs,
const std::string& i_algo, IOManager& iom)
: InterpolationAlgorithm(i_mi, i_vecArgs, i_algo, iom), vecDataVW(), vecDataDW() {}
virtual double getQualityRating(const DEMObject& i_dem, const Date& i_date, const MeteoData::Parameters& in_param);
virtual void calculate(Grid2DObject& grid);
virtual double getQualityRating(const Date& i_date, const MeteoData::Parameters& in_param);
virtual void calculate(const DEMObject& dem, Grid2DObject& grid);
private:
std::vector<double> vecDataVW, vecDataDW; ///<vectors of extracted VW and DW
};
......@@ -376,8 +373,8 @@ class USERInterpolation : public InterpolationAlgorithm {
const std::vector<std::string>& i_vecArgs,
const std::string& i_algo, IOManager& iom)
: InterpolationAlgorithm(i_mi, i_vecArgs, i_algo, iom) {}
virtual double getQualityRating(const DEMObject& i_dem, const Date& i_date, const MeteoData::Parameters& in_param);
virtual void calculate(Grid2DObject& grid);
virtual double getQualityRating(const Date& i_date, const MeteoData::Parameters& in_param);
virtual void calculate(const DEMObject& dem, Grid2DObject& grid);
private:
std::string getGridFileName() const;
};
......@@ -409,8 +406,8 @@ class SnowHNWInterpolation : public InterpolationAlgorithm {
const std::vector<std::string>& i_vecArgs,
const std::string& i_algo, IOManager& iom)
: InterpolationAlgorithm(i_mi, i_vecArgs, i_algo, iom) {}
virtual double getQualityRating(const DEMObject& i_dem, const Date& i_date, const MeteoData::Parameters& in_param);
virtual void calculate(Grid2DObject& grid);
virtual double getQualityRating(const Date& i_date, const MeteoData::Parameters& in_param);
virtual void calculate(const DEMObject& dem, Grid2DObject& grid);
};
/**
......@@ -441,8 +438,8 @@ class OrdinaryKrigingAlgorithm : public InterpolationAlgorithm {
const std::vector<std::string>& i_vecArgs,
const std::string& i_algo, IOManager& iom)
: InterpolationAlgorithm(i_mi, i_vecArgs, i_algo, iom), variogram() {}
virtual double getQualityRating(const DEMObject& i_dem, const Date& i_date, const MeteoData::Parameters& in_param);
virtual void calculate(Grid2DObject& grid);
virtual double getQualityRating(const Date& i_date, const MeteoData::Parameters& in_param);
virtual void calculate(const DEMObject& dem, Grid2DObject& grid);
protected:
void getDataForVariogram(std::vector<double> &distData, std::vector<double> &variData);
bool computeVariogram();
......@@ -467,7 +464,7 @@ class LapseOrdinaryKrigingAlgorithm : public OrdinaryKrigingAlgorithm {
const std::vector<std::string>& i_vecArgs,
const std::string& i_algo, IOManager& iom)
: OrdinaryKrigingAlgorithm(i_mi, i_vecArgs, i_algo, iom) {}
virtual void calculate(Grid2DObject& grid);
virtual void calculate(const DEMObject& dem, Grid2DObject& grid);
};
} //end namespace mio
......
......@@ -138,7 +138,7 @@ void Meteo2DInterpolator::interpolate(const Date& date, const DEMObject& dem, co
//Get the configured algorithm
auto_ptr<InterpolationAlgorithm> algorithm(AlgorithmFactory::getAlgorithm(algoname, *this, vecArgs, *iomanager));
//Get the quality rating and compare to previously computed quality ratings
const double rating = algorithm->getQualityRating(dem, date, meteoparam);
const double rating = algorithm->getQualityRating(date, meteoparam);
if ((rating != 0.0) && (rating > maxQualityRating)) {
//we use ">" so that in case of equality, the first choice will be kept
bestalgorithm = algorithm; //remember this algorithm: ownership belongs to bestalgorithm
......@@ -150,7 +150,7 @@ void Meteo2DInterpolator::interpolate(const Date& date, const DEMObject& dem, co
if (bestalgorithm.get() == NULL) {
throw IOException("No interpolation algorithm with quality rating >0 found for parameter "+MeteoData::getParameterName(meteoparam), AT);
}
bestalgorithm->calculate(result);
bestalgorithm->calculate(dem, result);