hydrobricks
Loading...
Searching...
No Matches
Logger Class Reference

#include <Logger.h>

Public Member Functions

void InitContainers (int timeSize, const std::vector< Subbasin * > &subbasins, SettingsModel &modelSettings)
 
void Reset ()
 
void SetSubbasinValuePointer (int iSubbasin, int iLabel, double *valPt)
 
void SetHydroUnitValuePointer (int iUnit, int iLabel, double *valPt)
 
void SetHydroUnitFractionPointer (int iUnit, int iLabel, double *valPt)
 
void SetHydroUnitLabelBasis (int iLabel, const string &basis)
 
void SetDate (double date)
 
void SaveInitialValues ()
 
void Record ()
 
void Increment ()
 
bool DumpOutputs (const string &path)
 
axd GetOutletDischarge () const
 
axd GetSubbasinDischarge (int subbasinId) const
 
vecInt GetIndicesForSubbasinElements (const string &item) const
 
vecInt GetIndicesForHydroUnitElements (const string &item) const
 
double GetTotalSubbasin (const string &item) const
 
double GetTotalHydroUnits (const string &item, bool needsAreaWeighting=false) const
 
double GetTotalOutletDischarge () const
 
double GetTotalET () const
 
double GetSubbasinInitialStorageState (const string &tag) const
 
double GetSubbasinFinalStorageState (const string &tag) const
 
int GetFractionIndexForComponent (const string &componentName) const
 
double GetHydroUnitsInitialStorageState (const string &tag) const
 
double GetHydroUnitsFinalStorageState (const string &tag) const
 
double GetTotalWaterStorageChanges () const
 
double GetTotalSnowStorageChanges () const
 
double GetTotalGlacierStorageChanges () const
 
vecAxd GetSubbasinValues () const
 
const vecAxxd & GetSubbasinValuesPerSubbasin () const
 
const vecAxxd & GetHydroUnitValues () const
 
const axd & GetTime () const
 
const vecInt & GetSubbasinIds () const
 
const vecInt & GetSubbasinDownstreamIds () const
 
const vecInt & GetSubbasinStructureIds () const
 
const axd & GetSubbasinLocalAreas () const
 
const axd & GetSubbasinDrainedAreas () const
 
int GetSubbasinCount () const
 
const vecInt & GetHydroUnitIds () const
 
const axd & GetHydroUnitAreas () const
 
const vecStr & GetSubbasinLabels () const
 
const vecStr & GetHydroUnitLabels () const
 
const vecStr & GetHydroUnitFractionLabels () const
 
const vecAxxd & GetHydroUnitFractions () const
 
const vecStr & GetHydroUnitLabelBases () const
 
const axd & GetHydroUnitSubbasinFractions () const
 
void RecordFractions ()
 
void AddSubbasinEtIndex (int iLabel)
 
void AddHydroUnitEtIndex (int iLabel)
 

Protected Attributes

int _cursor
 
axd _time
 
bool _recordFractions
 
vecInt _subbasinIds
 
vecInt _subbasinDownstreamIds
 
vecInt _subbasinStructureIds
 
axd _subbasinLocalAreas
 
axd _subbasinDrainedAreas
 
axd _subbasinWeights
 
int _outletIndex
 
vecStr _subbasinLabels
 
vecAxd _subbasinInitialValues
 
vecAxxd _subbasinValues
 
vector< vecDoublePt > _subbasinValuesPt
 
vecInt _hydroUnitIds
 
vecInt _hydroUnitStructureIds
 
axd _hydroUnitAreas
 
vecStr _hydroUnitLabels
 
vecStr _hydroUnitLabelBases
 
axd _hydroUnitSubbasinFractions
 
vecAxd _hydroUnitInitialValues
 
vecAxxd _hydroUnitValues
 
vector< vecDoublePt > _hydroUnitValuesPt
 
vecStr _hydroUnitFractionLabels
 
