MeteoIODoc 20241221.207bde49
mio::Grid3DObject Class Reference

Detailed Description

A class to represent 3D Grids. Typical application: wind field.

Author
Thomas Egger
Date
2009-07-20

#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...
 
Grid3DObjectoperator= (const double &value)
 Assignement operator. More...
 
Grid3DObjectoperator+= (const double &rhs)
 
const Grid3DObject operator+ (const double &rhs) const
 
Grid3DObjectoperator+= (const Grid3DObject &rhs)
 
const Grid3DObject operator+ (const Grid3DObject &rhs) const
 
Grid3DObjectoperator-= (const double &rhs)
 
const Grid3DObject operator- (const double &rhs) const
 
Grid3DObjectoperator-= (const Grid3DObject &rhs)
 
const Grid3DObject operator- (const Grid3DObject &rhs) const
 
Grid3DObjectoperator*= (const double &rhs)
 
const Grid3DObject operator* (const double &rhs) const
 
Grid3DObjectoperator*= (const Grid3DObject &rhs)
 
const Grid3DObject operator* (const Grid3DObject &rhs) const
 
Grid3DObjectoperator/= (const double &rhs)
 
const Grid3DObject operator/ (const double &rhs) const
 
Grid3DObjectoperator/= (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
 

‍Vector of depths

More...
 
double cellsize
 
bool z_is_absolute
 

Protected Member Functions

void setValues (const double &cellsize, const Coords &i_llcorner)
 

‍Are z coordinates absolute or relative to a DEM?

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)
 

Constructor & Destructor Documentation

◆ Grid3DObject() [1/6]

mio::Grid3DObject::Grid3DObject ( )

Default constructor. Initializes all variables to 0, except nodata, which is initialized to -9999.0

◆ Grid3DObject() [2/6]

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

◆ Grid3DObject() [3/6]

mio::Grid3DObject::Grid3DObject ( const size_t &  ncols,
const size_t &  nrows,
const size_t &  ndepths,
const double &  cellsize,
const Coords i_llcorner 
)

◆ Grid3DObject() [4/6]

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 
)

◆ Grid3DObject() [5/6]

mio::Grid3DObject::Grid3DObject ( const Grid3DObject i_grid,
const double &  init 
)

◆ Grid3DObject() [6/6]

mio::Grid3DObject::Grid3DObject ( const double &  cellsize,
const Coords i_llcorner,
const Array3D< double > &  grid3D 
)

Member Function Documentation

◆ clear()

void mio::Grid3DObject::clear ( )

deletes the data, but keeps geolocalization

◆ empty()

bool mio::Grid3DObject::empty ( ) const

Check if a grid does not contain any data (but it can contain geolocalization)

Returns
true if the grid is 0x0

◆ extractLayer()

void mio::Grid3DObject::extractLayer ( const size_t &  i_z,
Grid2DObject layer 
)

Extract a 2D grid for a given height.

Parameters
i_zlayer to extract
layerextracted 2D grid

◆ getMax()

double mio::Grid3DObject::getMax ( ) const

◆ getMean()

double mio::Grid3DObject::getMean ( ) const

◆ getMin()

double mio::Grid3DObject::getMin ( ) const

◆ getNx()

size_t mio::Grid3DObject::getNx ( ) const

◆ getNy()

size_t mio::Grid3DObject::getNy ( ) const

◆ getNz()

size_t mio::Grid3DObject::getNz ( ) const

◆ grid_to_WGS84()

bool mio::Grid3DObject::grid_to_WGS84 ( Coords point) const
protected

Converts grid coordinates (i,j) into WGS84 coordinates.

Parameters
pointcoordinate to convert
Returns
false if the given point was invalid (outside the grid or nodata and if possible sets (i,j) to closest values within the grid)

◆ gridify() [1/2]

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).

Parameters
pointcoordinate to convert
Returns
false if the given point was invalid or outside the grid (sets (i,j) to closest values within the grid)

◆ gridify() [2/2]

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.

Parameters
vec_pointsvector containing the coordinates to convert
keep_invalidkeep invalid coordinates? (default: false)
Returns
false if invalid or external points had to be removed

◆ isSameGeolocalization()

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)

Parameters
targetgrid to compare to
Returns
true if same geolocalization

◆ operator!=()

bool mio::Grid3DObject::operator!= ( const Grid3DObject in) const

Operator that tests for inequality.

◆ operator()() [1/4]

double & mio::Grid3DObject::operator() ( const size_t &  i)

◆ operator()() [2/4]

double mio::Grid3DObject::operator() ( const size_t &  i) const

◆ operator()() [3/4]

