WSL/SLF GitLab Repository

Commit 5c50e114 authored by Mathias Bavay's avatar Mathias Bavay
Browse files

The popc version has been updated. It is far from perfect (lots of popc...

The popc version has been updated. It is far from perfect (lots of popc specific hacks), it lacks an IOManager parclass, but this is the minimum that we need for Alpine3D...

The ptr_to_function to ptr_to_object cast warning has been turned off (at least for gcc). This does not fix the core issue (that has to be dealt with by the future c++ standard), but at least we don't see it anymore...

parent c45a0f0d
......@@ -107,16 +107,16 @@ void BufferedIOHandler::readAssimilationData(const Date& in_date, Grid2DObject&
in_grid2Dobj = tmpgrid2D;
}
void BufferedIOHandler::readStationData(const Date& date, std::vector<StationData>& vecStation)
void BufferedIOHandler::readStationData(const Date& date, STATION_TIMESERIE& vecStation)
{
iohandler.readStationData(date, vecStation);
}
#ifdef _POPC_
void BufferedIOHandler::writeMeteoData(std::vector< std::vector<MeteoData> >& vecMeteo,
void BufferedIOHandler::writeMeteoData(std::vector< METEO_TIMESERIE >& vecMeteo,
const std::string& name)
#else
void BufferedIOHandler::writeMeteoData(const std::vector< std::vector<MeteoData> >& vecMeteo,
void BufferedIOHandler::writeMeteoData(const std::vector< METEO_TIMESERIE >& vecMeteo,
const std::string& name)
#endif
{
......@@ -161,7 +161,7 @@ double BufferedIOHandler::getAvgSamplingRate()
return IOUtils::nodata;
}
const std::vector<METEO_DATASET>& BufferedIOHandler::get_complete_buffer(Date& start, Date& end)
const std::vector< METEO_TIMESERIE >& BufferedIOHandler::get_complete_buffer(Date& start, Date& end)
{
start = buffer_start;
end = buffer_end;
......@@ -170,7 +170,7 @@ const std::vector<METEO_DATASET>& BufferedIOHandler::get_complete_buffer(Date& s
}
void BufferedIOHandler::readMeteoData(const Date& date_start, const Date& date_end,
std::vector< std::vector<MeteoData> >& vecMeteo,
std::vector< METEO_TIMESERIE >& vecMeteo,
const unsigned int& /*stationindex*/)
{
vecMeteo.clear();
......@@ -245,7 +245,7 @@ void BufferedIOHandler::readMeteoData(const Date& date_start, const Date& date_e
}
}
void BufferedIOHandler::bufferData(const Date& date_start, const Date& date_end, std::vector< std::vector<MeteoData> >& vecvecMeteo){
void BufferedIOHandler::bufferData(const Date& date_start, const Date& date_end, std::vector< METEO_TIMESERIE >& vecvecMeteo){
//TODO: implement reading data by chunks. It has to be done the same way as rebuffering
vecvecMeteo.clear(); //the plugins do it internally anyway, but this is cheap and safe...
iohandler.readMeteoData(date_start, date_end, vecvecMeteo);
......
......@@ -86,7 +86,7 @@ class BufferedIOHandler : public IOInterface {
* @param date date for which to read the metadata
* @param vecStation vector of metadata
*/
virtual void readStationData(const Date& date, std::vector<StationData>& vecStation);
virtual void readStationData(const Date& date, STATION_TIMESERIE& vecStation);
/**
* @brief Clear all buffers in BufferedIOHandler and hence force rebuffering
......@@ -99,13 +99,13 @@ class BufferedIOHandler : public IOInterface {
virtual void readLanduse(Grid2DObject& landuse_out);
virtual void readSpecialPoints(std::vector<Coords>& pts);
virtual void readMeteoData(const Date& dateStart, const Date& dateEnd,
std::vector< std::vector<MeteoData> >& vecMeteo,
std::vector< METEO_TIMESERIE >& vecMeteo,
const unsigned int& stationindex=IOUtils::npos);
#ifdef _POPC_
virtual void writeMeteoData(std::vector< std::vector<MeteoData> >& vecMeteo,
virtual void writeMeteoData(std::vector< METEO_TIMESERIE >& vecMeteo,
const std::string& name="");
#else
virtual void writeMeteoData(const std::vector< std::vector<MeteoData> >& vecMeteo,
virtual void writeMeteoData(const std::vector< METEO_TIMESERIE >& vecMeteo,
const std::string& name="");
#endif
virtual void write2DGrid(const Grid2DObject& grid_in, const std::string& options="");
......@@ -123,10 +123,10 @@ class BufferedIOHandler : public IOInterface {
friend class IOManager;
private:
const std::vector<METEO_DATASET>& get_complete_buffer(Date& start, Date& end);
const std::vector<METEO_TIMESERIE>& get_complete_buffer(Date& start, Date& end);
void setDfltBufferProperties();
void bufferData(const Date& date_start, const Date& date_end, std::vector< std::vector<MeteoData> >& vecvecMeteo);
void bufferData(const Date& date_start, const Date& date_end, std::vector< METEO_TIMESERIE >& vecvecMeteo);
IOHandler& iohandler;
const Config& cfg;
......@@ -136,7 +136,7 @@ class BufferedIOHandler : public IOInterface {
Date chunk_size; ///< How much data to read at once
unsigned int chunks; ///< How many chuncks to buffer
std::vector< std::vector<MeteoData> > vec_buffer_meteo;
std::vector< METEO_TIMESERIE > vec_buffer_meteo;
std::map<std::string, Grid2DObject> mapBufferedGrids;
};
} //end namespace
......
......@@ -45,17 +45,17 @@ SET(meteoio_sources
)
if (DEST MATCHES "par")
#set_source_files_properties(SMETIO.cc PROPERTIES COMPILE_FLAGS "-fPIC")
SET(CMAKE_CXX_SOURCE_FILE_EXTENSIONS cc;ph;)
SET(meteoio_sources
marshal_meteoio.cc
IOHandler.ph
IOManager.ph
#IOManager.ph
${meteoio_sources}
)
SET_SOURCE_FILES_PROPERTIES( ${meteoio_sources} PROPERTIES LANGUAGE CXX )
SET_SOURCE_FILES_PROPERTIES( IOHandler.ph PROPERTIES KEEP_EXTENSION TRUE)
#SET_SOURCE_FILES_PROPERTIES( IOManager.ph PROPERTIES KEEP_EXTENSION TRUE)
SET(STATICNAME ${PROJECT_NAME}_STATIC_par)
SET(STATICLIBNAME ${PROJECT_NAME}popc)
ADD_LIBRARY(${STATICNAME} STATIC ${meteoio_sources})
......
......@@ -43,15 +43,19 @@ PluginObject* DynamicLibrary::newObject(const std::string& name, const Config& c
// Get the loadObject() function. If it doesn't exist, return NULL.
#ifdef WIN32
void (*loadSym)(const std::string&, const Config&) = (void (*)(const std::string&, const Config&))GetProcAddress(_objFile, "loadObject");
const void (*loadSym)(const std::string&, const Config&) = (void (*)(const std::string&, const Config&))GetProcAddress(_objFile, "loadObject");
#else
void* loadSym = dlsym(_objFile, "loadObject");
const void* loadSym = dlsym(_objFile, "loadObject");
#endif
if(loadSym == NULL) {
return NULL;
}
//HACK: this has to stay until c++ standard handles this case...
#ifdef __GNUC__
__extension__
#endif
// Load a new instance of the requested class, and return it
void* obj = ((void* (*)(const std::string&, const Config&))(loadSym))(name, cfg);
return reinterpret_cast<PluginObject*>(obj);
......
......@@ -217,13 +217,13 @@ void IOHandler::readLanduse(Grid2DObject& landuse_out)
plugin->readLanduse(landuse_out);
}
void IOHandler::readStationData(const Date& date, STATION_DATASET& vecStation)
void IOHandler::readStationData(const Date& date, STATION_TIMESERIE& vecStation)
{
IOInterface *plugin = getPlugin("METEO", "Input");
plugin->readStationData(date, vecStation);
}
void IOHandler::readMeteoData(const Date& date, METEO_DATASET& vecMeteo)
void IOHandler::readMeteoData(const Date& date, METEO_TIMESERIE& vecMeteo)
{
vecMeteo.clear();
......@@ -245,17 +245,17 @@ void IOHandler::readMeteoData(const Date& date, METEO_DATASET& vecMeteo)
}
void IOHandler::readMeteoData(const Date& dateStart, const Date& dateEnd,
std::vector<METEO_DATASET>& vecMeteo,
std::vector<METEO_TIMESERIE>& vecMeteo,
const unsigned& stationindex)
{
IOInterface *plugin = getPlugin("METEO", "Input");
plugin->readMeteoData(dateStart, dateEnd, vecMeteo, stationindex);
}
#ifdef _POPC_
void IOHandler::writeMeteoData(std::vector<METEO_DATASET>& vecMeteo,
void IOHandler::writeMeteoData(std::vector<METEO_TIMESERIE>& vecMeteo,
const std::string& name)
#else
void IOHandler::writeMeteoData(const std::vector<METEO_DATASET>& vecMeteo,
void IOHandler::writeMeteoData(const std::vector<METEO_TIMESERIE>& vecMeteo,
const std::string& name)
#endif
{
......
......@@ -51,13 +51,13 @@ class IOHandler : public IOInterface {
virtual void readDEM(DEMObject& dem_out);
virtual void readLanduse(Grid2DObject& landuse_out);
virtual void readStationData(const Date& date,
STATION_DATASET& vecStation);
virtual void writeMeteoData(const std::vector<METEO_DATASET>& vecMeteo,
STATION_TIMESERIE& vecStation);
virtual void writeMeteoData(const std::vector<METEO_TIMESERIE>& vecMeteo,
const std::string& name="");
virtual void readMeteoData(const Date& dateStart, const Date& dateEnd,
std::vector<METEO_DATASET>& vecMeteo,
std::vector<METEO_TIMESERIE>& vecMeteo,
const unsigned& stationindex=IOUtils::npos);
void readMeteoData(const Date& date, METEO_DATASET& vecMeteo);
void readMeteoData(const Date& date, METEO_TIMESERIE& vecMeteo);
virtual void readAssimilationData(const Date&, Grid2DObject& da_out);
virtual void readSpecialPoints(std::vector<Coords>& pts);
......
......@@ -53,13 +53,13 @@ parclass IOHandler {
virtual void readDEM([out]DEMObject& dem_out);
virtual void readLanduse([out]Grid2DObject& landuse_out);
virtual void readStationData([in]const Date& date,
[proc=marshal_STATION_DATASET] STATION_DATASET& vecStation);
virtual void writeMeteoData([in,proc=marshal_vector_METEO_DATASET] std::vector<METEO_DATASET>& vecMeteo,
[proc=marshal_STATION_TIMESERIE] STATION_TIMESERIE& vecStation);
virtual void writeMeteoData([in,proc=marshal_vector_METEO_TIMESERIE] std::vector<METEO_TIMESERIE>& vecMeteo,
[in]const std::string& name="");
virtual void readMeteoData([in]const Date& dateStart, [in]const Date& dateEnd,
[proc=marshal_vector_METEO_DATASET] std::vector<METEO_DATASET>& vecMeteo,
[proc=marshal_vector_METEO_TIMESERIE] std::vector<METEO_TIMESERIE>& vecMeteo,
const unsigned& stationindex=IOUtils::npos);
void readMeteoData([in]const Date& date, [proc=marshal_METEO_DATASET] METEO_DATASET& vecMeteo);
void readMeteoData([in]const Date& date, [proc=marshal_METEO_TIMESERIE] METEO_TIMESERIE& vecMeteo);
virtual void readAssimilationData([in] const Date&,[out] Grid2DObject& da_out);
virtual void readSpecialPoints([out,proc=marshal_vec_coords]std::vector<Coords>& pts);
virtual void write2DGrid([in]const Grid2DObject& grid_in, [in]const std::string& name);
......
......@@ -15,6 +15,7 @@
You should have received a copy of the GNU Lesser General Public License
along with MeteoIO. If not, see <http://www.gnu.org/licenses/>.
*/
#include <meteoio/IOManager.h>
using namespace std;
......@@ -51,7 +52,7 @@ double IOManager::getAvgSamplingRate()
}
}
unsigned int IOManager::getStationData(const Date& date, std::vector<StationData>& vecStation)
unsigned int IOManager::getStationData(const Date& date, STATION_TIMESERIE& vecStation)
{
vecStation.clear();
......@@ -67,7 +68,7 @@ unsigned int IOManager::getStationData(const Date& date, std::vector<StationData
//for an interval of data: decide whether data should be filtered or raw
unsigned int IOManager::getMeteoData(const Date& dateStart, const Date& dateEnd,
std::vector< std::vector<MeteoData> >& vecMeteo)
std::vector< METEO_TIMESERIE >& vecMeteo)
{
vecMeteo.clear();
......@@ -104,7 +105,7 @@ void IOManager::fill_filtered_cache()
{
if ((IOManager::filtered & processing_level) == IOManager::filtered){
//ask the bufferediohandler for the whole buffer
const vector<METEO_DATASET>& buffer = bufferedio.get_complete_buffer(fcache_start, fcache_end);
const vector< METEO_TIMESERIE >& buffer = bufferedio.get_complete_buffer(fcache_start, fcache_end);
//cout << "Now filtering ..." << endl;
meteoprocessor.process(buffer, filtered_cache);
......@@ -119,7 +120,7 @@ void IOManager::fill_filtered_cache()
* @return true if the requested chunk was contained by filtered_cache, false otherwise
*/
bool IOManager::read_filtered_cache(const Date& start_date, const Date& end_date,
std::vector<METEO_DATASET>& vec_meteo)
std::vector< METEO_TIMESERIE >& vec_meteo)
{
if ((start_date >= fcache_start) && (end_date <= fcache_end)){
//it's already in the filtered_cache, so just copy the requested slice
......@@ -153,7 +154,7 @@ bool IOManager::read_filtered_cache(const Date& start_date, const Date& end_date
return false;
}
void IOManager::add_to_cache(const Date& i_date, const std::vector<MeteoData>& vecMeteo)
void IOManager::add_to_cache(const Date& i_date, const METEO_TIMESERIE& vecMeteo)
{
//Check cache size, delete oldest elements if necessary
if (resampled_cache.size() > 200){
......@@ -165,7 +166,7 @@ void IOManager::add_to_cache(const Date& i_date, const std::vector<MeteoData>& v
}
//data can be raw or processed (filtered, resampled)
unsigned int IOManager::getMeteoData(const Date& i_date, std::vector<MeteoData>& vecMeteo)
unsigned int IOManager::getMeteoData(const Date& i_date, METEO_TIMESERIE& vecMeteo)
{
vecMeteo.clear();
......@@ -212,8 +213,11 @@ unsigned int IOManager::getMeteoData(const Date& i_date, std::vector<MeteoData>&
return vecMeteo.size();
}
void IOManager::writeMeteoData(const std::vector< std::vector<MeteoData> >& vecMeteo, const std::string& name)
#ifdef _POPC_ //HACK popc
void IOManager::writeMeteoData(/*const*/ std::vector< METEO_TIMESERIE >& vecMeteo, /*const*/ std::string& name)
#else
void IOManager::writeMeteoData(const std::vector< METEO_TIMESERIE >& vecMeteo, const std::string& name)
#endif
{
if (processing_level == IOManager::raw){
rawio.writeMeteoData(vecMeteo, name);
......@@ -222,15 +226,25 @@ void IOManager::writeMeteoData(const std::vector< std::vector<MeteoData> >& vecM
}
}
#ifdef _POPC_ //HACK popc
void IOManager::interpolate(/*const*/ Date& date, /*const*/ DEMObject& dem, /*const*/ MeteoData::Parameters& meteoparam,
Grid2DObject& result)
#else
void IOManager::interpolate(const Date& date, const DEMObject& dem, const MeteoData::Parameters& meteoparam,
Grid2DObject& result)
#endif
{
string info_string;
interpolate(date, dem, meteoparam, result, info_string);
}
#ifdef _POPC_ //HACK popc
void IOManager::interpolate(/*const*/ Date& date, /*const*/ DEMObject& dem, /*const*/ MeteoData::Parameters& meteoparam,
Grid2DObject& result, std::string& info_string)
#else
void IOManager::interpolate(const Date& date, const DEMObject& dem, const MeteoData::Parameters& meteoparam,
Grid2DObject& result, std::string& info_string)
Grid2DObject& result, std::string& info_string)
#endif
{
Meteo2DInterpolator mi(cfg, *this);
mi.interpolate(date, dem, meteoparam, result, info_string);
......@@ -290,21 +304,24 @@ void IOManager::write2DGrid(const Grid2DObject& grid2D, const std::string& name)
}
}
std::ostream& operator<<(std::ostream& os, const IOManager& io)
{
std::string IOManager::toString() const {
stringstream os;
os << "<IOManager>\n";
os << "Config& cfg = " << hex << &io.cfg << dec << "\n";
os << io.rawio;
os << io.bufferedio;
os << io.meteoprocessor;
os << "Processing level = " << io.processing_level << "\n";
os << "Config& cfg = " << hex << &cfg << dec << "\n";
#ifndef _POPC_ //HACK popc
os << rawio;
#endif
os << bufferedio;
os << meteoprocessor;
os << "Processing level = " << processing_level << "\n";
//display meteocache
unsigned int count=0;
unsigned int min_stations=std::numeric_limits<unsigned int>::max();
unsigned int max_stations=-std::numeric_limits<unsigned int>::max();
std::map<Date, std::vector<MeteoData> >::const_iterator iter = io.resampled_cache.begin();
for (; iter != io.resampled_cache.end(); iter++) {
std::map<Date, std::vector<MeteoData> >::const_iterator iter = resampled_cache.begin();
for (; iter != resampled_cache.end(); iter++) {
const unsigned int nb_stations = iter->second.size();
if(nb_stations>max_stations) max_stations=nb_stations;
if(nb_stations<min_stations) min_stations=nb_stations;
......@@ -321,10 +338,10 @@ std::ostream& operator<<(std::ostream& os, const IOManager& io)
else
os << min_stations << " to " << max_stations;
os << " station(s))\n";
os << io.resampled_cache.begin()->first.toString(Date::ISO) << " - 1 timestep\n";
os << resampled_cache.begin()->first.toString(Date::ISO) << " - 1 timestep\n";
}
if(count>1) {
const double avg_sampling = ( (io.resampled_cache.rbegin()->first.getJulianDate()) - (io.resampled_cache.begin()->first.getJulianDate()) ) / (double)(count-1);
const double avg_sampling = ( (resampled_cache.rbegin()->first.getJulianDate()) - (resampled_cache.begin()->first.getJulianDate()) ) / (double)(count-1);
os << "Resampled cache content (";
if(max_stations==min_stations)
......@@ -332,24 +349,32 @@ std::ostream& operator<<(std::ostream& os, const IOManager& io)
else
os << min_stations << " to " << max_stations;
os << " station(s))\n";
os << io.resampled_cache.begin()->first.toString(Date::ISO);
os << " - " << io.resampled_cache.rbegin()->first.toString(Date::ISO);
os << resampled_cache.begin()->first.toString(Date::ISO);
os << " - " << resampled_cache.rbegin()->first.toString(Date::ISO);
os << " - " << count << " timesteps (" << setprecision(3) << fixed << avg_sampling*24.*3600. << " s sampling rate)";
}
//display filtered_cache
os << "Filteredcache content (" << io.filtered_cache.size() << " stations)\n";
for(unsigned int ii=0; ii<io.filtered_cache.size(); ii++) {
if (io.filtered_cache[ii].size() > 0){
os << std::setw(10) << io.filtered_cache[ii][0].meta.stationID << " = "
<< io.filtered_cache[ii][0].date.toString(Date::ISO) << " - "
<< io.filtered_cache[ii][io.filtered_cache[ii].size()-1].date.toString(Date::ISO) << ", "
<< io.filtered_cache[ii].size() << " timesteps" << endl;
os << "Filteredcache content (" << filtered_cache.size() << " stations)\n";
for(unsigned int ii=0; ii<filtered_cache.size(); ii++) {
if (filtered_cache[ii].size() > 0){
os << std::setw(10) << filtered_cache[ii][0].meta.stationID << " = "
<< filtered_cache[ii][0].date.toString(Date::ISO) << " - "
<< filtered_cache[ii][filtered_cache[ii].size()-1].date.toString(Date::ISO) << ", "
<< filtered_cache[ii].size() << " timesteps" << endl;
}
}
os << "</IOManager>\n";
return os.str();
}
//#ifndef _POPC_
std::ostream& operator<<(std::ostream& os, const IOManager& io)
{
os << io.toString();
return os;
}
//#endif
} //namespace
......@@ -21,6 +21,7 @@
#include <meteoio/BufferedIOHandler.h>
#include <meteoio/Meteo2DInterpolator.h>
#include <meteoio/MeteoProcessor.h>
#include <meteoio/MeteoData.h>
namespace mio {
......@@ -45,7 +46,7 @@ class IOManager {
void write2DGrid(const Grid2DObject& grid_in, const std::string& options="");
//end legacy support
unsigned int getStationData(const Date& date, std::vector<StationData>& vecStation);
unsigned int getStationData(const Date& date, STATION_TIMESERIE& vecStation);
/**
* @brief Fill vecMeteo with a time series of objects
......@@ -72,7 +73,7 @@ class IOManager {
* @return Number of stations for which data has been found in the interval
*/
unsigned int getMeteoData(const Date& dateStart, const Date& dateEnd,
std::vector< std::vector<MeteoData> >& vecMeteo);
std::vector< METEO_TIMESERIE >& vecMeteo);
/**
* @brief Fill vector<MeteoData> object with multiple instances of MeteoData
......@@ -94,13 +95,23 @@ class IOManager {
* @param vecMeteo A vector of MeteoData objects to be filled with data
* @return Number of stations for which data has been found in the interval
*/
unsigned int getMeteoData(const Date& i_date, std::vector<MeteoData>& vecMeteo);
unsigned int getMeteoData(const Date& i_date, METEO_TIMESERIE& vecMeteo);
#ifdef _POPC_ //HACK popc
void interpolate(/*const*/ Date& date, /*const*/ DEMObject& dem, /*const*/ MeteoData::Parameters& meteoparam,
Grid2DObject& result, std::string& info_string);
#else
void interpolate(const Date& date, const DEMObject& dem, const MeteoData::Parameters& meteoparam,
Grid2DObject& result, std::string& info_string);
#endif
#ifdef _POPC_ //HACK popc
void interpolate(/*const*/ Date& date, /*const*/ DEMObject& dem, /*const*/ MeteoData::Parameters& meteoparam,
Grid2DObject& result);
#else
void interpolate(const Date& date, const DEMObject& dem, const MeteoData::Parameters& meteoparam,
Grid2DObject& result);
#endif
/**
* @brief Set the desired ProcessingLevel of the IOManager instance
......@@ -118,15 +129,20 @@ class IOManager {
double getAvgSamplingRate();
void writeMeteoData(const std::vector< std::vector<MeteoData> >& vecMeteo, const std::string& name="");
#ifdef _POPC_ //HACK popc
void writeMeteoData(/*const*/ std::vector< METEO_TIMESERIE >& vecMeteo, /*const*/ std::string& name/*=""*/);
#else
void writeMeteoData(const std::vector< METEO_TIMESERIE >& vecMeteo, const std::string& name="");
#endif
std::string toString() const;
friend std::ostream& operator<<(std::ostream& os, const IOManager& io);
private:
void add_to_cache(const Date& i_date, const std::vector<MeteoData>& vecMeteo);
void add_to_cache(const Date& i_date, const METEO_TIMESERIE& vecMeteo);
void fill_filtered_cache();
bool read_filtered_cache(const Date& start_date, const Date& end_date,
std::vector<METEO_DATASET>& vec_meteo);
std::vector< METEO_TIMESERIE >& vec_meteo);
const Config& cfg;
IOHandler rawio;
......@@ -134,8 +150,8 @@ class IOManager {
MeteoProcessor meteoprocessor;
ProcessingProperties proc_properties;
std::map<Date, std::vector<MeteoData> > resampled_cache; ///< stores already resampled data points
std::vector< std::vector<MeteoData> > filtered_cache; ///< stores already filtered data intervals
std::map<Date, METEO_TIMESERIE > resampled_cache; ///< stores already resampled data points
std::vector< METEO_TIMESERIE > filtered_cache; ///< stores already filtered data intervals
Date fcache_start, fcache_end;
unsigned int processing_level;
};
......
......@@ -22,70 +22,79 @@
#include <meteoio/Meteo2DInterpolator.h>
#include <meteoio/MeteoProcessor.h>
#include <meteoio/marshal_meteoio.h>
#include <meteoio/IOPlugin.h>
using namespace mio; //HACK for POPC
namespace mio {
typedef std::map<std::string, IOPlugin::IOPlugin>::iterator PLUGIN_ITERATOR; //HACK for POPC
//This one line above does absolutely nothing, but if removed, popc does not compile the file....
/**
* @file IOManager.ph
* The is the parclass implementing the user accessible interface.
*/
parclass IOManager {
classuid(1005);
classuid(1004);
public:
enum ProcessingLevel {
raw = 1,
filtered = 1 << 1,
resampled = 1 << 2,
num_of_levels = 1 << 3
};
IOManager(const Config& i_cfg);
IOManager([in]const Config& i_cfg);
//Legacy support to support functionality of the IOInterface superclass:
void read2DGrid(Grid2DObject& grid_out, const std::string& parameter="");
void readDEM(DEMObject& dem_out);
void readAssimilationData(const Date& date_in, Grid2DObject& da_out);
void readLanduse(Grid2DObject& landuse_out);
void readSpecialPoints(std::vector<Coords>& pts);
void write2DGrid(const Grid2DObject& grid_in, const std::string& options="");
void read2DGrid([out]Grid2DObject& grid_out, [in]const std::string& parameter="");
void readDEM([out]DEMObject& dem_out);
void readAssimilationData([in]const Date& date_in, [out]Grid2DObject& da_out);
void readLanduse([out]Grid2DObject& landuse_out);
void readSpecialPoints([out]std::vector<Coords>& pts);
void write2DGrid([in]const Grid2DObject& grid_in, [in]const std::string& options="");
//end legacy support
unsigned int getStationData(const Date& date, std::vector<StationData>& vecStation);
unsigned int getStationData([in]const Date& date, [out, proc=marshal_STATION_TIMESERIE]STATION_TIMESERIE& vecStation);
unsigned int getMeteoData(const Date& dateStart, const Date& dateEnd,
std::vector< std::vector<MeteoData> >& vecMeteo);
unsigned int getMeteoData([in]const Date& dateStart, [in]const Date& dateEnd,
[out, proc=marshal_vector_METEO_TIMESERIE]std::vector< METEO_TIMESERIE >& vecMeteo);
unsigned int getMeteoData(const Date& i_date, std::vector<MeteoData>& vecMeteo);
unsigned int getMeteoData([in]const Date& i_date, [out, proc=marshal_METEO_TIMESERIE]METEO_TIMESERIE& vecMeteo);
void interpolate(const Date& date, const DEMObject& dem, const MeteoData::Parameters& meteoparam,
Grid2DObject& result, std::string& info_string);
void interpolate([in]const Date& date, [in]const DEMObject& dem, [in, proc=marshal_MeteoParameters]/*const*/ MeteoData::Parameters& meteoparam,
[out]Grid2DObject& result, [out]std::string& info_string);
void interpolate(const Date& date, const DEMObject& dem, const MeteoData::Parameters& meteoparam,
Grid2DObject& result);
void interpolate([in]const Date& date, [in]const DEMObject& dem, [in, proc=marshal_MeteoParameters]/*const*/ MeteoData::Parameters& meteoparam,
[out]Grid2DObject& result); //HACK popc
void setProcessingLevel(const unsigned int& i_level);
void setProcessingLevel([in]const unsigned int& i_level);
double getAvgSamplingRate();
void writeMeteoData(const std::vector< std::vector<MeteoData> >& vecMeteo, const std::string& name="");
void writeMeteoData([in ,proc=marshal_vector_METEO_TIMESERIE]/*const*/ std::vector< METEO_TIMESERIE >& vecMeteo, [in]const std::string& name=""); //HACK popc
std::string toString() /*const*/; //HACK popc
//friend std::ostream& operator<<(std::ostream& os, const IOManager& io);
friend std::ostream& operator<<(std::ostream& os, const IOManager& io);
/*enum ProcessingLevel { //HACK popc
raw = 1,
filtered = 1 << 1,
resampled = 1 << 2,
num_of_levels = 1 << 3
};*/
private:
void add_to_cache(const Date& i_date, const std::vector<MeteoData>& vecMeteo);
void add_to_cache(const Date& i_date, const METEO_TIMESERIE& vecMeteo);
void fill_filtered_cache();
bool read_filtered_cache(const Date& start_date, const Date& end_date,
std::vector<METEO_DATASET>& vec_meteo);
std::vector< METEO_TIMESERIE >& vec_meteo);
const Config& cfg;
//const Config& cfg; //HACK popc
Config cfg; //HACK popc
IOHandler rawio;
BufferedIOHandler bufferedio;
MeteoProcessor meteoprocessor;
ProcessingProperties proc_properties;
std::map<Date, std::vector<MeteoData> > meteo_cache;
std::vector< std::vector<MeteoData> > filtered_cache;
std::map<Date, METEO_TIMESERIE > resampled_cache; ///< stores already resampled data points
std::vector< METEO_TIMESERIE > filtered_cache; ///< stores already filtered data intervals
Date fcache_start, fcache_end;
unsigned int processing_level;
};
......
......@@ -169,7 +169,7 @@ class MeteoData {
bool resampled; ///<set this to true if MeteoData is result of resampling
};
typedef std::vector<MeteoData> METEO_DATASET; //HACK: replace by TIMESERIE