#include <cbmdisturbancelistener.h>
|
NotificationCenter * | _notificationCenter |
|
std::vector< std::string > | _layerNames |
|
std::vector< const flint::IVariable * > | _layers |
|
flint::IVariable * | _landClass |
|
flint::IVariable * | _spu |
|
flint::IVariable * | _classifierSet |
|
flint::IVariable * | _age |
|
EventMap | _matrices |
|
std::unordered_map< std::pair< int, std::string >, std::pair< int, int > > | _peatlandDmAssociations |
|
std::unordered_map< std::pair< std::string, int >, int > | _dmAssociations |
|
std::unordered_map< std::string, std::string > | _landClassTransitions |
|
std::map< int, std::vector< CBMDistEventRef > > | _landUnitEvents |
|
std::unordered_map< std::string, int > | _distTypeCodes |
|
std::unordered_map< int, std::string > | _distTypeNames |
|
std::unordered_set< std::string > | _errorLayers |
|
std::unordered_set< std::string > | _classifierNames |
|
std::unordered_map< std::string, int > | _disturbanceOrder |
|
bool | _disturbanceConditionsInitialized = false |
|
DynamicVar | _conditionConfig |
|
std::vector< DisturbanceCondition > | _disturbanceConditions |
|
std::shared_ptr< std::deque< DisturbanceHistoryRecord > > | _disturbanceHistory |
|
◆ EventMap
◆ EventVector
◆ CBMDisturbanceListener()
◆ ~CBMDisturbanceListener()
◆ addLandUnitEvent()
bool addLandUnitEvent |
( |
const DynamicVar & |
eventData | ) |
|
|
private |
If parameter eventData is not a structure, return
Get the disturbanceType using CBMDisturbanceListener.getDisturbanceTypeName(), year and transition Id from parameter eventData,
Extract DynamicObject from parameter eventData and store it in a variable event
If event has "conditions" and it is not empty, create a variable to store all the disturbance conditions
for every condition, assign variable varName to condition[0], target to condition[2], targetType to condition[1] that can either take values DisturbanceConditionType::LessThan, DisturbanceConditionType::AtLeast or DisturbanceConditionType::EqualTo
If varName is not found in CBMDisturbanceListener._classifierNames, instantiate an object of VariableDisturbanceSubCondition with CBMDisturbanceListener._classifierSet, targetType, target, varName,
else instantiate it with variable varName in _landUnitData, targetType, target and append it to conditions
Corresponding to the current year, instantiate an object of CBMDistEventRef with disturbanceType, year, transitionId, conditions, event and append it to CBMDisturbanceListener._landUnitEvents
- Parameters
-
- Returns
- bool
◆ configure()
void configure |
( |
const DynamicObject & |
config | ) |
|
|
override |
◆ createSubCondition()
Determine the various subconditions based on the configuration
An shared pointer of type IDisturbanceSubCondition, subConditions, is created to store all the subConditions
For each condition in parameter config, if the first element of the condition, (condition.first), is either "disturbance_type", "run_conditions", "override_conditions" or "override_disturbance_type", the next configuration object is checked
If condition.first is "disturbance_sequence", all the historical disturbances are added to an object of DisturbanceHistoryCondition. A shared pointer of DisturbanceSequenceSubCondition containing the timing, disturbance history and sequence of disturbance events is added to subConditions and the next condition is visited
Extract the comparison type (<, =, >=, <->, !=) and target of value of condition.second
If the condition is a single variable, the condition.first is present in _landUnitData, a shared pointer of VariableDisturbanceSubCondition is added to subConditions and the next condition is visited
Based on whether the condition is on one or more pools, a shared pointer of PoolDisturbanceSubCondition is added to subConditions and the next condition is visited
An object of CompositeDisturbanceSubCondition with the subConditions is returned
- Parameters
-
- Returns
- shared_ptr<IDisturbanceSubCondition>
◆ doDisturbanceEvent()
void doDisturbanceEvent |
( |
DynamicVar |
n | ) |
|
|
overridevirtual |
◆ doLocalDomainInit()
void doLocalDomainInit |
( |
| ) |
|
|
overridevirtual |
◆ doSystemShutdown()
void doSystemShutdown |
( |
| ) |
|
|
overridevirtual |
◆ doTimingInit()
◆ doTimingStep()
◆ fetchDistTypeCodes()
void fetchDistTypeCodes |
( |
| ) |
|
|
private |
Get disturbance type and disturbance type codes
If _landUnitData has the variable "disturbance_type_codes", for each code in variable "disturbance_type_codes", populate CBMDisturbanceListener._distTypeCodes mapping the "disturbance_type" to the "disturbance_type_code" and CBMDisturbanceListener.__distTypeNames mapping "disturbance_type_code" to the "disturbance_type"
- Returns
- void
◆ fetchDisturbanceOrder()
void fetchDisturbanceOrder |
( |
| ) |
|
|
private |
◆ fetchDMAssociations()
void fetchDMAssociations |
( |
| ) |
|
|
private |
For each dmAssociation in variable "disturbance_matrix_associations" of _landUnitData, insert the "disturbance_type", "spatial_unit_id" and "disturbance_matrix_id" as a pair of pairs into CBMDisturbanceListener._dmAssociations
- Returns
- void
◆ fetchLandClassTransitions()
void fetchLandClassTransitions |
( |
| ) |
|
|
private |
◆ fetchMatrices()
◆ fetchPeatlandDMAssociations()
void fetchPeatlandDMAssociations |
( |
| ) |
|
|
private |
If _landUnitData has variable "peatland_dm_associations", insert each dmAssociation in variable "peatland_dm_associations" with attributes "peatland_id", "disturbance_type", "peatland_dm_id" and "wtd_modifier_id" to CBMDisturbanceListener._peatlandDmAssociations
- Returns
- void
◆ fireCBMDisturbanceEvent()
Fire a CBM disturbance event.
If CBMDisturbanceListener._dmAssociations does not contain the key <disturbance type - from parameter e, spatial unit - value of CBMDisturbanceListener._spu >, return
If the disturbance type of parameter e transitions to a new land class, set CBMDisturbanceListener._landClass to the landClassTransition
Find the disturbance type code corresponding to the disturbance type of parameter e, else set it to 1
Add all transfers from CBMDisturbanceListener._matrices for the current disturbance id
Prepare the disturbance data object with attributes "disturbance" - e.disturbanceType() ,
"disturbance_type_code", "transfers" - disturbance matrix, "transition" - e.transitionRuleId()
Merge any additional metadata into disturbance data and fire the disturbance events
- Parameters
-
- Returns
- void
◆ firePeatlandDisturbanceEvent()
Fire a Peatland disturbance event.
If the disturbance type of parameter e transitions to a new land class, set CBMDisturbanceListener._landClass to the landClassTransition
Find the disturbance type code corresponding to the disturbance type of parameter e, else set it to 1
If disturbance is applied in this peatland, prepare the disturbance data object with "disturbance" - e.disturbanceType(),
"disturbance_type_code", "transition" - e.transitionRuleId(), "transfers" is a vector of CBMDistEventTransfer, which will be injected by peatland disturbance module
Merge any additional metadata into disturbance data and fire the disturbance events
- Parameters
-
- Returns
- void
◆ getDisturbanceTypeName()
std::string getDisturbanceTypeName |
( |
const DynamicObject & |
eventData | ) |
|
|
private |
Return disturbance type name
If the parameter eventData contains the variables "disturbance_type", "disturbance_id" check if CBMDisturbanceListener._distTypeNames has eventData["disturbance_type_id"] and the value of disturbance id corresponds to disturbance name
Else if, parameter eventData contains only "disturbance_id", check if check if CBMDisturbanceListener._distTypeNames has eventData["disturbance_type_id"]
Else report the absence of a disturbance name and id
- Parameters
-
- Returns
- string
◆ moduleType()
flint::ModuleTypes moduleType |
( |
| ) |
|
◆ subscribe()
void subscribe |
( |
NotificationCenter & |
notificationCenter | ) |
|
|
override |
Subscribe to the signals LocalDomainInit, SystemShutdown, TimingInit, DisturbanceEvent, and TimingStep.
- Parameters
-
notificationCenter | NotificationCenter& |
- Returns
- void
◆ _age
◆ _classifierNames
std::unordered_set<std::string> _classifierNames |
|
private |
◆ _classifierSet
flint::IVariable* _classifierSet |
|
private |
◆ _conditionConfig
DynamicVar _conditionConfig |
|
private |
◆ _distTypeCodes
std::unordered_map<std::string, int> _distTypeCodes |
|
private |
◆ _distTypeNames
std::unordered_map<int, std::string> _distTypeNames |
|
private |
◆ _disturbanceConditions
◆ _disturbanceConditionsInitialized
bool _disturbanceConditionsInitialized = false |
|
private |
◆ _disturbanceHistory
◆ _disturbanceOrder
std::unordered_map<std::string, int> _disturbanceOrder |
|
private |
◆ _dmAssociations
std::unordered_map<std::pair<std::string, int>, int> _dmAssociations |
|
private |
◆ _errorLayers
std::unordered_set<std::string> _errorLayers |
|
private |
◆ _landClass
flint::IVariable* _landClass |
|
private |
◆ _landClassTransitions
std::unordered_map<std::string, std::string> _landClassTransitions |
|
private |
◆ _landUnitEvents
◆ _layerNames
std::vector<std::string> _layerNames |
|
private |
◆ _layers
std::vector<const flint::IVariable*> _layers |
|
private |
◆ _matrices
◆ _notificationCenter
NotificationCenter* _notificationCenter |
|
private |
◆ _peatlandDmAssociations
std::unordered_map<std::pair<int, std::string>, std::pair<int, int> > _peatlandDmAssociations |
|
private |
◆ _spu
The documentation for this class was generated from the following files: