WSL/SLF GitLab Repository

Commit 761491bb authored by Mathias Bavay's avatar Mathias Bavay
Browse files

Fixed a stupid bug in my previous commit and added the possibility to provide...

Fixed a stupid bug in my previous commit and added the possibility to provide a fallback constant when using the CST spatial interpolation:
RH::algorithms = Cst
RH::cst                = 0.3

This would behave as before, except that if no data at all would be available at a given time step, then the value 0.3 would be taken to fill the grid.
parent f5cf64d6
......@@ -819,7 +819,7 @@ double Date::parseTimeZone(const std::string& timezone_iso)
* @param fractional fractional day (ie: fractional part of a julian date)
* @return string containing a human readable time
*/
std::string printFractionalDay(const double& fractional) {
std::string Date::printFractionalDay(const double& fractional) {
const double hours=floor(fractional*24.);
const double minutes=floor((fractional*24.-hours)*60.);
const double seconds=fractional*24.*3600.-hours*3600.-minutes*60.;
......
......@@ -258,11 +258,15 @@ double ConstAlgorithm::getQualityRating(const Date& i_date, const MeteoData::Par
param = in_param;
nrOfMeasurments = getData(date, param, vecData, vecMeta);
if (nrOfMeasurments == 0){
return 0.0;
} else if (nrOfMeasurments == 1){
if (nrOfMeasurments == 0) {
if (vecArgs.size()==1) {
IOUtils::convertString(user_cst, vecArgs[0]);
user_provided = true;
return 0.01;
} else return 0.0;
} else if (nrOfMeasurments == 1) {
return 0.8;
} else if (nrOfMeasurments > 1){
} else if (nrOfMeasurments > 1) {
return 0.2;
}
......@@ -270,7 +274,10 @@ double ConstAlgorithm::getQualityRating(const Date& i_date, const MeteoData::Par
}
void ConstAlgorithm::calculate(const DEMObject& dem, Grid2DObject& grid) {
Interpol2D::constant(Interpol1D::arithmeticMean(vecData), dem, grid);
if (!user_provided)
Interpol2D::constant(Interpol1D::arithmeticMean(vecData), dem, grid);
else
Interpol2D::constant(user_cst, dem, grid);
}
......
......@@ -200,15 +200,20 @@ class NoneAlgorithm : public InterpolationAlgorithm {
* @class ConstAlgorithm
* @brief Constant filling interpolation algorithm.
* Fill the grid with the average of the inputs for this parameter.
* Optionally, it is also possible to provide the constant that should be used if no measurements
* are avaiblable.
*/
class ConstAlgorithm : public InterpolationAlgorithm {
public:
ConstAlgorithm(Meteo2DInterpolator& i_mi,
const std::vector<std::string>& i_vecArgs,
const std::string& i_algo, IOManager& iom)
: InterpolationAlgorithm(i_mi, i_vecArgs, i_algo, iom) {}
: InterpolationAlgorithm(i_mi, i_vecArgs, i_algo, iom), user_cst(0.), user_provided(false) {}
virtual double getQualityRating(const Date& i_date, const MeteoData::Parameters& in_param);
virtual void calculate(const DEMObject& dem, Grid2DObject& grid);
private:
double user_cst;
bool user_provided;
};
/**
......
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