WSL/SLF GitLab Repository

Commit b2991182 authored by Thomas Egger's avatar Thomas Egger
Browse files

IOManager: added another interpolate procedure that takes as arguments a Date,...

IOManager: added another interpolate procedure that takes as arguments a Date, a DEMObject, the parameter to interpolate, a vector of Coords objects and a vector of doubles. The Coords represent different points in the DEM. The interpolation is only performed for these points and for each point one double value is stored in a vector. 

Furthermore IOManager now has a member variable called interpolater of type Meteo2DInterpolator. A circular inclusion problem has been solved between IOManager and Meteo2DInterpolator.

libinterpol2D bugfix: The SimpleDEMWindInterpolate algorithm had  a small bug in it, it wasn't interpolating values in the last row or last column of the 2D grid.
parent 79439412
......@@ -22,7 +22,8 @@ using namespace std;
namespace mio {
IOManager::IOManager(const Config& i_cfg) : cfg(i_cfg), rawio(cfg), bufferedio(rawio, cfg), meteoprocessor(cfg)
IOManager::IOManager(const Config& i_cfg) : cfg(i_cfg), rawio(cfg), bufferedio(rawio, cfg),
meteoprocessor(cfg), interpolator(cfg, *this)
{
setProcessingLevel(IOManager::filtered | IOManager::resampled);
fcache_start = fcache_end = Date(0.0, 0.); //this should not matter, since 0 is still way back before any real data...
......@@ -274,8 +275,47 @@ void IOManager::interpolate(const Date& date, const DEMObject& dem, const MeteoD
Grid2DObject& result, std::string& info_string)
#endif
{
Meteo2DInterpolator mi(cfg, *this);
mi.interpolate(date, dem, meteoparam, result, info_string);
interpolator.interpolate(date, dem, meteoparam, result, info_string);
}
#ifdef _POPC_ //HACK popc
void IOManager::interpolate(/*const*/ Date& date, /*const*/ DEMObject& dem, /*const*/ MeteoData::Parameters& meteoparam,
/*const*/ std::vector<Coords>& in_coords, std::vector<double>& result)
#else
void IOManager::interpolate(const Date& date, const DEMObject& dem, const MeteoData::Parameters& meteoparam,
const std::vector<Coords>& in_coords, std::vector<double>& result)
#endif
{
result.clear();
vector<Coords> vec_coords = in_coords;
for (size_t ii=0; ii<vec_coords.size(); ii++) {
bool gridify_success = dem.gridify(vec_coords[ii]);
if (!gridify_success)
throw InvalidArgumentException("Coordinate given to interpolate is outside of dem", AT);
//Make new DEM with just one point, namely the one specified by vec_coord[ii]
//Copy all other properties of the big DEM into the new one
DEMObject one_point_dem(dem, vec_coords[ii].getGridI(), vec_coords[ii].getGridJ(), 1, 1, false);
one_point_dem.min_altitude = dem.min_altitude;
one_point_dem.max_altitude = dem.max_altitude;
one_point_dem.min_slope = dem.min_slope;
one_point_dem.max_slope = dem.max_slope;
one_point_dem.min_curvature = dem.min_curvature;
one_point_dem.max_curvature = dem.max_curvature;
Grid2DObject result_grid;
interpolator.interpolate(date, one_point_dem, meteoparam, result_grid);
size_t result_x, result_y;
result_grid.size(result_x, result_y);
if ((result_x == result_y) && (result_x == 1)) { //Consistency check, maybe unnecessary
result.push_back(result_grid.grid2D(0,0));
} else {
throw IOException("Error while trying to interpolate for one coordinate", AT);
}
}
}
void IOManager::read2DGrid(Grid2DObject& grid2D, const std::string& filename)
......
......@@ -18,8 +18,8 @@
#ifndef __IOMANAGER_H__
#define __IOMANAGER_H__
#include <meteoio/BufferedIOHandler.h>
#include <meteoio/Meteo2DInterpolator.h>
#include <meteoio/BufferedIOHandler.h>
#include <meteoio/MeteoProcessor.h>
#include <meteoio/MeteoData.h>
......@@ -129,6 +129,14 @@ class IOManager {
Grid2DObject& result, std::string& info_string);
#endif
#ifdef _POPC_ //HACK popc
void interpolate(/*const*/ Date& date, /*const*/ DEMObject& dem, /*const*/ MeteoData::Parameters& meteoparam,
/*const*/ std::vector<Coords>& in_coords, std::vector<double>& result);
#else
void interpolate(const Date& date, const DEMObject& dem, const MeteoData::Parameters& meteoparam,
const std::vector<Coords>& in_coords, std::vector<double>& result);
#endif
/**
* @brief Set the desired ProcessingLevel of the IOManager instance
* The processing level affects the way meteo data is read and processed
......@@ -185,6 +193,7 @@ class IOManager {
IOHandler rawio;
BufferedIOHandler bufferedio;
MeteoProcessor meteoprocessor;
Meteo2DInterpolator interpolator;
ProcessingProperties proc_properties; ///< buffer constraints in order to be able to compute the requested values
std::map<Date, METEO_TIMESERIE > resampled_cache; ///< stores already resampled data points
......
......@@ -17,6 +17,8 @@
*/
#include <meteoio/InterpolationAlgorithms.h>
#include <meteoio/meteolaws/Atmosphere.h>
#include <meteoio/Meteo2DInterpolator.h>
#include <meteoio/IOManager.h>
using namespace std;
......
......@@ -18,8 +18,10 @@
#ifndef __INTERPOLATIONALGORITHMS_H__
#define __INTERPOLATIONALGORITHMS_H__
#include <meteoio/MeteoIO.h>
#include <meteoio/DEMObject.h>
#include <meteoio/MeteoData.h>
#include <meteoio/meteostats/libinterpol1D.h>
#include <meteoio/meteostats/libinterpol2D.h>
#include <meteoio/meteostats/libfit1D.h>
#include <vector>
......
......@@ -19,7 +19,11 @@
#ifndef __METEO2DINTERPOLATOR_H__
#define __METEO2DINTERPOLATOR_H__
#include <meteoio/MeteoIO.h>
#include <meteoio/Config.h>
#include <meteoio/Date.h>
#include <meteoio/MeteoData.h>
#include <meteoio/DEMObject.h>
#include <meteoio/InterpolationAlgorithms.h>
#include <memory>
#include <vector>
......
......@@ -564,8 +564,8 @@ void Interpol2D::SimpleDEMWindInterpolate(const DEMObject& dem, Grid2DObject& VW
const double dem_min_slope=dem.min_slope*to_rad, dem_range_slope=(dem.max_slope-dem_min_slope)*to_rad;
const double dem_min_curvature=dem.min_curvature, dem_range_curvature=(dem.max_curvature-dem_min_curvature);
for (unsigned int j=0;j<VW.nrows-1;j++) {
for (unsigned int i=0;i<VW.ncols-1;i++){
for (unsigned int j=0;j<VW.nrows;j++) {
for (unsigned int i=0;i<VW.ncols;i++){
// Get input data
speed = VW.grid2D(i,j);
dir = DW.grid2D(i,j);
......
......@@ -22,7 +22,10 @@
#ifndef INTERPOL2D_H
#define INTERPOL2D_H
#include <meteoio/MeteoIO.h>
#include <meteoio/StationData.h>
#include <meteoio/DEMObject.h>
#include <meteoio/meteostats/libfit1D.h>
#include <meteoio/meteostats/libinterpol1D.h>
#include <vector>
namespace mio {
......
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