WSL/SLF GitLab Repository

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

More debugging help: the "<<" operator has been redefined for MeteoFilter,...

More debugging help: the "<<" operator has been redefined for MeteoFilter, MeteoProcessor and BufferedIOHandler. Since the Config object is copied all over the place, it is not always printed.
parent 5b5cd758
......@@ -339,4 +339,34 @@ void BufferedIOHandler::clearBuffer(){
mapBufferedGrids.clear();
}
std::ostream& operator<<(std::ostream& os, const BufferedIOHandler& data)
{
os << "<BufferedIOHandler>\n";
os << "Config cfg; (not expanded)\n";
os << data.iohandler;
os << data.meteoprocessor;
os << "Rebuffer if not found: " << data.always_rebuffer << "\n";
os << "Buffer span: -" << data.bufferbefore.getJulianDate() << " days, +" << data.bufferafter.getJulianDate() << " days\n";
os << "Current buffer content (" << data.stationBuffer.size() << " stations, " << data.mapBufferedGrids.size() << " grids):\n";
for(unsigned int i=0; i<data.stationBuffer.size(); i++) {
os << std::setw(10) << data.stationBuffer[i][0].stationID << " = ";
os << data.startDateBuffer[i].toString(Date::ISO) << " - ";
os << data.endDateBuffer[i].toString(Date::ISO) << ", ";
os << data.meteoBuffer[i].size() << " timesteps\n";
}
std::map<std::string, Grid2DObject>::const_iterator it1;
for (it1=data.mapBufferedGrids.begin(); it1 != data.mapBufferedGrids.end(); it1++){
os << setw(10) << "Grid" << " = " << it1->first << ", ";
os << (it1->second).ncols << " x " << (it1->second).nrows << " @ " << (it1->second).cellsize << "m\n";
}
os << "</BufferedIOHandler>\n";
return os;
}
} //namespace
......@@ -167,6 +167,8 @@ class BufferedIOHandler : public IOInterface {
*/
void setBufferDuration(const Date& _bufferbefore, const Date& _bufferafter);
friend std::ostream& operator<<(std::ostream& os, const BufferedIOHandler& data);
private:
bool bufferData(const Date& _date, const unsigned int& stationindex);
void bufferAllData(const Date& _date);
......
......@@ -79,10 +79,9 @@ void MeteoFilter::filterData(const std::vector<MeteoData>& vecM, const std::vect
continue;
//cout << "\tExecuting: " << tasklist[ii][jj] << endl;
FilterAlgorithms::filterProperties(tasklist[ii][jj]).filterfunc(vecM, vecS,
taskargs.at(ii).at(jj),
MeteoData::Parameters(ii),
vecWindowM, vecWindowS);
FilterAlgorithms::filterProperties(tasklist[ii][jj]).filterfunc(vecM, vecS,
taskargs.at(ii).at(jj), MeteoData::Parameters(ii),
vecWindowM, vecWindowS);
}
}
}
......@@ -114,4 +113,24 @@ unsigned int MeteoFilter::getArgumentsForFilter(const std::string& keyname, std:
return vecArguments.size();
}
std::ostream& operator<<(std::ostream& os, const MeteoFilter& data)
{
os << "<MeteoFilter>\n";
os << "Config cfg; (not expanded)\n";
for (unsigned int ii=0; ii<data.tasklist.size(); ii++){ //For all meteo parameters
os << std::setw(5) << MeteoData::getParameterName(ii) << " =\t";
for (unsigned int jj=0; jj<data.tasklist[ii].size(); jj++){ //For eack activated filter
os << "[ " << data.tasklist[ii][jj] << " ";
for(unsigned int kk=0; kk<data.taskargs.at(ii).at(jj).size(); kk++)
os << data.taskargs.at(ii).at(jj).at(kk) << " ";
os << "]\t";
}
os << "\n";
}
os << "</MeteoFilter>\n";
return os;
}
} //namespace
......@@ -70,6 +70,7 @@ class MeteoFilter {
std::vector<MeteoData>& vecWindowM, std::vector<StationData>& vecWindowS,
const bool& checkonly = false);
friend std::ostream& operator<<(std::ostream& os, const MeteoFilter& data);
private:
unsigned int getFiltersForParameter(const std::string& parname, std::vector<std::string>& vecFilters);
......
......@@ -62,4 +62,14 @@ void MeteoProcessor::processData(const Date& date, const std::vector<MeteoData>&
sd = vecWindowS[position];
}
std::ostream& operator<<(std::ostream& os, const MeteoProcessor& data)
{
os << "<MeteoProcessor>\n";
os << "Config cfg; (not expanded)\n";
os << data.mf;
os << data.mi1d;
os << "</MeteoProcessor>\n";
return os;
}
} //namespace
......@@ -50,6 +50,8 @@ class MeteoProcessor {
void processData(const Date& date, const std::vector<MeteoData>& vecM, const std::vector<StationData>& vecS,
MeteoData& md, StationData& sd);
friend std::ostream& operator<<(std::ostream& os, const MeteoProcessor& data);
private:
Config cfg;
MeteoFilter mf;
......
......@@ -329,7 +329,7 @@ double Interpol2D::IDWCore(const double& x, const double& y, const std::vector<d
/*const double weight=1./(HorizontalDistance(x, y, vecStations_in[i].position.getEasting(),
vecStations_in[i].position.getNorthing()) + 1e-6);*/
const Coords& position = vecStations_in[i].position;
const double DX=x-position.getEasting();
const double DX=x-position.getEasting(); //optimization: precompute and store in a vector?
const double DY=y-position.getNorthing();
const double weight = invSqrt( DX*DX + DY*DY + scale ); //use the optimized 1/sqrt approximation
//const double weight = weightInvDistSqrt( (DX*DX + DY*DY) );
......
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