Alpine3D  Alpine3D-3.2.0
Runoff Class Reference

#include <Runoff.h>

Public Member Functions

 Runoff (const mio::Config &in_cfg, const mio::DEMObject &in_dem, const double &in_thresh_rain)
 Constructor of Runoff instance. More...
 
 Runoff (const Runoff &copy)
 
void setSnowPack (SnowpackInterface &sn_interface)
 Sets the internal reference to SnowpackInterface object. More...
 
virtual void output (const mio::Date &i_date, const mio::Grid2DObject &psum, const mio::Grid2DObject &ta, mio::IOManager &io_in)
 Writes the results for a specific day. More...
 
virtual ~Runoff ()
 Destructor of class Runoff. More...
 
std::string getGridsRequirements () const
 
double getTiming () const
 
 Runoff (mio::IOManager &sn_io, const double &)
 Constructor of Runoff instance. More...
 
 ~Runoff ()
 
bool initialize (const mio::DEMObject &in_dem, const mio::Config &cfg)
 This method initialize the importent parameters of Runoff. More...
 
void setRunoff (const mio::Array2D< double > &, const mio::Array2D< double > &runoff_soil, const mio::Array2D< double > &, const mio::Array2D< double > &, const mio::Array2D< double > &)
 
void output (const mio::Date &i_date)
 Writes the Results for a specific day. More...
 

Protected Types

enum  NumberingType { Alpine3DOld, TauDEM }
 

Protected Member Functions

virtual void constructCatchmentMasks (mio::Grid2DObject catchmentGrid)
 Initializes private attribute catchment_masks. More...
 
virtual void updateTotalRunoffGrid ()
 Updates protected attribute total_runoff. More...
 
virtual void updateGlacierMask ()
 Updates protected attribute glacier_mask. More...
 
virtual mio::Grid2DObject computePrecipRunoff (const mio::Grid2DObject &psum, const mio::Grid2DObject &ta) const
 Computes the grid storing the runoff which originates from liquid precipitation. More...
 
virtual void getExtraMeteoGrids (std::vector< mio::Grid2DObject > &grids) const
 Returns the grids corresponding to the additional meteo variables which have to be averaged over the subcatchments and written in the output files. More...
 
virtual void initializeOutputFiles (const mio::Grid2DObject &dem) const
 Initializes the SMET files in which the per-catchment-aggregated runoff values will be written. More...
 
virtual void updateOutputFile (const size_t &catchId, const mio::Date &currTime, const double &totalRunoff, const double &precipRunoff, const double &snowRunoff, const double &glacierRunoff, const std::vector< double > &meteoVars) const
 Writes the runoff values aggregated over a given catchment in the corresponding SMET file. More...
 

Static Protected Member Functions

static mio::IOManager * getIOManager (mio::Config in_cfg, const bool &outputGrids)
 Returns a IOManager object which will write the runoff grids in the correct output folder. More...
 
static mio::Grid2DObject getSlopeCorrection (const mio::DEMObject &dem)
 Computes the grid used to correct the runoff values for slope (Alpine3D assumes the cells to be flat, the predicted runoffs therefore have to be corrected for terrain inclination) More...
 
static NumberingType getCatchmentNumberingScheme (const mio::Config &in_cfg)
 Returns the numbering scheme used in the grid defining the catchments. More...
 
static bool getIsGlacierDynamic (const mio::Config &cfg)
 Returns whether the glaciers are dynamic, i.e. whether the glacier mask should be expected to change from one time step to the other. More...
 
static std::vector< SnGrids::ParametersgetExtraMeteoVariables (const mio::Config &cfg)
 This method returns the meteo variables which have to be averaged over the subwatershed areas and written in the output files on top of runoff. More...
 
static double getResamplingCellSize (const mio::DEMObject &in_dem, const mio::Grid2DObject &catchments)
 Returns the cell size which must be used to resample both the catchment masks and the runoff grids. More...
 
static bool isMultiple (const double &a, const double &b)
 Returns whether the first input is a multiple of the second one. More...
 
static double estimateResamplingCellSize (const double &llOffset, const double &currSizeEstimate)
 
static std::vector< size_t > factorizeCatchmentNumber (longuint value)
 This function splits up a given unsigned int value into a sum of powers of 2. More...
 
static void cropMask (mio::Grid2DObject &mask)
 Crops the mask so as to remove as many nodata cells as possible (note: this method possibly changes the georeferencing of the mask by changing its lower-left corner as well as its number of rows or columns) More...
 
static double sumOverMask (const mio::Grid2DObject &grid, const mio::Grid2DObject &mask)
 Sums the values of the grid cells which are located over the mask. More...
 
static double averageOverMask (const mio::Grid2DObject &grid, const mio::Grid2DObject &mask)
 Averages the values of the grid cells which are located over the mask. More...
 

Protected Attributes

mio::IOManager * io
 
SnowpackInterfacesnowpack
 Reference to SnowpackInterface object, used for callbacks, initialized during construction. More...
 
const double thresh_rain
 
const double tz_out
 
bool output_grids
 
bool output_sums
 
std::string catchment_out_path
 
double resampling_cell_size
 
double grid_size_factor
 
const size_t n_grid_cells
 
enum Runoff::NumberingType catchment_numbering
 
mio::Timer timer
 
const mio::Grid2DObject slope_correction
 
const bool is_glacier_mask_dynamic
 
bool is_glacier_mask_set
 
mio::Grid2DObject total_runoff
 
mio::Grid2DObject glacier_mask
 
std::vector< SnGrids::Parametersextra_meteo_variables
 
size_t n_extra_meteo_variables
 
std::map< size_t, mio::Grid2DObject > catchment_masks
 
bool use_external_iomanager_for_grids
 

Static Protected Attributes

static const double MIN_CELL_SIZE = 5.0
 
static const double DISTANCE_ABSOLUTE_PRECISION = 1e-3
 

Member Enumeration Documentation

◆ NumberingType

enum Runoff::NumberingType
protected
Enumerator
Alpine3DOld 
TauDEM 

Constructor & Destructor Documentation

◆ Runoff() [1/3]

Runoff::Runoff ( const mio::Config &  in_cfg,
const mio::DEMObject &  in_dem,
const double &  in_thresh_rain 
)

Constructor of Runoff instance.

Parameters
in_cfgreference to the config object used by SnowpackInterfaceWorker in order to build our own IOManager in Runoff
in_demreference to the DEM used by Alpine3D
in_thresh_rainrain/snow temperature threshold. This will be used to correctly split the output between melt/precipitation

◆ Runoff() [2/3]

Runoff::Runoff ( const Runoff copy)

◆ ~Runoff() [1/2]

Runoff::~Runoff ( )
virtual

Destructor of class Runoff.

Destructor of Runoff which close the output stream which write the result files.

◆ Runoff() [3/3]

Runoff::Runoff ( mio::IOManager &  sn_io,
const double &   
)

Constructor of Runoff instance.

Parameters
sn_iois the ref to the IOManager instance from SnowPack. With this, Runoff don't need to have a second IOManager

◆ ~Runoff() [2/2]

Runoff::~Runoff ( )

Member Function Documentation

◆ averageOverMask()

double Runoff::averageOverMask ( const mio::Grid2DObject &  grid,
const mio::Grid2DObject &  mask 
)
staticprotected

Averages the values of the grid cells which are located over the mask.

Parameters
gridgrid whose cell values have to be averaged
maskmask over which the grid cell values have to be averaged
Returns
Average of the masked grid cell values

◆ computePrecipRunoff()

mio::Grid2DObject Runoff::computePrecipRunoff ( const mio::Grid2DObject &  psum,
const mio::Grid2DObject &  ta 
) const
protectedvirtual

Computes the grid storing the runoff which originates from liquid precipitation.

Parameters
psumgrid of precipitation in mm/h
tagrid of air temperature
Returns
Precipitation runoff grid

◆ constructCatchmentMasks()

void Runoff::constructCatchmentMasks ( mio::Grid2DObject  catchmentGrid)
protectedvirtual

Initializes private attribute catchment_masks.

Parameters
catchmentGridgrid defining the catchments. The catchment numbering scheme must be specified in the ini file using the key CATCHMENT_NUMBERING in section INPUT. This scheme can be either ALPINE3D_OLD (for catchments numbered with powers of 2), or TAUDEM (for standard numbering).

◆ cropMask()

void Runoff::cropMask ( mio::Grid2DObject &  mask)
staticprotected

Crops the mask so as to remove as many nodata cells as possible (note: this method possibly changes the georeferencing of the mask by changing its lower-left corner as well as its number of rows or columns)

◆ estimateResamplingCellSize()

double Runoff::estimateResamplingCellSize ( const double &  llOffset,
const double &  currSizeEstimate 
)
staticprotected

◆ factorizeCatchmentNumber()

std::vector< size_t > Runoff::factorizeCatchmentNumber ( longuint  value)
staticprotected

This function splits up a given unsigned int value into a sum of powers of 2.

Parameters
valueThe value that shall be split up into a sum of powers of two
Returns
A vector that will hold all exponents of the sum of powers

◆ getCatchmentNumberingScheme()

Runoff::NumberingType Runoff::getCatchmentNumberingScheme ( const mio::Config &  in_cfg)
staticprotected

Returns the numbering scheme used in the grid defining the catchments.

Parameters
in_cfgReference to the Config object used in Alpine3D
Returns
Catchment numbering scheme

◆ getExtraMeteoGrids()

void Runoff::getExtraMeteoGrids ( std::vector< mio::Grid2DObject > &  grids) const
protectedvirtual

Returns the grids corresponding to the additional meteo variables which have to be averaged over the subcatchments and written in the output files.

Parameters
[out]gridsvector containing the meteo grids

◆ getExtraMeteoVariables()

std::vector< SnGrids::Parameters > Runoff::getExtraMeteoVariables ( const mio::Config &  cfg)
staticprotected

This method returns the meteo variables which have to be averaged over the subwatershed areas and written in the output files on top of runoff.

Parameters
cfgReference to the Config object holding the simulation parameters
Returns
Variables which have to be averaged over the subwatershed areas

◆ getGridsRequirements()

std::string Runoff::getGridsRequirements ( ) const

◆ getIOManager()

mio::IOManager * Runoff::getIOManager ( mio::Config  cfg,
const bool &  outputGrids 
)
staticprotected

Returns a IOManager object which will write the runoff grids in the correct output folder.

Parameters
cfgConfig object used in Alpine3D
outputGridsshould the runoff grids be written out?

◆ getIsGlacierDynamic()

bool Runoff::getIsGlacierDynamic ( const mio::Config &  cfg)
staticprotected

Returns whether the glaciers are dynamic, i.e. whether the glacier mask should be expected to change from one time step to the other.

Parameters
cfgReference to the Config object holding the simulation parameters
Returns
Is glacier mask dynamic?

◆ getResamplingCellSize()

double Runoff::getResamplingCellSize ( const mio::DEMObject &  in_dem,
const mio::Grid2DObject &  catchmentGrid 
)
staticprotected

Returns the cell size which must be used to resample both the catchment masks and the runoff grids.

Parameters
in_demreference to the Config object used in Alpine3D
catchmentGridgrid defining the catchments
Returns
Resampling cell size in m

◆ getSlopeCorrection()

mio::Grid2DObject Runoff::getSlopeCorrection ( const mio::DEMObject &  dem)
staticprotected

Computes the grid used to correct the runoff values for slope (Alpine3D assumes the cells to be flat, the predicted runoffs therefore have to be corrected for terrain inclination)

Parameters
demReference to the DEM object used by Alpine3D

◆ getTiming()

double Runoff::getTiming ( ) const

◆ initialize()

bool Runoff::initialize ( const mio::DEMObject &  in_dem,
const mio::Config &  cfg 
)

This method initialize the importent parameters of Runoff.

Parameters
in_demis the Deographic object, which is needed for to take/controll the dimensions of the catchments
cfgis the configuration file, so Runoff know where to write the results maxexp

◆ initializeOutputFiles()

void Runoff::initializeOutputFiles ( const mio::Grid2DObject &  dem) const
protectedvirtual

Initializes the SMET files in which the per-catchment-aggregated runoff values will be written.

Parameters
demReference to the DEM object

◆ isMultiple()

bool Runoff::isMultiple ( const double &  a,
const double &  b 
)
staticprotected

Returns whether the first input is a multiple of the second one.

◆ output() [1/2]

void Runoff::output ( const mio::Date &  i_date,
const mio::Grid2DObject &  psum,
const mio::Grid2DObject &  ta,
mio::IOManager &  io_in 
)
virtual

Writes the results for a specific day.

Parameters
[in]i_datethe date at which the results should be written
[in]psumgrid of precipitation in mm/h
[in]tagrid of air temperature
io_inExternal IOManager that can be used to write all outputs into the same file (if GRID2DFILE=RUNOFF_GRID2DFILE)

