WSL/SLF GitLab Repository

Commit 8d695069 authored by Mathias Bavay's avatar Mathias Bavay
Browse files

More includes cleanup and code cleanup in the plugins (getting rid of the...

More includes cleanup and code cleanup in the plugins (getting rid of the "stationindex" thing that was pretty much deprecated in all plugins)
parent eb3f8a06
......@@ -161,10 +161,4 @@ class MIO_API NoDataException : public IOException
};
} //end namespace
// Define DEBUG an empty function for seq compilation
#ifndef DEBUG
#define DEBUG printdebug
inline void printdebug(...) {}
#endif
#endif
......@@ -21,6 +21,8 @@
#include <meteoio/IOHandler.h>
#include <meteoio/dataClasses/MeteoData.h> //needed for the merge strategies
#include <algorithm>
#cmakedefine PLUGIN_ALPUG
#cmakedefine PLUGIN_ARCIO
#cmakedefine PLUGIN_A3DIO
......@@ -434,11 +436,10 @@ void IOHandler::readStationData(const Date& date, STATIONS_SET& vecStation)
}
void IOHandler::readMeteoData(const Date& dateStart, const Date& dateEnd,
std::vector<METEO_SET>& vecMeteo,
const size_t& stationindex)
std::vector<METEO_SET>& vecMeteo)
{
IOInterface *plugin = getPlugin("METEO", "Input");
plugin->readMeteoData(dateStart, dateEnd, vecMeteo, stationindex);
plugin->readMeteoData(dateStart, dateEnd, vecMeteo);
checkTimestamps(vecMeteo);
......
......@@ -57,8 +57,7 @@ class IOHandler : public IOInterface {
virtual void writeMeteoData(const std::vector<METEO_SET>& vecMeteo,
const std::string& name="");
virtual void readMeteoData(const Date& dateStart, const Date& dateEnd,
std::vector<METEO_SET>& vecMeteo,
const size_t& stationindex=IOUtils::npos);
std::vector<METEO_SET>& vecMeteo);
virtual void readAssimilationData(const Date&, Grid2DObject& da_out);
virtual void readPOI(std::vector<Coords>& pts);
......
......@@ -102,8 +102,7 @@ void IOInterface::readStationData(const Date& /*date*/, std::vector<StationData>
}
void IOInterface::readMeteoData(const Date& /*dateStart*/, const Date& /*dateEnd*/,
std::vector< std::vector<MeteoData> >& /*vecMeteo*/,
const size_t& /*stationindex=IOUtils::npos*/)
std::vector< std::vector<MeteoData> >& /*vecMeteo*/)
{
throw IOException("Nothing implemented here", AT);
}
......
......@@ -18,7 +18,8 @@
#ifndef IOINTERFACE_H
#define IOINTERFACE_H
#include <meteoio/dataClasses/Array1D.h>
#include <meteoio/Config.h> //so the plugins can get access to Config for their constructor
#include <meteoio/dataClasses/Coords.h>
#include <meteoio/dataClasses/Array2D.h>
#include <meteoio/dataClasses/Date.h>
#include <meteoio/dataClasses/DEMObject.h>
......@@ -142,11 +143,9 @@ class IOInterface {
* @param dateStart A Date object representing the beginning of an interval (inclusive)
* @param dateEnd A Date object representing the end of an interval (inclusive)
* @param vecMeteo A vector of vector<MeteoData> objects to be filled with data
* @param stationindex (optional) update only the station given by this index
*/
virtual void readMeteoData(const Date& dateStart, const Date& dateEnd,
std::vector< std::vector<MeteoData> >& vecMeteo,
const size_t& stationindex=IOUtils::npos);
std::vector< std::vector<MeteoData> >& vecMeteo);
/**
* @brief Write vecMeteo time series to a certain destination
......
......@@ -15,15 +15,17 @@
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 <cmath>
#include <cstdio>
#include <iomanip>
#include <meteoio/dataClasses/Coords.h>
#include <meteoio/dataClasses/CoordsAlgorithms.h>
#include <meteoio/IOUtils.h>
#include <meteoio/IOExceptions.h>
#include <meteoio/MathOptim.h>
#include <meteoio/meteoLaws/Meteoconst.h> //for math constants
#include <cmath>
#include <cstdio>
#include <iomanip>
#ifdef PROJ4
#include <proj_api.h>
#endif
......
......@@ -18,14 +18,10 @@
#ifndef COORDS_H
#define COORDS_H
#include <meteoio/IOUtils.h>
#include <meteoio/IOExceptions.h>
#include <string>
#include <iostream>
namespace mio {
/**
* @page dev_coords Coordinate systems support developement guide
* Geographic coordinates are transparently supported (ie converted to/from lat/lon as well as between cartesian coordinate systems) through
......
......@@ -16,6 +16,8 @@
along with MeteoIO. If not, see <http://www.gnu.org/licenses/>.
*/
#include <meteoio/plugins/A3DIO.h>
#include <meteoio/IOExceptions.h>
#include <meteoio/IOUtils.h>
using namespace std;
......@@ -110,8 +112,7 @@ void A3DIO::readStationData(const Date& timestamp, std::vector<StationData>& vec
}
void A3DIO::readMeteoData(const Date& dateStart, const Date& dateEnd,
std::vector< std::vector<MeteoData> >& vecMeteo,
const size_t& /*stationindex*/)
std::vector< std::vector<MeteoData> >& vecMeteo)
{
//if dateStart and dateEnd are the same: return exact match for date
//if dateStart > dateEnd: return first data set with date > dateStart
......
......@@ -20,11 +20,6 @@
#include <meteoio/IOInterface.h>
#include <meteoio/dataClasses/Coords.h>
#include <meteoio/Config.h>
#include <meteoio/IOExceptions.h>
#include <meteoio/IOUtils.h>
#include <string>
#include <vector>
#include <map>
......@@ -43,8 +38,7 @@ class A3DIO : public IOInterface {
virtual void readStationData(const Date& date, std::vector<StationData>& vecStation);
virtual void readMeteoData(const Date& dateStart, const Date& dateEnd,
std::vector< std::vector<MeteoData> >& vecMeteo,
const size_t& stationindex=IOUtils::npos);
std::vector< std::vector<MeteoData> >& vecMeteo);
virtual void writeMeteoData(const std::vector< std::vector<MeteoData> >& vecMeteo,
const std::string& name="");
......
......@@ -15,8 +15,8 @@
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 "ALPUG.h"
#include "libsmet.h"
#include <meteoio/plugins/ALPUG.h>
#include <meteoio/plugins/libsmet.h>
#include <meteoio/meteoLaws/Meteoconst.h>
#include <errno.h>
......@@ -112,7 +112,7 @@ void ALPUG::parseInputOutputSection()
readMetaData();
cfg.getValue("WRAP_MONTH", "Input", wrap_month, IOUtils::nothrow);
const string fields = cfg.get("ALPUG_FIELDS", "Input");
const std::string fields = cfg.get("ALPUG_FIELDS", "Input");
IOUtils::readLineToVec(fields, vecFields, ',');
if (vecFields.empty())
throw InvalidArgumentException("Please provide a comma delimited list of fields!", AT);
......@@ -132,8 +132,8 @@ void ALPUG::readMetaData()
vecMeta.resize( nr_ids );
vector<bool> foundID(nr_ids, false);
const string filename = cfg.get("METAFILE", "Input");
const string metafile = inpath + "/" + filename;
const std::string filename = cfg.get("METAFILE", "Input");
const std::string metafile( inpath + "/" + filename );
if (!FileUtils::fileExists(metafile)) throw AccessException(metafile, AT); //prevent invalid filenames
errno = 0;
std::ifstream fin(metafile.c_str(), std::ifstream::in);
......@@ -166,14 +166,14 @@ void ALPUG::readMetaData()
throw InvalidFormatException(ss.str(), AT);
}
const string line_id = vecLine[0];
const std::string line_id( vecLine[0] );
for (size_t ii=0; ii<nr_ids; ++ii) {
if (line_id==vecIDs[ii]) { //station ID found in the input list
if (foundID[ii])
throw InvalidFormatException("Error: station "+line_id+" appears multiple times in metafile \'"+metafile+"\'", AT);
vector<double> tmpdata = vector<double>(vecLine.size());
std::vector<double> tmpdata( vecLine.size() );
for (size_t jj=2; jj<5; jj++) {
if (!IOUtils::convertString(tmpdata[jj], vecLine[jj], std::dec))
throw ConversionFailedException("While reading meta data for station " + vecLine[0], AT);
......@@ -192,7 +192,7 @@ void ALPUG::readMetaData()
throw;
}
string msg;
std::string msg;
for (size_t ii=0; ii<nr_ids; ++ii) {
if (!foundID[ii]) {
if (msg.empty())
......@@ -233,13 +233,13 @@ bool ALPUG::parseLine(const std::string& filename, const size_t& nr_of_data_fiel
md.reset();
isValid = false;
vector<string> tmp_vec;
std::vector<std::string> tmp_vec;
if (IOUtils::readLineToVec(line, tmp_vec, ',') == nr_of_data_fields){
for (size_t ii=0; ii<nr_of_data_fields; ++ii) {
const string field = vecFields[ii];
const std::string field( vecFields[ii] );
if (field=="%" || field=="ID") continue;
if (field=="TIMESTAMP") {
Date date = parseDINDate(tmp_vec[ii]);
Date date( parseDINDate(tmp_vec[ii]) );
if (date.isUndef())
throw InvalidFormatException("Invalid date \'"+tmp_vec[ii]+"\' in file \'"+filename+"\'", AT);
......@@ -295,9 +295,9 @@ void ALPUG::readMetoFile(const size_t& station_index, const Date& dateStart, con
if (start_month>=wrap_month) start_year++;
if (end_month>=wrap_month) end_year++;
const string station_id = vecIDs[station_index];
const std::string station_id( vecIDs[station_index] );
Date prev_date(0., 0.);
list<string> dirlist = FileUtils::readDirectory( inpath, station_id+dflt_extension );
std::list<std::string> dirlist( FileUtils::readDirectory( inpath, station_id+dflt_extension ) );
if (dirlist.empty()) {
const std::string msg = "No data file found for station "+station_id+" in \'"+inpath+"\'"+". Files should be named as {YY}{station_id}"+dflt_extension+" with {YY} the last two digits of the year.";
throw NoDataException(msg, AT);
......@@ -306,11 +306,11 @@ void ALPUG::readMetoFile(const size_t& station_index, const Date& dateStart, con
for (int year=start_year; year<=end_year; ++year) {
stringstream ss;
ss << year;
const string filename = ss.str().substr(2,2) + station_id + dflt_extension;
const std::string filename( ss.str().substr(2,2) + station_id + dflt_extension );
if (std::find(dirlist.begin(), dirlist.end(), filename) == dirlist.end()) //this file does not exist
continue;
const string file_and_path = inpath + "/" + filename;
const std::string file_and_path( inpath + "/" + filename );
if (!FileUtils::fileExists(file_and_path)) throw AccessException(file_and_path, AT); //prevent invalid filenames
errno = 0;
std::ifstream fin(file_and_path.c_str(), ios::in|ios::binary); //ascii does end of line translation, which messes up the pointer code
......@@ -328,7 +328,6 @@ void ALPUG::readMetoFile(const size_t& station_index, const Date& dateStart, con
if (line.empty()) continue; //Pure comment lines and empty lines are ignored
//if (isDuplicate(line)) continue;
Coords pos;
MeteoData md(Date(), vecMeta[station_index]);
bool isValid;
if (!parseLine(file_and_path, nr_of_data_fields, dateStart, dateEnd, line, md, isValid))
......@@ -351,8 +350,7 @@ void ALPUG::readMetoFile(const size_t& station_index, const Date& dateStart, con
}
void ALPUG::readMeteoData(const Date& dateStart, const Date& dateEnd,
std::vector< std::vector<MeteoData> >& vecMeteo,
const size_t&)
std::vector< std::vector<MeteoData> >& vecMeteo)
{
vecMeteo.clear();
for (size_t ii=0; ii<vecIDs.size(); ++ii) {
......
......@@ -19,7 +19,6 @@
#define ALPUG_H
#include <meteoio/IOInterface.h>
#include <meteoio/Config.h>
#include <string>
#include <deque>
......@@ -43,8 +42,7 @@ class ALPUG : public IOInterface {
virtual void readStationData(const Date& date, std::vector<StationData>& vecStation);
virtual void readMeteoData(const Date& dateStart, const Date& dateEnd,
std::vector< std::vector<MeteoData> >& vecMeteo,
const size_t& stationindex=IOUtils::npos);
std::vector< std::vector<MeteoData> >& vecMeteo);
private:
void parseInputOutputSection();
......
......@@ -15,7 +15,10 @@
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 "ARCIO.h"
#include <meteoio/plugins/ARCIO.h>
#include <meteoio/IOUtils.h>
#include <meteoio/IOExceptions.h>
#include <errno.h>
#include <string.h>
#include <algorithm>
......
......@@ -18,11 +18,7 @@
#ifndef ARCIO_H
#define ARCIO_H
#include <meteoio/Config.h>
#include <meteoio/IOInterface.h>
#include <meteoio/IOUtils.h>
#include <meteoio/dataClasses/Coords.h>
#include <meteoio/IOExceptions.h>
#include <string>
......
......@@ -15,14 +15,15 @@
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/plugins/ARPSIO.h>
#include <meteoio/IOUtils.h>
#include <meteoio/IOExceptions.h>
#include <meteoio/meteoLaws/Meteoconst.h> //for PI
#include <meteoio/MathOptim.h>
#include <string.h>
#include <algorithm>
#include <meteoio/plugins/ARPSIO.h>
using namespace std;
namespace mio {
......
......@@ -18,12 +18,7 @@
#ifndef ARPSIO_H
#define ARPSIO_H
#include <meteoio/Config.h>
#include <meteoio/IOInterface.h>
#include <meteoio/IOUtils.h>
#include <meteoio/dataClasses/Coords.h>
#include <meteoio/IOExceptions.h>
#include <meteoio/dataClasses/Grid3DObject.h>
#include <string>
#include <sstream>
......
......@@ -17,7 +17,6 @@
*/
#include <meteoio/plugins/BormaIO.h>
#include <meteoio/IOUtils.h>
#include <meteoio/dataClasses/Coords.h>
#include <meteoio/IOExceptions.h>
#include <sstream>
......@@ -73,28 +72,15 @@ BormaIO::BormaIO(const Config& cfgreader)
}
void BormaIO::readMeteoData(const Date& dateStart, const Date& dateEnd,
std::vector< std::vector<MeteoData> >& vecMeteo,
const size_t& stationindex)
std::vector< std::vector<MeteoData> >& vecMeteo)
{
if (vecStationName.empty())
readStationNames(); //reads station names into vector<string> vecStationName
size_t indexStart=0, indexEnd=vecStationName.size();
vecMeteo.clear();
vecMeteo.insert(vecMeteo.begin(), vecStationName.size(), std::vector<MeteoData>());
//The following part decides whether all the stations are rebuffered or just one station
if (stationindex == IOUtils::npos){
vecMeteo.clear();
vecMeteo.insert(vecMeteo.begin(), vecStationName.size(), std::vector<MeteoData>());
} else {
if (stationindex < vecMeteo.size()){
indexStart = stationindex;
indexEnd = stationindex+1;
} else {
throw IndexOutOfBoundsException(std::string(), AT);
}
}
for (size_t ii=indexStart; ii<indexEnd; ii++){ //loop through stations
for (size_t ii=0; ii<vecStationName.size(); ii++){ //loop through stations
bufferData(dateStart, dateEnd, vecMeteo, ii);
}
}
......
......@@ -18,9 +18,7 @@
#ifndef BORMAIO_H
#define BORMAIO_H
#include <meteoio/Config.h>
#include <meteoio/IOInterface.h>
#include <meteoio/dataClasses/Date.h>
#include <libxml++/libxml++.h>
#include <string>
......@@ -44,8 +42,7 @@ class BormaIO : public IOInterface {
BormaIO(const Config&);
virtual void readMeteoData(const Date& dateStart, const Date& dateEnd,
std::vector< std::vector<MeteoData> >& vecMeteo,
const size_t& stationindex=IOUtils::npos);
std::vector< std::vector<MeteoData> >& vecMeteo);
private:
void convertUnits(MeteoData& meteo);
......
......@@ -18,7 +18,6 @@
#include "CNRMIO.h"
#include <meteoio/ResamplingAlgorithms2D.h>
#include <meteoio/meteoStats/libinterpol1D.h>
#include <meteoio/Timer.h>
#include <meteoio/MathOptim.h>
#include <meteoio/meteoLaws/Atmosphere.h>
#include <meteoio/plugins/libncpp.h>
......@@ -232,7 +231,7 @@ void CNRMIO::readMetaData(const int& ncid, std::vector<StationData>& vecStation)
delete[] alt; delete[] lat; delete[] lon; delete[] aspect; delete[] slope;
}
void CNRMIO::readMeteoData(const Date& dateStart, const Date& dateEnd, std::vector< std::vector<MeteoData> >& vecMeteo, const size_t&)
void CNRMIO::readMeteoData(const Date& dateStart, const Date& dateEnd, std::vector< std::vector<MeteoData> >& vecMeteo)
{
vecMeteo.clear();
const string path = cfg.get("METEOPATH", "Input");
......
......@@ -19,7 +19,6 @@
#define CNRMIO_H
#include <meteoio/IOInterface.h>
#include <meteoio/Config.h>
#include <string>
......@@ -41,8 +40,7 @@ class CNRMIO : public IOInterface {
virtual void readStationData(const Date& date, std::vector<StationData>& vecStation);
virtual void readMeteoData(const Date& dateStart, const Date& dateEnd,
std::vector< std::vector<MeteoData> >& vecMeteo,
const size_t& stationindex=IOUtils::npos);
std::vector< std::vector<MeteoData> >& vecMeteo);
virtual void writeMeteoData(const std::vector< std::vector<MeteoData> >& vecMeteo,
const std::string& name="");
......
......@@ -15,7 +15,9 @@
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 "CosmoXMLIO.h"
#include <meteoio/plugins/CosmoXMLIO.h>
#include <meteoio/IOUtils.h>
#include <meteoio/IOExceptions.h>
#include <meteoio/meteoLaws/Atmosphere.h>
#include <sstream>
......@@ -470,8 +472,7 @@ bool CosmoXMLIO::parseMeteoData(const Date& dateStart, const Date& dateEnd, cons
}
void CosmoXMLIO::readMeteoData(const Date& dateStart, const Date& dateEnd,
std::vector< std::vector<MeteoData> >& vecMeteo,
const size_t&)
std::vector< std::vector<MeteoData> >& vecMeteo)
{
vecMeteo.clear();
const size_t nr_files = cache_meteo_files.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