WSL/SLF GitLab Repository

Commit 6ecfe7bc authored by Mathias Bavay's avatar Mathias Bavay
Browse files

Some "TODO" have been removed, a missing check has been added in...

Some "TODO" have been removed, a missing check has been added in Interpol1D:linRegression (at least 2 valid points are required), type inconsistencies have been fixed in FilterTukey and ProcessinStack. However using size_t for the meteo parameter index is not necessarily a good idea and this will require a careful review.
parent d0607675
......@@ -91,7 +91,7 @@ double FilterTukey::getStdDev(const std::vector<MeteoData>& ivec, const unsigned
return sqrt(variance);
}
double FilterTukey::getU3(const std::vector<MeteoData>& ivec, const unsigned int& i, const unsigned int& param)
double FilterTukey::getU3(const std::vector<MeteoData>& ivec, const size_t& i, const unsigned int& param)
{
//exit if we don't have the required data points
if( i<4 || i>=(ivec.size()-4) ) {
......@@ -100,12 +100,12 @@ double FilterTukey::getU3(const std::vector<MeteoData>& ivec, const unsigned int
//prepare intermediate variances
std::vector<double> u2;
for(int ii=-1; ii<=1; ii++) {
for(char ii=-1; ii<=1; ii++) {
std::vector<double> u1;
for(int jj=-1; jj<=1; jj++) {
for(char jj=-1; jj<=1; jj++) {
std::vector<double> u;
for(int kk=-2; kk<=2; kk++) {
const size_t index = (unsigned)((signed)i + kk + jj + ii);
for(char kk=-2; kk<=2; kk++) {
const size_t index = (i + (kk + jj + ii));
const double value = ivec[index](param);
if(value!=IOUtils::nodata)
u.push_back( value );
......@@ -159,7 +159,7 @@ void FilterTukey::parse_args(std::vector<std::string> vec_args)
throw InvalidArgumentException("Invalid window size configuration for filter " + getName(), AT);
}
min_data_points = (unsigned int)floor(filter_args[0]);
min_data_points = (size_t)floor(filter_args[0]);
min_time_span = Duration(filter_args[1] / 86400.0, 0.);
}
......
......@@ -53,7 +53,7 @@ class FilterTukey : public WindowedFilter {
private:
void parse_args(std::vector<std::string> vec_args);
double getStdDev(const std::vector<MeteoData>& ivec, const unsigned int& param, const size_t& start, const size_t& end);
double getU3(const std::vector<MeteoData>& ivec, const unsigned int& i, const unsigned int& param);
double getU3(const std::vector<MeteoData>& ivec, const size_t& i, const unsigned int& param);
static const double k; ///<How many times the stddev allowed as deviation to the smooth signal for valid points
};
......
......@@ -34,7 +34,7 @@ ProcessingStack::ProcessingStack(const Config& cfg, const std::string& parname)
tmp << param_name << "::arg" << (ii+1);
getArgumentsForFilter(cfg, tmp.str(), vec_args); //Read arguments
filter_stack.push_back(BlockFactory::getBlock(block_name, vec_args));
filter_stack.push_back( BlockFactory::getBlock(block_name, vec_args) );
}
}
......@@ -102,7 +102,7 @@ void ProcessingStack::process(const std::vector< std::vector<MeteoData> >& ivec,
}
appliedFilter = true;
(*filter_stack[jj]).process(param, tmp, ovec[ii]);
(*filter_stack[jj]).process(static_cast<unsigned int>(param), tmp, ovec[ii]);
if (tmp.size() == ovec[ii].size()){
if ((jj+1) != filter_stack.size()){//after the last filter not necessary
......
......@@ -385,8 +385,8 @@ void Interpol1D::LinRegression(const std::vector<double>& X, const std::vector<d
//check arguments
const size_t n = X.size();
if(n==0)
throw NoAvailableDataException("Trying to calculate linear regression with no data points", AT);
if(n<2)
throw NoAvailableDataException("Trying to calculate linear regression with too few data points", AT);
if(n!=Y.size())
throw IOException("Vectors should have the same size for linear regression!", AT);
......@@ -400,8 +400,8 @@ void Interpol1D::LinRegression(const std::vector<double>& X, const std::vector<d
count++;
}
}
if(count==0)
throw NoAvailableDataException("Trying to calculate linear regression with no valid data points", AT);
if(count<2)
throw NoAvailableDataException("Trying to calculate linear regression with too few valid data points", AT);
x_avg /= (double)count;
y_avg /= (double)count;
......
......@@ -70,7 +70,7 @@ inline double Interpol2D::InvHorizontalDistance(const double& X1, const double&
* @return (double) distance in m
*/
inline double Interpol2D::HorizontalDistance(const DEMObject& dem, const int& i, const int& j, const double& X2, const double& Y2)
{//TODO: store DEM easting/northing, etc as private members
{
//This function computes the horizontal distance between two points
//coordinates are given in a square, metric grid system
//for grid points toward real coordinates
......
......@@ -725,7 +725,7 @@ void A3DIO::readSpecialPoints(std::vector<Coords>& pts)
}
int A3DIO::create1DFile(const std::vector< std::vector<MeteoData> >& data)
{//TODO: add check for stations' positions
{
std::string tmp_path;
cfg.getValue("METEOPATH", "Output", tmp_path);
const size_t sta_nr = data.size();
......
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