vecAxxd _hydroUnitFractions
 
vector< vecDoublePt > _hydroUnitFractionsPt
 
vecInt _subbasinEtIndices
 
vecInt _hydroUnitEtIndices
 

Detailed Description

Records the model values over time: the subbasin (aggregated) values per subbasin, and the hydro unit (distributed) values per unit. The subbasins are indexed in processing order (upstream first, the outlet last); the hydro units are indexed globally, in the order of the subbasins.

Member Function Documentation

◆ AddHydroUnitEtIndex()

void Logger::AddHydroUnitEtIndex ( int iLabel)
inline

Tag a hydro unit log label index as an evapotranspiration (to-atmosphere) flux.

Parameters
iLabelindex of the hydro unit label.

◆ AddSubbasinEtIndex()

void Logger::AddSubbasinEtIndex ( int iLabel)

Tag a subbasin log label index as an evapotranspiration (to-atmosphere) flux. A label is tagged once (the same structure is built in every subbasin).

Parameters
iLabelindex of the subbasin label.

◆ DumpOutputs()

bool Logger::DumpOutputs ( const string & path)

Dump the outputs to a file.

Parameters
pathpath to the output file.
Returns
true if the dump was successful, false otherwise.

◆ GetFractionIndexForComponent()

int Logger::GetFractionIndexForComponent ( const string & componentName) const
nodiscard

Find the land-cover fraction series that weights a logged hydro-unit component to a basin (area) average. A component is matched to its land cover by name: the land cover itself (<cover>:) or one of its surface components (<cover>_snowpack:, <cover>_canopy:). Returns the index into _hydroUnitFractions or -1 if the component is not tied to a land cover (then a fraction of one applies, i.e. it spans the whole unit).

Parameters
componentNamethe logged component label (e.g. "forest_canopy:water_content").
Returns
the fraction index, or -1 if none.

◆ GetHydroUnitAreas()

const axd & Logger::GetHydroUnitAreas ( ) const
inline

Get the hydro unit areas.

Returns
vector of hydro unit areas.

◆ GetHydroUnitFractionLabels()

const vecStr & Logger::GetHydroUnitFractionLabels ( ) const
inline

Get the hydro unit fraction labels.

Returns
vector of fraction labels.

◆ GetHydroUnitFractions()

const vecAxxd & Logger::GetHydroUnitFractions ( ) const
inline

Get the hydro unit fractions.

Returns
vector of fraction arrays.

◆ GetHydroUnitIds()

const vecInt & Logger::GetHydroUnitIds ( ) const
inline

Get the hydro unit IDs.

Returns
vector of hydro unit IDs.

◆ GetHydroUnitLabelBases()

const vecStr & Logger::GetHydroUnitLabelBases ( ) const
inline

Get the area basis of each hydro unit label ("land_cover", "hydro_unit" or "subbasin").

Returns
vector of area bases, one per hydro unit label.

◆ GetHydroUnitLabels()

const vecStr & Logger::GetHydroUnitLabels ( ) const
inline

Get the hydro unit labels.

Returns
vector of hydro unit labels.

◆ GetHydroUnitsFinalStorageState()

double Logger::GetHydroUnitsFinalStorageState ( const string & tag) const
nodiscard

Get the final storage state of a hydro unit for a given tag.

Parameters
tagtag to search for.
Returns
final storage state.

◆ GetHydroUnitsInitialStorageState()

double Logger::GetHydroUnitsInitialStorageState ( const string & tag) const
nodiscard

Get the initial storage state of a hydro unit for a given tag.

Parameters
tagtag to search for.
Returns
initial storage state.

◆ GetHydroUnitSubbasinFractions()

const axd & Logger::GetHydroUnitSubbasinFractions ( ) const
inline

Get the share of its subbasin's area covered by each hydro unit (unit area / subbasin area).

Returns
vector of area fractions, one per hydro unit.

