GCBM
Public Member Functions | Private Member Functions | Private Attributes | List of all members
CBMLandClassTransitionModule Class Reference

#include <cbmlandclasstransitionmodule.h>

Inheritance diagram for CBMLandClassTransitionModule:
Inheritance graph
Collaboration diagram for CBMLandClassTransitionModule:
Collaboration graph

Public Member Functions

 CBMLandClassTransitionModule ()
 
virtual ~CBMLandClassTransitionModule ()=default
 
void configure (const DynamicObject &config) override
 
void subscribe (NotificationCenter &notificationCenter) override
 
flint::ModuleTypes moduleType ()
 
virtual void doLocalDomainInit () override
 
virtual void doTimingInit () override
 
virtual void doTimingStep () override
 
- Public Member Functions inherited from CBMModuleBase
virtual ~CBMModuleBase ()=default
 
void onSystemInit () override
 
void onSystemShutdown () override
 
void onLocalDomainInit () override
 
void onLocalDomainShutdown () override
 
void onLocalDomainProcessingUnitInit () override
 
void onLocalDomainProcessingUnitShutdown () override
 
void onPreTimingSequence () override
 
void onTimingInit () override
 
void onTimingPrePostInit () override
 
void onTimingPostInit () override
 
void onTimingPostInit2 () override
 
void onTimingShutdown () override
 
void onTimingStep () override
 
void onTimingPreEndStep () override
 
void onTimingEndStep () override
 
void onTimingPostStep () override
 
void onOutputStep () override
 
void onPrePostDisturbanceEvent () override
 
void onPostDisturbanceEvent () override
 
void onPostDisturbanceEvent2 () override
 
void onError (std::string msg) override
 
void onDisturbanceEvent (DynamicVar e) override
 
void onPostNotification (short preMessageSignal) override
 
virtual void doSystemInit ()
 
virtual void doSystemShutdown ()
 
virtual void doLocalDomainShutdown ()
 
virtual void doLocalDomainProcessingUnitInit ()
 
virtual void doLocalDomainProcessingUnitShutdown ()
 
virtual void doPreTimingSequence ()
 
virtual void doTimingPrePostInit ()
 
virtual void doTimingPostInit ()
 
virtual void doTimingPostInit2 ()
 
virtual void doTimingShutdown ()
 
virtual void doTimingPreEndStep ()
 
virtual void doTimingEndStep ()
 
virtual void doTimingPostStep ()
 
virtual void doOutputStep ()
 
virtual void doError (std::string msg)
 
virtual void doDisturbanceEvent (DynamicVar)
 
virtual void doPrePostDisturbanceEvent ()
 
virtual void doPostDisturbanceEvent ()
 
virtual void doPostDisturbanceEvent2 ()
 
virtual void doPostNotification (short preMessageSignal)
 

Private Member Functions

void updateRemainingStatus (std::string landClass)
 
void setUnfcccLandClass ()
 
void fetchLandClassTransitions ()
 
std::string getCreationDisturbance ()
 

Private Attributes

flint::IVariable * _historicLandClass
 
flint::IVariable * _currentLandClass
 
flint::IVariable * _unfcccLandClass
 
flint::IVariable * _isForest
 
flint::IVariable * _lastPassDisturbance
 
flint::IVariable * _isDecaying
 
flint::IVariable * _lastPassDisturbanceTimeseries = nullptr
 
std::unordered_map< std::string, bool > _landClassForestStatus
 
std::unordered_map< std::string, int > _landClassElapsedTime
 
std::unordered_map< std::string, std::string > _landClassTransitions
 
std::string _lastCurrentLandClass
 
int _yearsSinceTransition = 0
 

Constructor & Destructor Documentation

◆ CBMLandClassTransitionModule()

◆ ~CBMLandClassTransitionModule()

virtual ~CBMLandClassTransitionModule ( )
virtualdefault

Member Function Documentation

◆ configure()

void configure ( const DynamicObject &  config)
override

Configuration function.

Parameters
configDynamicObject&
Returns
void

◆ doLocalDomainInit()

void doLocalDomainInit ( )
overridevirtual

Initialise a constant variable landClasses as land_class_data variable value.
If landClasses is a vector, Initialise a constant variable allTransistions as landClasses (vector<DynamicObject>).
For each constant variable row in allTransistions, assign CBMLandClassTransitionModule._landClassForestStatus[row["land_class"]] as row["is_forest"] and
CBMLandClassTransitionModule._landClassElapsedTime[row["land_class"]] as row["years_to_permanent"].
If not, assign CBMLandClassTransitionModule._landClassForestStatus[landClasses["land_class"]] as landClasses["is_forest"] and
CBMLandClassTransitionModule._landClassElapsedTime[landClasses["land_class"]] as landClasses["years_to_permanent"].

Initialise CBMLandClassTransitionModule._isForest,CBMLandClassTransitionModule._isDecaying,CBMLandClassTransitionModule._historicLandClass,
CBMLandClassTransitionModule._currentLandClass and CBMLandClassTransitionModule._unfcccLandClass.

if _landUnitData has variable last_pass_disturbance_timeseries, initialise CBMLandClassTransitionModule._lastPassDisturbanceTimeseries.
Invoke fetchLandClassTransitions().

Returns
void

Reimplemented from CBMModuleBase.

◆ doTimingInit()

void doTimingInit ( )
overridevirtual

Set initial decay status

Assign CBMLandClassTransitionModule._lastCurrentLandClass as CBMLandClassTransitionModule._currentLandClass value (string).
Invoke CBMLandClassTransitionModule.setUnfcccLandClass(), set CBMLandClassTransitionModule._yearsSinceTransition to 0
Set the initial stand decaying status. The carbon in a stand always decays unless the stand is initially a non-forest land class and the last-pass disturbance was not a deforestation event - i.e. a non-forest stand that will be afforested at some point has its decay paused until then
If the value of CBMLandClassTransitionModule._isForest is false and land was deforested in spinup, then set CBMLandClassTransitionModule._isDecaying to false, else set it to true

Returns
void

Reimplemented from CBMModuleBase.

◆ doTimingStep()

void doTimingStep ( )
overridevirtual

Iterate CBMLandClassTransitionModule.yearsSinceTransition by 1;
Initialise string varaible currentLandClass as CBMLandClassTransitionModule._currentLandClass value.
if currentLandClass is equal to CBMLandClassTransitionModule._lastCurrentLandClass, invoke updateRemainigStatus() using currentLandClass as a parameter and
End program.

Assign CBMLandClassTransitionModule._historicLandClass as CBMLandClassTransitionModule._landCurrentLandClass.
Assign CBMLandClassTransitionModule._lastCurrentLandClass as currentLandClass.
Invoke CBMLandClassTransitionModule.setUnfcccLandClass();
Assign CBMLandClassTransitionModule._yearsSinceTransition as 0.
Set CBMLandClassTransitionModule._isDecaying to true.

Returns
void

Reimplemented from CBMModuleBase.

◆ fetchLandClassTransitions()

void fetchLandClassTransitions ( )
private

Insert the values of "disturbance_type" and "land_class_transition" as a pair in "land_class_transitions" from variable _landUnitData into CBMLandClassTransitionModule._landClassTransitions

Returns
void

◆ getCreationDisturbance()

std::string getCreationDisturbance ( )
private

If CBMLandClassTransitionModule._lastPassDisturbanceTimeseries is not equal to nullptr,
initialise constant variable lastPassTimeseries as CBMLandClassTransitionModule._lastPassDisturbanceTimeSeries value.
if lastPassTimeseries is not empty, initialise integer variable maxYear as -1.
Initialise string variable creationDisturbance.
For each constant variable event in lastPassTimeseries (vector<DynamicObject>),
initalise integer variable year as event["year"].
if year is greater than maxYear, assign maxYear as year and creationDisturbance as event["disturbance_type"] (string)
return creationDisturbance.
else, initialise a constant variable spinup as spinup_parameters value and spinupParams as spinup (DynamicObject).
return spinupParams["last_pass_disturbance_type"](string).

Returns
string

◆ moduleType()

flint::ModuleTypes moduleType ( )

◆ setUnfcccLandClass()

void setUnfcccLandClass ( )
private

◆ subscribe()

void subscribe ( NotificationCenter &  notificationCenter)
override

Subscribe to the signals LocalDomainInit, TimingInit and TimingStep.

Parameters
notificationCenterNotificationCenter&
Returns
void

◆ updateRemainingStatus()

void updateRemainingStatus ( std::string  landClass)
private

If the parameter landClass is the same as CBMLandClassTransitionModule._historicLandClass, return
If the value of parameter landClass CBMLandClassTransitionModule._landClassElapsedTime is > CBMLandClassTransitionModule.targetYears, set the value of _historicLandClass to landClass and invoke CBMLandClassTransitionModule.setUnfcccLandClass()

Parameters
landClassstring
Returns
void

Member Data Documentation

◆ _currentLandClass

flint::IVariable* _currentLandClass
private

◆ _historicLandClass

flint::IVariable* _historicLandClass
private

◆ _isDecaying

flint::IVariable* _isDecaying
private

◆ _isForest

flint::IVariable* _isForest
private

◆ _landClassElapsedTime

std::unordered_map<std::string, int> _landClassElapsedTime
private

◆ _landClassForestStatus

std::unordered_map<std::string, bool> _landClassForestStatus
private

◆ _landClassTransitions

std::unordered_map<std::string, std::string> _landClassTransitions
private

◆ _lastCurrentLandClass

std::string _lastCurrentLandClass
private

◆ _lastPassDisturbance

flint::IVariable* _lastPassDisturbance
private

◆ _lastPassDisturbanceTimeseries

flint::IVariable* _lastPassDisturbanceTimeseries = nullptr
private

◆ _unfcccLandClass

flint::IVariable* _unfcccLandClass
private

◆ _yearsSinceTransition

int _yearsSinceTransition = 0
private

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