double & mio::Grid3DObject::operator() ( const size_t &  ix,
const size_t &  iy,
const size_t &  iz 
)

◆ operator()() [4/4]

double mio::Grid3DObject::operator() ( const size_t &  ix,
const size_t &  iy,
const size_t &  iz 
) const

◆ operator*() [1/2]

const Grid3DObject mio::Grid3DObject::operator* ( const double &  rhs) const

◆ operator*() [2/2]

const Grid3DObject mio::Grid3DObject::operator* ( const Grid3DObject rhs) const

◆ operator*=() [1/2]

Grid3DObject & mio::Grid3DObject::operator*= ( const double &  rhs)

◆ operator*=() [2/2]

Grid3DObject & mio::Grid3DObject::operator*= ( const Grid3DObject rhs)

◆ operator+() [1/2]

const Grid3DObject mio::Grid3DObject::operator+ ( const double &  rhs) const

◆ operator+() [2/2]

const Grid3DObject mio::Grid3DObject::operator+ ( const Grid3DObject rhs) const

◆ operator+=() [1/2]

Grid3DObject & mio::Grid3DObject::operator+= ( const double &  rhs)

◆ operator+=() [2/2]

Grid3DObject & mio::Grid3DObject::operator+= ( const Grid3DObject rhs)

◆ operator-() [1/2]

const Grid3DObject mio::Grid3DObject::operator- ( const double &  rhs) const

◆ operator-() [2/2]

const Grid3DObject mio::Grid3DObject::operator- ( const Grid3DObject rhs) const

◆ operator-=() [1/2]

Grid3DObject & mio::Grid3DObject::operator-= ( const double &  rhs)

◆ operator-=() [2/2]

Grid3DObject & mio::Grid3DObject::operator-= ( const Grid3DObject rhs)

◆ operator/() [1/2]

const Grid3DObject mio::Grid3DObject::operator/ ( const double &  rhs) const

◆ operator/() [2/2]

const Grid3DObject mio::Grid3DObject::operator/ ( const Grid3DObject rhs) const

◆ operator/=() [1/2]

Grid3DObject & mio::Grid3DObject::operator/= ( const double &  rhs)

◆ operator/=() [2/2]

Grid3DObject & mio::Grid3DObject::operator/= ( const Grid3DObject rhs)

◆ operator=()

Grid3DObject & mio::Grid3DObject::operator= ( const double &  value)

Assignement operator.

◆ operator==()

bool mio::Grid3DObject::operator== ( const Grid3DObject in) const

Operator that tests for equality.

◆ set() [1/4]

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.

Parameters
cellsizevalue for cellsize in grid3D
i_llcornerlower left corner coordinates
grid3D_ingrid to be copied by value

◆ set() [2/4]

void mio::Grid3DObject::set ( const Grid3DObject i_grid,
const double &  init 
)

◆ set() [3/4]

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.

Parameters
ncolsnumber of colums in the grid3D (1st dimension)
nrowsnumber of rows in the grid3D (2nd dimension)
depthsnumber of depth in the grid3D (3rd dimension)
cellsizevalue for cellsize in grid3D
i_llcornerlower left corner coordinates

◆ set() [4/4]

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 
)

◆ setValues()

void mio::Grid3DObject::setValues ( const double &  cellsize,
const Coords i_llcorner 
)
protected

‍Are z coordinates absolute or relative to a DEM?

◆ size() [1/2]

size_t mio::Grid3DObject::size ( ) const

◆ size() [2/2]

void mio::Grid3DObject::size ( size_t &  o_ncols,
size_t &  o_nrows,
size_t &  o_ndepths 
) const

◆ toString()

const std::string mio::Grid3DObject::toString ( ) const

◆ WGS84_to_grid()

bool mio::Grid3DObject::WGS84_to_grid ( Coords  point) const
protected

Converts WGS84 coordinates into grid coordinates (i,j)

Parameters
pointcoordinate to convert
Returns
false if the given point was outside the grid (sets (i,j) to closest values within the grid)

Friends And Related Function Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream &  os,
const Grid3DObject grid 
)
friend

◆ operator>>

std::istream & operator>> ( std::istream &  is,
Grid3DObject grid 
)
friend

Member Data Documentation

◆ cellsize

double mio::Grid3DObject::cellsize

◆ grid3D

Array3D<double> mio::Grid3DObject::grid3D

◆ llcorner

Coords mio::Grid3DObject::llcorner

‍Vector of depths

◆ z

std::vector<double> mio::Grid3DObject::z

◆ z_is_absolute

bool mio::Grid3DObject::z_is_absolute

The documentation for this class was generated from the following files: