WSL/SLF GitLab Repository

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

Now the toString() method of Meteo2DInterpolator works with the new structure...

Now the toString() method of Meteo2DInterpolator works with the new structure and is called by IOManager.toString(). Small cleanup (white spaces, etc) in 2D_interpolations and ResamplingAlgorithms.
parent bc78c49e
......@@ -462,6 +462,7 @@ const std::string IOManager::toString() const {
os << bufferedio.toString();
os << meteoprocessor.toString();
os << "Processing level = " << processing_level << "\n";
os << interpolator.toString();
//display meteocache
size_t count=0;
......
......@@ -138,13 +138,15 @@ 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.), vecArgs(i_vecArgs), algo(i_algo), iomanager(iom),
param(MeteoData::firstparam), vecMeteo(), vecData(), vecMeta(), info(), nrOfMeasurments(0) {};
algo(i_algo), mi(i_mi), date(0.), vecArgs(i_vecArgs), vecMeteo(), vecData(),
vecMeta(), info(), param(MeteoData::firstparam), nrOfMeasurments(0), iomanager(iom) {};
virtual ~InterpolationAlgorithm() {};
//if anything is not ok (wrong parameter for this algo, insufficient data, etc) -> return zero
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;
const std::string algo;
protected:
size_t getData(const Date& i_date, const MeteoData::Parameters& i_param, std::vector<double>& o_vecData);
size_t getData(const Date& i_date, const MeteoData::Parameters& i_param,
......@@ -157,16 +159,14 @@ class InterpolationAlgorithm {
Meteo2DInterpolator& mi;
Date date;
const std::vector<std::string> vecArgs; //we must keep our own copy, it is different for each algorithm!
const std::string algo;
IOManager& iomanager;
MeteoData::Parameters param; ///<the parameter that we will interpolate
std::vector<MeteoData> vecMeteo;
std::vector<double> vecData; ///<store the measurement for the given parameter
std::vector<StationData> vecMeta; ///<store the station data for the given parameter
std::ostringstream info; ///<to store some extra information about the interoplation process
MeteoData::Parameters param; ///<the parameter that we will interpolate
size_t nrOfMeasurments; ///<the available number of measurements
IOManager& iomanager;
};
class AlgorithmFactory {
......
......@@ -232,12 +232,12 @@ const std::string Meteo2DInterpolator::toString() const {
os << "Config& cfg = " << hex << &cfg << dec << "\n";
os << "IOManager& iomanager = " << hex << &iomanager << dec << "\n";
os << "User list of algorithms:\n";
os << "Spatial resampling algorithms:\n";
std::map<std::string, std::vector<InterpolationAlgorithm*> >::const_iterator iter;
for (iter = mapAlgorithms.begin(); iter != mapAlgorithms.end(); ++iter) {
os << setw(10) << iter->first << " :: ";
os << setw(10) << iter->first << "::";
for(unsigned int jj=0; jj<iter->second.size(); jj++) {
//os << iter->second[jj]-> << " ";
os << iter->second[jj]->algo << " ";
}
os << "\n";
}
......
......@@ -91,7 +91,7 @@ void ResamplingAlgorithms::getNearestValidPts(const size_t& pos, const size_t& p
//make sure the search window remains window_size
const Date dateEnd = (indexP1 != IOUtils::npos)? vecM[indexP1].date+window_size : resampling_date+window_size;
for (size_t ii=pos; ii<vecM.size(); ii++) {
for (size_t ii=pos; ii<vecM.size(); ++ii) {
if (vecM[ii].date > dateEnd) break;
if (vecM[ii](paramindex) != IOUtils::nodata) {
indexP2 = ii;
......@@ -110,7 +110,7 @@ void ResamplingAlgorithms::getNearestValidPts(const size_t& pos, const size_t& p
* @return y-coordinate of desired point
*/
double ResamplingAlgorithms::linearInterpolation(const double& x1, const double& y1,
const double& x2, const double& y2, const double& x3)
const double& x2, const double& y2, const double& x)
{
if (x1 == x2)
throw IOException("Attempted division by zero", AT);
......@@ -119,7 +119,7 @@ double ResamplingAlgorithms::linearInterpolation(const double& x1, const double&
const double a = (y2 - y1) / (x2 - x1);
const double b = y2 - a*x2;
return (a*x3 + b);
return (a*x + b);
}
/**********************************************************************************
......
......@@ -100,7 +100,6 @@ int main(int /*argc*/, char** argv) {
}
}
if(!gen_ref) io.write2DGrid(param, MeteoGrids::P, d1); //trying to write one grid out
return status;
......
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