WSL/SLF GitLab Repository

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

The documentation and examples have been updated to reflect the latest changes...

The documentation and examples have been updated to reflect the latest changes in MeteoIO (namely: the merging of MeteoData with StationData). A documentation bug has been fixed, that involved deleting the doxygen comments for the commented "clone()" method in IOInterface. Since this is not used anywhere and has been commented out for a while, this method has been fully deleted.

Meteo2DInterpolator now has its own << operator for debugging purposes.
parent b9716b30
......@@ -9,7 +9,6 @@ using namespace mio; //The MeteoIO namespace is called mio
int main(int /*argc*/, char** argv) {
Date d1;
std::vector<MeteoData> vecMeteo;
std::vector<StationData> vecStation;
//initializing the io handlers according to the config file
Config cfg("io.ini");
......@@ -23,10 +22,10 @@ int main(int /*argc*/, char** argv) {
//we assume that the time given on the command line is in TZ=+1
d1.setTimeZone(1.);
IOUtils::convertString(d1,argv[1]);
io.readMeteoData(d1, vecMeteo, vecStation);
io.readMeteoData(d1, vecMeteo);
//performing spatial interpolations
Meteo2DInterpolator mi(cfg, dem, vecMeteo, vecStation);
Meteo2DInterpolator mi(cfg, dem, vecMeteo);
Grid2DObject param;
mi.interpolate(MeteoData::RH, param);
......
......@@ -12,7 +12,6 @@ int main(int /*argc*/, char** /*argv*/) {
Date d1(2008,12,01,00,00);
Date d2(2009,01,31,23,00);
std::vector< std::vector<MeteoData> > vecMeteo;
std::vector< std::vector<StationData> > vecStation;
Config cfg("io.ini");
IOHandler raw_io(cfg);
......@@ -26,21 +25,18 @@ int main(int /*argc*/, char** /*argv*/) {
//More elaborate conversion: sample the data to a specific rate
//by looping over the time and calling readMeteoData for each timestep
std::vector<MeteoData> Meteo; //we need some intermediate storage, for storing data sets for 1 timestep
std::vector<StationData> Station;
io.readMeteoData(d1, Meteo, Station); //we need to know how many stations will be available
vecMeteo.insert(vecMeteo.begin(), Station.size(), std::vector<MeteoData>()); //allocation for the vectors
vecStation.insert(vecStation.begin(), Station.size(), std::vector<StationData>());
io.readMeteoData(d1, Meteo); //we need to know how many stations will be available
vecMeteo.insert(vecMeteo.begin(), Meteo.size(), std::vector<MeteoData>()); //allocation for the vectors
for(; d1<=d2; d1+=1./24.) { //time loop, sampling rate = 1/24 day = 1 hour
io.readMeteoData(d1, Meteo, Station); //read 1 timestep at once, forcing resampling to the timestep
for(unsigned int ii=0; ii<Station.size(); ii++) {
io.readMeteoData(d1, Meteo); //read 1 timestep at once, forcing resampling to the timestep
for(unsigned int ii=0; ii<Meteo.size(); ii++) {
vecMeteo.at(ii).push_back(Meteo[ii]); //fill the data manually into the vector of vectors
vecStation.at(ii).push_back(Station[ii]);
}
}
//In both case, we write the data out
std::cout << "Writing output data" << std::endl;
io.writeMeteoData(vecMeteo, vecStation);
io.writeMeteoData(vecMeteo);
std::cout << "Done!!" << std::endl;
return 0;
......
......@@ -9,7 +9,6 @@ using namespace mio; //The MeteoIO namespace is called mio
int main(int /*argc*/, char** argv) {
Date d1;
std::vector<MeteoData> vecMeteo;
std::vector<StationData> vecStation;
Config cfg("io.ini");
IOHandler raw_io(cfg);
......@@ -18,12 +17,11 @@ int main(int /*argc*/, char** argv) {
//we assume that the time given on the command line is in TZ=+1
d1.setTimeZone(1.);
IOUtils::convertString(d1,argv[1]);
io.readMeteoData(d1, vecMeteo, vecStation);
io.readMeteoData(d1, vecMeteo);
//writing some data out in order to prove that it really worked!
for (unsigned int ii=0; ii < vecMeteo.size(); ii++) {
std::cout << "---------- Station: " << (ii+1) << " / " << vecStation.size() << std::endl;
std::cout << vecStation[ii] << std::endl;
std::cout << "---------- Station: " << (ii+1) << " / " << vecMeteo.size() << std::endl;
std::cout << vecMeteo[ii] << std::endl;
}
......
......@@ -33,10 +33,6 @@ namespace mio {
class A3DIO : public IOInterface {
public:
//virtual A3DIO* clone() const;
//A3DIO(void (*delObj)(void*), const std::string& filename);
A3DIO(const std::string& configfile);
A3DIO(const A3DIO&);
A3DIO(const Config&);
......
......@@ -93,19 +93,6 @@ class IOInterface : public PluginObject {
IOInterface(void (*delObj)(void*));
virtual ~IOInterface();
/**
* @brief A virtual copy constructor used for cloning objects
*
* Example Usage:
* @code
* IOInterface *io1,*io2;
* io1 = new IOHandler("io.ini");
* io2 = io1->clone();
* @endcode
* @return A pointer to the cloned object.
*/
//virtual IOInterface* clone() const = 0;
/**
* @brief A generic function for parsing 2D grids into a Grid2DObject. The string parameter shall be used for addressing the
* specific 2D grid to be parsed into the Grid2DObject.
......@@ -168,11 +155,10 @@ class IOInterface : public PluginObject {
* Example Usage:
* @code
* vector< vector<MeteoData> > vecMeteo; //empty vector
* vector< vector<StationData> > vecStation; //empty vector
* Date d1(2008,06,21,11,00); //21.6.2008 11:00
* Date d2(2008,07,21,11,00); //21.7.2008 11:00
* IOHandler io1("io.ini");
* io1.readMeteoData(d1, d2, vecMeteo, vecStation);
* io1.readMeteoData(d1, d2, vecMeteo);
* @endcode
* @param dateStart A Date object representing the beginning of an interval (inclusive)
* @param dateEnd A Date object representing the end of an interval (inclusive)
......@@ -196,12 +182,11 @@ class IOInterface : public PluginObject {
* An example implementation (reading and writing):
* @code
* vector< vector<MeteoData> > vecMeteo; //empty vector
* vector< vector<StationData> > vecStation; //empty vector
* Date d1(2008,06,21,11,00); //21.6.2008 11:00
* Date d2(2008,07,21,11,00); //21.7.2008 11:00
* IOHandler io1("io.ini");
* io1.readMeteoData(d1, d2, vecMeteo, vecStation);
* io1.writeMeteoData(vecMeteo, vecStation)
* io1.readMeteoData(d1, d2, vecMeteo);
* io1.writeMeteoData(vecMeteo)
* @endcode
* @param vecMeteo A vector of vector<MeteoData> objects to be filled with data
* @param name (optional string) Identifier usefull for the output plugin (it could become part
......
......@@ -295,7 +295,6 @@ namespace mio {
* //provide date as ISO formatted, for example 2008-12-01T15:35:00
* Date d1;
* std::vector<mio::MeteoData> vecMeteo;
* std::vector<mio::StationData> vecStation;
*
* mio::IOHandler *raw_io = NULL;
* mio::BufferedIOHandler *io = NULL;
......@@ -310,15 +309,14 @@ namespace mio {
*
* try {
* mio::convertString(d1,argv[1]);
* io->readMeteoData(d1, vecMeteo, vecStation);
* io->readMeteoData(d1, vecMeteo);
* } catch (IOException& e){
* std::cout << "Problem when reading data, cause: " << e.what() << std::endl;
* }
*
* //writing some data out in order to prove that it really worked!
* for (unsigned int ii=0; ii < vecMeteo.size(); ii++) {
* std::cout << "---------- Station: " << (ii+1) << " / " << vecStation.size() << std::endl;
* std::cout << vecStation[ii] << std::endl;
* std::cout << "---------- Station: " << (ii+1) << " / " << vecMeteo.size() << std::endl;
* std::cout << vecMeteo[ii] << std::endl;
* }
*
......@@ -363,11 +361,10 @@ namespace mio {
*
* The next example shows how to compute and output spatial interpolations using previously read meteorological data and DEM.
* \code
* void spatial_interpolations(mio::IOHandler& io, mio::DEMObject& dem, std::vector<mio::MeteoData>& vecMeteo,
* std::vector<mio::StationData>& vecStation);
* void spatial_interpolations(mio::IOHandler& io, mio::DEMObject& dem, std::vector<mio::MeteoData>& vecMeteo);
* {
* mio::Grid2DObject ta;
* mio::Meteo2DInterpolator mi(dem, vecMeteo, vecStation);
* mio::Meteo2DInterpolator mi(dem, vecMeteo);
*
* mi.interpolate(mio::MeteoData::TA, ta);
*
......
......@@ -23,8 +23,8 @@ using namespace std;
namespace mio {
Meteo2DInterpolator::Meteo2DInterpolator(const Config& i_cfg, const DEMObject& i_dem,
const std::vector<MeteoData>& i_vecMeteo)
: cfg(i_cfg), dem(i_dem), vecMeteo(i_vecMeteo)
const std::vector<MeteoData>& i_vecMeteo)
: cfg(i_cfg), dem(i_dem), vecMeteo(i_vecMeteo)
{
/*
* By reading the Config object build up a list of user configured algorithms
......@@ -174,28 +174,50 @@ void Meteo2DInterpolator::checkMinMax(const double& minval, const double& maxval
}
}
std::ostream& operator<<(std::ostream &os, const Meteo2DInterpolator &mi) {
os << "<Meteo2DInterpolator>\n";
os << "Config *cfg = " << hex << &mi.cfg << "\n";
os << "DemObject *dem= " << hex << &mi.dem << "\n";
const unsigned int nb_stations = mi.vecMeteo.size();
os << "Current vecMeteo content : " << nb_stations << " stations";
if(nb_stations>0) os << " at " << mi.vecMeteo[0].date.toString(Date::ISO);
os << " \n";
os << "User list of algorithms:\n";
std::map<std::string, std::vector<std::string> >::const_iterator iter = mi.mapAlgorithms.begin();
for (; iter != mi.mapAlgorithms.end(); iter++) {
os << setw(10) << iter->first << " :: ";
for(unsigned int jj=0; jj<iter->second.size(); jj++) {
os << iter->second[jj] << " ";
}
os << "\n";
}
os << "</Meteo2DInterpolator>\n";
return os;
}
#ifdef _POPC_
#include "marshal_meteoio.h"
void Meteo2DInterpolator::Serialize(POPBuffer &buf, bool pack)
{
//TODO: check this serialization!! It seems dubious that it would work at all...
if (pack)
//TODO: check this serialization!!
/*if (pack)
{
/*buf.Pack(*cfg,1);
buf.Pack(*dem,1);
buf.Pack(cfg,1); //Pbl: cfg is a reference...
buf.Pack(dem,1);
marshal_METEO_DATASET(buf, vecMeteo, 0, FLAG_MARSHAL, NULL);
marshal_STATION_DATASET(buf, vecStation, 0, FLAG_MARSHAL, NULL);
marshal_map_str_vecstr(buf, mapAlgorithms, 0, FLAG_MARSHAL, NULL);*/
marshal_map_str_vecstr(buf, mapAlgorithms, 0, FLAG_MARSHAL, NULL);
}
else
{
/*buf.UnPack(*cfg,1);
buf.UnPack(*dem,1);
buf.UnPack(cfg,1);
buf.UnPack(dem,1);
marshal_METEO_DATASET(buf, vecMeteo, 0, !FLAG_MARSHAL, NULL);
marshal_STATION_DATASET(buf, vecStation, 0, !FLAG_MARSHAL, NULL);
marshal_map_str_vecstr(buf, mapAlgorithms, 0, !FLAG_MARSHAL, NULL);*/
}
marshal_map_str_vecstr(buf, mapAlgorithms, 0, !FLAG_MARSHAL, NULL);
}*/
}
#endif
......
......@@ -141,6 +141,9 @@ class Meteo2DInterpolator {
unsigned int getArgumentsForAlgorithm(const MeteoData::Parameters& param,
const std::string& algorithm,
std::vector<std::string>& vecArgs) const;
friend std::ostream& operator<<(std::ostream& os, const Meteo2DInterpolator& mi);
private:
const Config& cfg; ///< Reference to Config object, initialized during construction
const DEMObject& dem; ///< Reference to DEMObject object, initialized during construction
......
......@@ -73,9 +73,6 @@ void BormaIO::cleanup() throw()
}
}
//Clone function
//BormaIO* BormaIO::clone() const { return new BormaIO(*this); }
void BormaIO::read2DGrid(Grid2DObject&, const std::string& filename)
{
//Nothing so far
......
......@@ -35,8 +35,6 @@ namespace mio {
*/
class GeotopIO : public IOInterface {
public:
//virtual GeotopIO* clone() const;
GeotopIO(void (*delObj)(void*), const Config& i_cfg);
GeotopIO(const std::string& configfile);
......
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