◆ output() [2/2]

void Runoff::output ( const mio::Date &  i_date)

Writes the Results for a specific day.

Parameters
i_datethe Date to write the results

◆ setRunoff()

void Runoff::setRunoff ( const mio::Array2D< double > &  ,
const mio::Array2D< double > &  runoff_soil,
const mio::Array2D< double > &  ,
const mio::Array2D< double > &  ,
const mio::Array2D< double > &   
)

◆ setSnowPack()

void Runoff::setSnowPack ( SnowpackInterface sn_interface)

Sets the internal reference to SnowpackInterface object.

Parameters
sn_interfaceReference to the SnowpackInterface object

◆ sumOverMask()

double Runoff::sumOverMask ( const mio::Grid2DObject &  grid,
const mio::Grid2DObject &  mask 
)
staticprotected

Sums the values of the grid cells which are located over the mask.

Parameters
gridgrid whose cell values have to be summed
maskmask over which the grid cell values have to be summed
Returns
Sum of the masked grid cell values

◆ updateGlacierMask()

void Runoff::updateGlacierMask ( )
protectedvirtual

Updates protected attribute glacier_mask.

◆ updateOutputFile()

void Runoff::updateOutputFile ( const size_t &  catchId,
const mio::Date &  currTime,
const double &  totalRunoff,
const double &  precipRunoff,
const double &  snowRunoff,
const double &  glacierRunoff,
const std::vector< double > &  meteoVars 
) const
protectedvirtual

Writes the runoff values aggregated over a given catchment in the corresponding SMET file.

Parameters
catchIdcatchment id number
currTimetime corresponding to the runoff values
totalRunofftotal runoff (corrected for slope) over the catchment, in mm/h
precipRunoffpart of the total runoff attributable to liquid precipitation, in mm/h
snowRunoffpart of the total runoff attributable to snow melt, in mm/h
glacierRunoffpart of the total runoff attributable to glacier melt, in mm/h
meteoVarsadditional meteorological variables averaged over the catchment area. The units of each variable correspond to those used in Alpine3D or Snowpack.

◆ updateTotalRunoffGrid()

void Runoff::updateTotalRunoffGrid ( )
protectedvirtual

Updates protected attribute total_runoff.

Member Data Documentation

◆ catchment_masks

std::map<size_t, mio::Grid2DObject> Runoff::catchment_masks
protected

◆ catchment_numbering

enum Runoff::NumberingType Runoff::catchment_numbering
protected

◆ catchment_out_path

std::string Runoff::catchment_out_path
protected

◆ DISTANCE_ABSOLUTE_PRECISION

const double Runoff::DISTANCE_ABSOLUTE_PRECISION = 1e-3
staticprotected

◆ extra_meteo_variables

std::vector<SnGrids::Parameters> Runoff::extra_meteo_variables
protected

◆ glacier_mask

mio::Grid2DObject Runoff::glacier_mask
protected

◆ grid_size_factor

double Runoff::grid_size_factor
protected

◆ io

mio::IOManager * Runoff::io
protected

◆ is_glacier_mask_dynamic

const bool Runoff::is_glacier_mask_dynamic
protected

◆ is_glacier_mask_set

bool Runoff::is_glacier_mask_set
protected

◆ MIN_CELL_SIZE

const double Runoff::MIN_CELL_SIZE = 5.0
staticprotected

◆ n_extra_meteo_variables

size_t Runoff::n_extra_meteo_variables
protected

◆ n_grid_cells

const size_t Runoff::n_grid_cells
protected

◆ output_grids

bool Runoff::output_grids
protected

◆ output_sums

bool Runoff::output_sums
protected

◆ resampling_cell_size

double Runoff::resampling_cell_size
protected

◆ slope_correction

const mio::Grid2DObject Runoff::slope_correction
protected

◆ snowpack

SnowpackInterface* Runoff::snowpack
protected

Reference to SnowpackInterface object, used for callbacks, initialized during construction.

◆ thresh_rain

const double Runoff::thresh_rain
protected

◆ timer

mio::Timer Runoff::timer
protected

◆ total_runoff

mio::Grid2DObject Runoff::total_runoff
protected

◆ tz_out

const double Runoff::tz_out
protected

◆ use_external_iomanager_for_grids

bool Runoff::use_external_iomanager_for_grids
protected

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