A class to represent 3D Grids. Typical application: wind field.
#include <Grid3DObject.h>
Public Member Functions | |
double & | operator() (const size_t &ix, const size_t &iy, const size_t &iz) |
double | operator() (const size_t &ix, const size_t &iy, const size_t &iz) const |
double & | operator() (const size_t &i) |
double | operator() (const size_t &i) const |
const std::string | toString () const |
Grid3DObject () | |
Grid3DObject (const Grid3DObject &i_grid3D, const size_t &i_nx, const size_t &i_ny, const size_t &i_nz, const size_t &i_ncols, const size_t &i_nrows, const size_t &i_ndepths) | |
Grid3DObject (const size_t &ncols, const size_t &nrows, const size_t &ndepths, const double &cellsize, const Coords &i_llcorner) | |
Grid3DObject (const size_t &ncols, const size_t &nrows, const size_t &ndepths, const double &cellsize, const Coords &i_llcorner, const double &init) | |
Grid3DObject (const Grid3DObject &i_grid, const double &init) | |
Grid3DObject (const double &cellsize, const Coords &i_llcorner, const Array3D< double > &grid3D) | |
void | set (const size_t &ncols, const size_t &nrows, const size_t &depths, const double &cellsize, const Coords &i_llcorner) |
Set all variables in one go. More... | |
void | set (const double &cellsize, const Coords &i_llcorner, const Array3D< double > &grid3D_in) |
Set all variables in one go. Notably the member grid3D of type Array3D<double> will be destroyed and recreated to size ncols x nrows. More... | |
void | set (const size_t &ncols, const size_t &nrows, const size_t &ndepths, const double &cellsize, const Coords &i_llcorner, const double &init) |
void | set (const Grid3DObject &i_grid, const double &init) |
void | size (size_t &o_ncols, size_t &o_nrows, size_t &o_ndepths) const |
size_t | size () const |
size_t | getNx () const |
size_t | getNy () const |
size_t | getNz () const |
double | getMin () const |
double | getMax () const |
double | getMean () const |
void | clear () |
deletes the data, but keeps geolocalization More... | |
bool | empty () const |
Check if a grid does not contain any data (but it can contain geolocalization) More... | |
bool | gridify (Coords &point) const |
Compute the positional parameters that are not already known This means that the Coords::point object that is given either contains geographic coordinates or grid indices. This method will calculate the missing ones (so that (i,j,k) match with (lat,lon,alt) and (east,north,alt). More... | |
bool | gridify (std::vector< Coords > &vec_points, const bool &keep_invalid=false) const |
Compute the positional parameters that are not already known This means that the Coords::point object that is given either contains geographic coordinates or grid indices. This method will calculate the missing ones (so that (i,j) match with (lat,lon) and (east,north)). Any point that is either invalid or outside the grid is removed from the vector. If the given point had a "NULL" projection, it will be set to the grid's. More... | |
bool | isSameGeolocalization (const Grid3DObject &target) const |
check if the current Grid3DObject has the same geolocalization attributes as another Grid3DObject. The grid coordinates (xllcorner & yllcorner) are NOT checked as these might be tweaked for convenience (like between input grid and local grid) More... | |
void | extractLayer (const size_t &i_z, Grid2DObject &layer) |
Extract a 2D grid for a given height. More... | |
Grid3DObject & | operator= (const double &value) |
Assignement operator. More... | |
Grid3DObject & | operator+= (const double &rhs) |
const Grid3DObject | operator+ (const double &rhs) const |
Grid3DObject & | operator+= (const Grid3DObject &rhs) |
const Grid3DObject | operator+ (const Grid3DObject &rhs) const |
Grid3DObject & | operator-= (const double &rhs) |
const Grid3DObject | operator- (const double &rhs) const |
Grid3DObject & | operator-= (const Grid3DObject &rhs) |
const Grid3DObject | operator- (const Grid3DObject &rhs) const |
Grid3DObject & | operator*= (const double &rhs) |
const Grid3DObject | operator* (const double &rhs) const |
Grid3DObject & | operator*= (const Grid3DObject &rhs) |
const Grid3DObject | operator* (const Grid3DObject &rhs) const |
Grid3DObject & | operator/= (const double &rhs) |
const Grid3DObject | operator/ (const double &rhs) const |
Grid3DObject & | operator/= (const Grid3DObject &rhs) |
const Grid3DObject | operator/ (const Grid3DObject &rhs) const |
bool | operator== (const Grid3DObject &in) const |
Operator that tests for equality. More... | |
bool | operator!= (const Grid3DObject &in) const |
Operator that tests for inequality. More... | |
Public Attributes | |
Array3D< double > | grid3D |
std::vector< double > | z |
Coords | llcorner |
More... | |
double | cellsize |
bool | z_is_absolute |
Protected Member Functions | |
void | setValues (const double &cellsize, const Coords &i_llcorner) |
More... | |
bool | WGS84_to_grid (Coords point) const |
Converts WGS84 coordinates into grid coordinates (i,j) More... | |
bool | grid_to_WGS84 (Coords &point) const |
Converts grid coordinates (i,j) into WGS84 coordinates. More... | |
Friends | |
std::ostream & | operator<< (std::ostream &os, const Grid3DObject &grid) |
std::istream & | operator>> (std::istream &is, Grid3DObject &grid) |
mio::Grid3DObject::Grid3DObject | ( | ) |
Default constructor. Initializes all variables to 0, except nodata, which is initialized to -9999.0
mio::Grid3DObject::Grid3DObject | ( | const Grid3DObject & | i_grid3D, |
const size_t & | i_nx, | ||
const size_t & | i_ny, | ||
const size_t & | i_nz, | ||
const size_t & | i_ncols, | ||
const size_t & | i_nrows, | ||
const size_t & | i_ndepths | ||
) |
A constructor that can be used to create a Grid3DObject that is contained in the one passed as i_grid3Dobj argument. The resulting Grid3DObject is a by value copy of a subspace of the space spanned by the i_grid3Dobj
mio::Grid3DObject::Grid3DObject | ( | const size_t & | ncols, |
const size_t & | nrows, | ||
const size_t & | ndepths, | ||
const double & | cellsize, | ||
const Coords & | i_llcorner | ||
) |
mio::Grid3DObject::Grid3DObject | ( | const size_t & | ncols, |
const size_t & | nrows, | ||
const size_t & | ndepths, | ||
const double & | cellsize, | ||
const Coords & | i_llcorner, | ||
const double & | init | ||
) |
mio::Grid3DObject::Grid3DObject | ( | const Grid3DObject & | i_grid, |
const double & | init | ||
) |
mio::Grid3DObject::Grid3DObject | ( | const double & | cellsize, |
const Coords & | i_llcorner, | ||
const Array3D< double > & | grid3D | ||
) |
void mio::Grid3DObject::clear | ( | ) |
deletes the data, but keeps geolocalization
bool mio::Grid3DObject::empty | ( | ) | const |
Check if a grid does not contain any data (but it can contain geolocalization)
void mio::Grid3DObject::extractLayer | ( | const size_t & | i_z, |
Grid2DObject & | layer | ||
) |
Extract a 2D grid for a given height.
i_z | layer to extract |
layer | extracted 2D grid |
double mio::Grid3DObject::getMax | ( | ) | const |
double mio::Grid3DObject::getMean | ( | ) | const |
double mio::Grid3DObject::getMin | ( | ) | const |
size_t mio::Grid3DObject::getNx | ( | ) | const |
size_t mio::Grid3DObject::getNy | ( | ) | const |
size_t mio::Grid3DObject::getNz | ( | ) | const |
|
protected |
Converts grid coordinates (i,j) into WGS84 coordinates.
point | coordinate to convert |
bool mio::Grid3DObject::gridify | ( | Coords & | point | ) | const |
Compute the positional parameters that are not already known This means that the Coords::point object that is given either contains geographic coordinates or grid indices. This method will calculate the missing ones (so that (i,j,k) match with (lat,lon,alt) and (east,north,alt).
point | coordinate to convert |
bool mio::Grid3DObject::gridify | ( | std::vector< Coords > & | vec_points, |
const bool & | keep_invalid = false |
||
) | const |
Compute the positional parameters that are not already known This means that the Coords::point object that is given either contains geographic coordinates or grid indices. This method will calculate the missing ones (so that (i,j) match with (lat,lon) and (east,north)). Any point that is either invalid or outside the grid is removed from the vector. If the given point had a "NULL" projection, it will be set to the grid's.
vec_points | vector containing the coordinates to convert |
keep_invalid | keep invalid coordinates? (default: false) |
bool mio::Grid3DObject::isSameGeolocalization | ( | const Grid3DObject & | target | ) | const |
check if the current Grid3DObject has the same geolocalization attributes as another Grid3DObject. The grid coordinates (xllcorner & yllcorner) are NOT checked as these might be tweaked for convenience (like between input grid and local grid)
target | grid to compare to |
bool mio::Grid3DObject::operator!= | ( | const Grid3DObject & | in | ) | const |
Operator that tests for inequality.
double & mio::Grid3DObject::operator() | ( | const size_t & | i | ) |
double mio::Grid3DObject::operator() | ( | const size_t & | i | ) | const |
double & mio::Grid3DObject::operator() | ( | const size_t & | ix, |
const size_t & | iy, | ||
const size_t & | iz | ||
) |
double mio::Grid3DObject::operator() | ( | const size_t & | ix, |
const size_t & | iy, | ||
const size_t & | iz | ||
) | const |
const Grid3DObject mio::Grid3DObject::operator* | ( | const double & | rhs | ) | const |
const Grid3DObject mio::Grid3DObject::operator* | ( | const Grid3DObject & | rhs | ) | const |
Grid3DObject & mio::Grid3DObject::operator*= | ( | const double & | rhs | ) |
Grid3DObject & mio::Grid3DObject::operator*= | ( | const Grid3DObject & | rhs | ) |
const Grid3DObject mio::Grid3DObject::operator+ | ( | const double & | rhs | ) | const |
const Grid3DObject mio::Grid3DObject::operator+ | ( | const Grid3DObject & | rhs | ) | const |
Grid3DObject & mio::Grid3DObject::operator+= | ( | const double & | rhs | ) |
Grid3DObject & mio::Grid3DObject::operator+= | ( | const Grid3DObject & | rhs | ) |
const Grid3DObject mio::Grid3DObject::operator- | ( | const double & | rhs | ) | const |
const Grid3DObject mio::Grid3DObject::operator- | ( | const Grid3DObject & | rhs | ) | const |
Grid3DObject & mio::Grid3DObject::operator-= | ( | const double & | rhs | ) |
Grid3DObject & mio::Grid3DObject::operator-= | ( | const Grid3DObject & | rhs | ) |
const Grid3DObject mio::Grid3DObject::operator/ | ( | const double & | rhs | ) | const |
const Grid3DObject mio::Grid3DObject::operator/ | ( | const Grid3DObject & | rhs | ) | const |
Grid3DObject & mio::Grid3DObject::operator/= | ( | const double & | rhs | ) |
Grid3DObject & mio::Grid3DObject::operator/= | ( | const Grid3DObject & | rhs | ) |
Grid3DObject & mio::Grid3DObject::operator= | ( | const double & | value | ) |
Assignement operator.
bool mio::Grid3DObject::operator== | ( | const Grid3DObject & | in | ) | const |
Operator that tests for equality.
void mio::Grid3DObject::set | ( | const double & | cellsize, |
const Coords & | i_llcorner, | ||
const Array3D< double > & | grid3D_in | ||
) |
Set all variables in one go. Notably the member grid3D of type Array3D<double> will be destroyed and recreated to size ncols x nrows.
cellsize | value for cellsize in grid3D |
i_llcorner | lower left corner coordinates |
grid3D_in | grid to be copied by value |
void mio::Grid3DObject::set | ( | const Grid3DObject & | i_grid, |
const double & | init | ||
) |
void mio::Grid3DObject::set | ( | const size_t & | ncols, |
const size_t & | nrows, | ||
const size_t & | depths, | ||
const double & | cellsize, | ||
const Coords & | i_llcorner | ||
) |
Set all variables in one go.
ncols | number of colums in the grid3D (1st dimension) |
nrows | number of rows in the grid3D (2nd dimension) |
depths | number of depth in the grid3D (3rd dimension) |
cellsize | value for cellsize in grid3D |
i_llcorner | lower left corner coordinates |
void mio::Grid3DObject::set | ( | const size_t & | ncols, |
const size_t & | nrows, | ||
const size_t & | ndepths, | ||
const double & | cellsize, | ||
const Coords & | i_llcorner, | ||
const double & | init | ||
) |
|
protected |
Are z coordinates absolute or relative to a DEM?
size_t mio::Grid3DObject::size | ( | ) | const |
void mio::Grid3DObject::size | ( | size_t & | o_ncols, |
size_t & | o_nrows, | ||
size_t & | o_ndepths | ||
) | const |
const std::string mio::Grid3DObject::toString | ( | ) | const |
|
protected |
Converts WGS84 coordinates into grid coordinates (i,j)
point | coordinate to convert |
|
friend |
|
friend |
double mio::Grid3DObject::cellsize |
Array3D<double> mio::Grid3DObject::grid3D |
Coords mio::Grid3DObject::llcorner |
Vector of depths
std::vector<double> mio::Grid3DObject::z |
bool mio::Grid3DObject::z_is_absolute |