◆ GetHydroUnitValues()

const vecAxxd & Logger::GetHydroUnitValues ( ) const
inline

Get all the hydro unit values.

Returns
vector of hydro unit values.

◆ GetIndicesForHydroUnitElements()

vecInt Logger::GetIndicesForHydroUnitElements ( const string & item) const
nodiscard

Get the indices of the hydro unit elements for a given item.

Parameters
itemitem to search for.
Returns
vector of indices.

◆ GetIndicesForSubbasinElements()

vecInt Logger::GetIndicesForSubbasinElements ( const string & item) const
nodiscard

Get the indices of the subbasin elements for a given item.

Parameters
itemitem to search for.
Returns
vector of indices.

◆ GetOutletDischarge()

axd Logger::GetOutletDischarge ( ) const
nodiscard

Get the outlet discharge series at the catchment outlet (the terminal subbasin), in mm over the drained area.

Returns
outlet discharge series.

◆ GetSubbasinCount()

int Logger::GetSubbasinCount ( ) const
inlinenodiscard

Get the number of subbasins.

Returns
number of subbasins.

◆ GetSubbasinDischarge()

axd Logger::GetSubbasinDischarge ( int subbasinId) const
nodiscard

Get the discharge series at the outlet of a subbasin, in mm over its drained area.

Parameters
subbasinIdID of the subbasin.
Returns
discharge series.

◆ GetSubbasinDownstreamIds()

const vecInt & Logger::GetSubbasinDownstreamIds ( ) const
inline

Get the downstream subbasin IDs (0 for the catchment outlet).

Returns
vector of downstream subbasin IDs.

◆ GetSubbasinDrainedAreas()

const axd & Logger::GetSubbasinDrainedAreas ( ) const
inline

Get the areas drained at the subbasin outlets (own plus upstream) [m2].

Returns
vector of drained areas.

◆ GetSubbasinFinalStorageState()

double Logger::GetSubbasinFinalStorageState ( const string & tag) const
nodiscard

Get the final storage state of the subbasins for a given tag (area-weighted over the subbasins).

Parameters
tagtag to search for.
Returns
final storage state.

◆ GetSubbasinIds()

const vecInt & Logger::GetSubbasinIds ( ) const
inline

Get the subbasin IDs (processing order, the outlet last).

Returns
vector of subbasin IDs.

◆ GetSubbasinInitialStorageState()

double Logger::GetSubbasinInitialStorageState ( const string & tag) const
nodiscard

Get the initial storage state of the subbasins for a given tag (area-weighted over the subbasins).

Parameters
tagtag to search for.
Returns
initial storage state.

◆ GetSubbasinLabels()

const vecStr & Logger::GetSubbasinLabels ( ) const
inline

Get the subbasin labels.

Returns
vector of subbasin labels.

◆ GetSubbasinLocalAreas()

const axd & Logger::GetSubbasinLocalAreas ( ) const
inline

Get the local areas of the subbasins (their own hydro units) [m2].

Returns
vector of local areas.

◆ GetSubbasinStructureIds()

const vecInt & Logger::GetSubbasinStructureIds ( ) const
inline

Get the structure variant used by each subbasin's catchment-level components (processing order).

Returns
vector of structure IDs.

◆ GetSubbasinValues()

vecAxd Logger::GetSubbasinValues ( ) const
nodiscard

Get all the subbasin values at the catchment outlet (the terminal subbasin).

Returns
vector of subbasin values (one series per label).

◆ GetSubbasinValuesPerSubbasin()

const vecAxxd & Logger::GetSubbasinValuesPerSubbasin ( ) const
inline

Get all the subbasin values of every subbasin.

Returns
vector of subbasin values: one matrix per label, of shape (time steps x subbasins), the subbasins in processing order.

◆ GetTime()

const axd & Logger::GetTime ( ) const
inline

Get the time series.

Returns
time series vector.

◆ GetTotalET()

double Logger::GetTotalET ( ) const
nodiscard

Get the total ET over time.

Returns
total ET.

◆ GetTotalGlacierStorageChanges()

double Logger::GetTotalGlacierStorageChanges ( ) const
nodiscard

Get the total glacier storage changes.

Returns
the total glacier storage changes.

◆ GetTotalHydroUnits()

double Logger::GetTotalHydroUnits ( const string & item,
bool needsAreaWeighting = false ) const
nodiscard

Get the sum of hydro unit values for a given item.

Parameters
itemitem to search for.
needsAreaWeightingif true, area weighting is applied.
Returns
total value.

◆ GetTotalOutletDischarge()

double Logger::GetTotalOutletDischarge ( ) const
nodiscard

Get the total outlet discharge over time (at the catchment outlet).

Returns
total outlet discharge.

◆ GetTotalSnowStorageChanges()

double Logger::GetTotalSnowStorageChanges ( ) const
nodiscard

Get the total snow storage changes.

Returns
the total snow storage changes.

◆ GetTotalSubbasin()

double Logger::GetTotalSubbasin ( const string & item) const
nodiscard

Get the sum of a subbasin values for a given item, over time and over the subbasins (each weighted by its local area, so the total is in mm over the catchment area).

Parameters
itemitem to search for.
Returns
total value.

◆ GetTotalWaterStorageChanges()

double Logger::GetTotalWaterStorageChanges ( ) const
nodiscard

Get the total water storage changes.

Returns
the total water storage changes.

◆ Increment()

void Logger::Increment ( )

Increment the cursor to the next time step.

◆ InitContainers()

void Logger::InitContainers ( int timeSize,
const std::vector< Subbasin * > & subbasins,
SettingsModel & modelSettings )

Initialize the logger with the size of the time vector and the subbasins.

Parameters
timeSizesize of the time vector.
subbasinsthe subbasins in processing order (upstream first, the outlet last).
modelSettingssettings of the model.

◆ Record()

void Logger::Record ( )

Record the current values in the logger.

◆ RecordFractions()

void Logger::RecordFractions ( )
inline

Activate the recording of fractions.

◆ Reset()

void Logger::Reset ( )

Reset the logger.

◆ SaveInitialValues()

void Logger::SaveInitialValues ( )

Save the current values as initial values.

◆ SetDate()

void Logger::SetDate ( double date)

Set the date in the logger.

Parameters
datedate to set.

◆ SetHydroUnitFractionPointer()

void Logger::SetHydroUnitFractionPointer ( int iUnit,
int iLabel,
double * valPt )

Set a hydro unit fraction pointer in the logger array.

Parameters
iUnitindex of the hydro unit (global, over all the subbasins).
iLabelindex of the hydro unit label.
valPtpointer to the value.

◆ SetHydroUnitLabelBasis()

void Logger::SetHydroUnitLabelBasis ( int iLabel,
const string & basis )

Set the area a hydro unit label is expressed over: "land_cover" (a land cover or one of its surface components, over its own area), "hydro_unit" (over the hydro unit) or "subbasin" (a flux delivered to the outlet or to a subbasin brick, over the subbasin's local area).

Parameters
iLabelindex of the hydro unit label.
basisthe area basis.

◆ SetHydroUnitValuePointer()

void Logger::SetHydroUnitValuePointer ( int iUnit,
int iLabel,
double * valPt )

Set a hydro unit value pointer in the logger array.

Parameters
iUnitindex of the hydro unit (global, over all the subbasins).
iLabelindex of the hydro unit label.
valPtpointer to the value.

◆ SetSubbasinValuePointer()

void Logger::SetSubbasinValuePointer ( int iSubbasin,
int iLabel,
double * valPt )

Set a subbasin value pointer in the logger array.

Parameters
iSubbasinindex of the subbasin (processing order).
iLabelindex of the subbasin label.
valPtpointer to the value.

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