SORTIE Core C++ Documentation
|
Spatial disperse with masting - Version 1.0. More...
#include <MastingSpatialDisperse.h>
Public Member Functions | |
clMastingSpatialDisperse (clSimManager *p_oSimManager) | |
Constructor. More... | |
~clMastingSpatialDisperse () | |
Destructor. More... | |
mastEvent | GetMastEvent (int iSp) |
Get whether a given species masted this timestep. More... | |
int | GetTimestepsSinceLastMast (int iSp) |
Gets the number of years since the last mast for a species. More... | |
float | GetMastCDF (int sp, int yr) |
Gets the value of the masting cumulative distribution function at a particular point. More... | |
int | GetMaxTimesteps () |
Get max timesteps. More... | |
Public Member Functions inherited from clDisperseBase | |
clDisperseBase (clSimManager *p_oSimManager) | |
Constructor. More... | |
virtual | ~clDisperseBase () |
Destroys common objects. More... | |
void | Action () |
Performs all disperse calculations. More... | |
void | TimestepCleanup () |
Resets all values in the seed grid to 0 and sets the static m_bUpdatedGapStatus to false if this is a hooked object. More... | |
Public Member Functions inherited from clBehaviorBase | |
virtual float | GetBehaviorVersion () |
Gets the behavior version number. More... | |
clBehaviorBase (clSimManager *p_oSimManager) | |
Constructor. More... | |
virtual | ~clBehaviorBase () |
Destructor. More... | |
virtual short int | ValidateVersionNumber (float fTestVersion) |
Makes sure that the version number of a file passed is between the minimum and current version numbers. More... | |
virtual void | RegisterTreeDataMembers () |
Registers tree data members. More... | |
virtual void | SetSpeciesTypeCombos (short int iNumCombos, stcSpeciesTypeCombo *p_whatCombos) |
Sets the species/type combos for a behavior. More... | |
virtual void | SetNameData (std::string sNameString) |
Sets the string for the parameter file behavior. More... | |
virtual short int | GetNewTreeInts () |
Gets the number of new tree integer data members this behavior wants to register. More... | |
virtual short int | GetNewTreeFloats () |
Gets the number of new tree float data members this behavior wants to register. More... | |
virtual short int | GetNewTreeChars () |
Gets the number of new tree character data members this behavior wants to register. More... | |
virtual short int | GetNewTreeBools () |
Gets the number of new tree bool data members this behavior wants to register. More... | |
virtual short int | GetNumSpeciesTypeCombos () |
Gets the number of species/type combos to which this behavior applies. More... | |
virtual short int | GetNumBehaviorSpecies () |
Gets the number of unique tree species to which this behavior applies. More... | |
struct stcSpeciesTypeCombo | GetSpeciesTypeCombo (short int iIndex) |
Gets one of this behavior's type/species combos. More... | |
virtual short int | GetBehaviorSpecies (short int iIndex) |
Gets one of the behavior's species. More... | |
short int | GetBehaviorListNumber () |
Gets the behavior list number for this behavior, which differentiates between multiple copies of the behavior in the behavior list. More... | |
void | SetBehaviorListNumber (short int iNumber) |
Sets the behavior list number for this behavior, which differentiates between multiple copies of the behavior in the behavior list. More... | |
std::string | FormatSpeciesTypeQueryString () |
Formats the string for species/types query. More... | |
virtual DOMElement * | GetParentParametersElement (xercesc::DOMDocument *p_oDoc) |
This will get the correct set of parameters for this behavior based on the behavior list position number. More... | |
Public Member Functions inherited from clWorkerBase | |
clWorkerBase (clSimManager *p_oSimManager) | |
Constructor. More... | |
virtual | ~clWorkerBase () |
Destructor. More... | |
std::string | GetName () |
Gets the object's namestring. More... | |
clSimManager * | GetSimManager () |
void | DoObjectSetup (xercesc::DOMDocument *p_oDoc, fileType iFileType) |
Triggers the setup process. More... | |
virtual void | EndOfRunCleanup () |
Performs any necessary cleanup operations at the end of a run. More... | |
Protected Types | |
typedef float(clMastingSpatialDisperse::* | Ptr2GetNumberOfSeeds) (const float &, const short int &) |
Define a type for pointers to functions of the GetNumberOfSeeds type. More... | |
Protected Types inherited from clDisperseBase | |
enum | function { weibull, lognormal } |
What PDF is used by a species. More... | |
enum | cover { gap, canopy } |
Cover status. More... | |
Protected Member Functions | |
void | DoShellSetup (xercesc::DOMDocument *p_oDoc) |
Does setup. More... | |
void | CalcMastCDF (xercesc::DOMDocument *p_oDoc) |
Calculates the masting cumulative distribution function. More... | |
void | CalcSeedCDF (xercesc::DOMDocument *p_oDoc, clTreePopulation *p_oPop) |
Calculates the cumulative distribution functions for seed dispersal. More... | |
void | FormatQueryString (clTreePopulation *p_oPop) |
Formats the string in m_cQuery. More... | |
void | DisperseOneParentSeeds (clTree *p_oTree, clTreePopulation *p_oPop, clPlot *p_oPlot, float fDbh) |
Performs dispersal of seeds for one tree. More... | |
void | GetParameterFileData (xercesc::DOMDocument *p_oDoc, clTreePopulation *p_oPop) |
Extracts needed parameter file data. More... | |
void | PopulateUsedTable (clTreePopulation *p_oPop) |
Declares and populates the mp_bIsUsed array. More... | |
void | SetGetSeedsFunctionPointers () |
This figures out how each species's number of seeds is calculated. More... | |
void | CalculateProbabilityDistribution (float *p_fProbArray, const int &iMaxDistance, const function &iFunction, const float &fDispersalX0, const float &fThetaXb) |
Calculates the normalized probability distribution for a function for one species. More... | |
void | AddSeeds () |
Performs disperse. More... | |
void | DecideMast () |
Decides whether masting events occur for each species. More... | |
float | GetNumberOfSeedsNoDraw (const float &fDbh, const short int &iSp) |
Gets the number of seeds for a tree when there does not need to be an STR draw. More... | |
float | GetNumberOfSeedsDrawNormal (const float &fDbh, const short int &iSp) |
Gets the number of seeds for a tree when the tree needs a normal STR draw. More... | |
float | GetNumberOfSeedsDrawLognormal (const float &fDbh, const short int &iSp) |
Gets the number of seeds for a tree when the tree needs a lognormal STR draw. More... | |
Protected Member Functions inherited from clDisperseBase | |
void | GetData (xercesc::DOMDocument *p_oDoc) |
Triggers all disperse setup if an object is hooked. More... | |
void | SetUpBase () |
Does disperse base setup. More... | |
Protected Member Functions inherited from clWorkerBase | |
void | AssembleFileCode (int iFileType, int iFileVersion, char *cCode) |
Creates the proper identifying filecode for an XML file. More... | |
Protected Attributes | |
float *** | mp_fSeedCDF |
For testing. More... | |
double ** | mp_fStrMean |
STR mean (or STR value if deterministic). More... | |
double ** | mp_fStrStdDev |
STR standard deviation. More... | |
double ** | mp_fBeta |
Beta parameter. More... | |
float ** | mp_fMastCDF |
Masting cumulative distribution function. More... | |
double ** | mp_fFractionParticipating |
Fraction participating in disperse. More... | |
bool ** | mp_bIsUsed |
Whether this behavior is used by a species/type combo. More... | |
float * | mp_fFecundity |
Fecundity, if it is possible to pre-calculate it. More... | |
double * | mp_fDbhForReproduction |
Array of species with each one's dbh for reproduction. More... | |
int * | mp_iTimestepsSinceLastMast |
Number of years since the last mast for each species. More... | |
short int * | mp_iIndexes |
This will speed access to the other arrays by storing each species' array index so the other arrays only have to be as big as the number of unique species for this behavior. More... | |
short int * | mp_iGroup |
Group affiliation of the species. More... | |
pdf * | mp_iWhatPDFForSTR |
What PDF is used to draw the STR. More... | |
function * | mp_iWhatFunction |
Which function is used by species. More... | |
bool * | mp_bDrawSTRPerSpecies |
Whether to draw STR once per species (true) or once per tree (false). More... | |
enum mastEvent * | mp_iEvent |
Which event is occurring in the current timestep for each species. More... | |
char * | m_cQuery |
Query to perform to search for trees. More... | |
Ptr2GetNumberOfSeeds * | mp_GetSeeds |
Function pointer array for the appropriate function for calculating the number of seeds. More... | |
int | m_iNumYearsPerTimestep |
Number of years per timestep. More... | |
int | m_iMaxDistance |
Maximum distance, in meters, a seed can disperse - which is the maximum dimension of the grid with max of 1000 m. More... | |
int | m_iMaxTimesteps |
Maximum timesteps before a masting event occurs after a first masting event. More... | |
Protected Attributes inherited from clDisperseBase | |
bool | m_bHooked |
Protected Attributes inherited from clBehaviorBase | |
short int | m_iNumSpeciesTypeCombos |
How many type/species combos a behavior will act on. More... | |
short int | m_iNumBehaviorSpecies |
How many distinct species are in the combo list - important for filling species-specific values from parameter file. More... | |
short int * | mp_iWhatSpecies |
List of distinct species - for filling species-specific values from parameter file. More... | |
stcSpeciesTypeCombo * | mp_whatSpeciesTypeCombos |
Array of species/type combos that the behavior will act on. More... | |
short int | m_iNewTreeInts |
The number of new tree integer data members this behavior wants to add. More... | |
short int | m_iNewTreeFloats |
The number of new tree float data members this behavior wants to add. More... | |
short int | m_iNewTreeChars |
The number of new tree character data members this behavior wants to add. More... | |
short int | m_iNewTreeBools |
The number of new tree boolean data members this behavior wants to add. More... | |
short int | m_iBehaviorListNumber |
The number of this behavior in the behavior list, to differentiate between possible multiple copies of this behavior. More... | |
float | m_fVersionNumber |
Version number - this will be rounded to 2 digits after the decimal place. More... | |
std::string | m_sXMLRoot |
XML root that encloses the parameters for this behavior. More... | |
float | m_fMinimumVersionNumber |
Minimum version number - this behavior will run parameter data for a file marked between this number and the current version number, inclusive. More... | |
Protected Attributes inherited from clWorkerBase | |
std::string | m_sNameString |
If a behavior has registered a command line command with the sim manager, this allows it to be called. More... | |
clSimManager * | mp_oSimManager |
Pointer to the simulation manager object. More... | |
int * | mp_iAllowedFileTypes |
List of the input file types this object can handle. More... | |
int | m_iNumAllowedTypes |
Number of input file types this object can handle. More... | |
Friends | |
class | clTestMastingSpatialDisperse |
Additional Inherited Members | |
Static Protected Attributes inherited from clDisperseBase | |
static clDisperseOrg * | mp_oDisperseOrg |
clDisperseOrg object - this pointer is held in common by all shells More... | |
static clGrid * | mp_oSeedGrid |
Seed grid. More... | |
static short int * | mp_iNumSeedsCode |
Data member codes for "dispersed seeds" grid for "seeds_x" data member. More... | |
static short int | m_iGapCountCode |
Data member code - for counting trees for gap status. More... | |
static short int | m_iIsGapCode |
Data member code for substrate grid for gap status. More... | |
static short int | m_iTotalSpecies |
Total number of species. More... | |
static bool | m_bUpdatedGapStatus |
A flag indicating whether or not the gap status of the seed grid has been updated this timestep. More... | |
static bool | m_bIsStochastic |
Whether dispersal is stochastic (true) or deterministic (false). More... | |
Spatial disperse with masting - Version 1.0.
This class creates and disperses seeds according to the spatially-explicit model, allowing for masting events.
Masting is controlled by the cumulative distribution function: y = 1/(1 + (X / a)^b) where X is the time in years since the last mast, and a and b are parameters. The first timestep, X = 1. A random number compared to the probability distribution decides whether a mast has occurred.
The species may be organized into groups to create synchrony in masting. There can be up to N groups, where N is the number of species. If one species in a group masts, all species in the group do. Each group's mast decision is made separately, so sometimes more than one group may mast at a time.
There is a parameter for each species with the percentage of trees that participate in disperse (as a separate percentage for masting and non- masting). The set of trees, from those of above the minimum reproductive DBH, is randomly chosen each timestep.
The STR for trees can be chosen from a probability distribution function or not. It can be drawn once per species or once per tree. There are different STRs for masting and non-masting timesteps.
Once the number of seeds for a given tree has been calculated, the seeds are dispersed around the plot according to either the Weibull or Lognormal probability distribution functions.
The "seeds" are actually tallies by species in a grid. This behavior does not produce any seedlings. A separate recruitment behavior must "germinate" the seeds into seedlings according to its own rules.
The parameter file call string and namestring are both "MastingSpatialDisperse".
Copyright 2011 Charles D. Canham.
Edit history:
--------------—
October 20, 2011 - Wiped the slate clean for SORTIE 7.0 (LEM)
|
protected |
Define a type for pointers to functions of the GetNumberOfSeeds type.
clMastingSpatialDisperse::clMastingSpatialDisperse | ( | clSimManager * | p_oSimManager | ) |
Constructor.
p_oSimManager | Sim Manager object. |
clMastingSpatialDisperse::~clMastingSpatialDisperse | ( | ) |
Destructor.
|
protectedvirtual |
Performs disperse.
First, DecideMast() is called to determine which species mast this timestep. Then, for any species with STRs that are drawn per species, fecundity is calculated. Then this gets the group of trees to which this behavior applies. For each, a random number is compared to the appropriate value in mp_fFractionParticipating to determine whether this tree will produce seeds. That tree is passed to DisperseOneParentSeeds() for seed creation and distribution.
Implements clDisperseBase.
|
protected |
Calculates the masting cumulative distribution function.
This reads in the appropriate parameter values, finds the maximum number of years between mast events, then creates the CDF array. The parameters are thrown away because they are no longer needed.
p_oDoc | DOM tree of parsed input file. |
|
protected |
Calculates the cumulative distribution functions for seed dispersal.
This reads in the appropriate parameter values, finds the maximum seed dispersal distance, then creates the CDF array. The parameters are thrown away because they are no longer needed.
p_oDoc | DOM tree of parsed input file. |
p_oPop | Tree population object. |
stcErr | if a weibull theta value is not less than 50 (to prevent pow overflows) |
|
protected |
Calculates the normalized probability distribution for a function for one species.
p_fProbArray | The array into which to put the normalized values. |
iMaxDistance | The maximum distance out to which to calculate the function - which must equal the size of p_fProbArray. |
iFunction | Function flag. |
fDispersalX0 | Dispersal or X0 of the species in question, depending on the function |
fThetaXb | Theta or Xb of the species in question, depending on the function |
|
protected |
Decides whether masting events occur for each species.
This takes the time since last mast and compares a random number to the value for that time in the mp_fMastCDF array. It then uses that decision to set the appropriate event flag in mp_iEvent. Then the counter value for each species in m_iTimestepsSinceLastMast is set appropriately; incremented if no mast occurred, or set to 0 if it did.
If species have group affiliations, the mast decision is made for the first species. Then all other species in that group get the same value.
|
protected |
Performs dispersal of seeds for one tree.
The number of seeds is calculated by using the pointer in mp_GetSeeds. Each seed is given a random azimuth direction from the parent. Then each seed is given a random distance from the parent that conforms to the chosen probability distribution function. This is done by comparing a random value to successive values in the cumulative probability array until the first array bucket that has a greater value than the random number. Once the seed has an azimuth direction and a distance, it is added to the species total in the appropriate grid cell.
p_oTree | Tree for which to perform dispersal. |
fDbh | DBH of the tree, in cm. |
p_oPlot | Plot object |
p_oPop | Tree Population object |
|
protectedvirtual |
Does setup.
This sets all values in mp_iTimestepsSinceLastMast to 1. Then it calls:
p_oDoc | DOM tree of parsed input file. |
Implements clDisperseBase.
|
protected |
Formats the string in m_cQuery.
This value will be used in AddSeeds() in order to get the trees to act on.
p_oPop | Tree Population object |
|
inline |
Gets the value of the masting cumulative distribution function at a particular point.
sp | Species. |
yr | Year. |
|
inline |
Get whether a given species masted this timestep.
iSp | Species to check |
|
inline |
Get max timesteps.
|
protected |
Gets the number of seeds for a tree when the tree needs a lognormal STR draw.
seeds = STR * (DBH / 30)β
fDbh | DBH of the tree, in cm |
iSp | Tree species number |
|
protected |
Gets the number of seeds for a tree when the tree needs a normal STR draw.
seeds = STR * (DBH / 30)β
fDbh | DBH of the tree, in cm |
iSp | Tree species number |
|
protected |
Gets the number of seeds for a tree when there does not need to be an STR draw.
seeds = fecundity * DBHβ, Fecundity should have already been calculated.
fDbh | DBH of the tree, in cm |
iSp | Tree species number |
|
protected |
Extracts needed parameter file data.
(Some parameters are extracted by other setup functions and thrown away - this gets all other, permanent parameters.)
p_oDoc | Parsed parameter file document. |
stcErr | if:
|
p_oPop | Tree population object. |
|
inline |
Gets the number of years since the last mast for a species.
iSp | Species. |
|
protected |
Declares and populates the mp_bIsUsed array.
p_oPop | Tree Population object |
|
protected |
This figures out how each species's number of seeds is calculated.
It sets the appropriate function pointers in mp_GetSeeds.
|
friend |
|
protected |
Query to perform to search for trees.
|
protected |
Maximum distance, in meters, a seed can disperse - which is the maximum dimension of the grid with max of 1000 m.
|
protected |
Maximum timesteps before a masting event occurs after a first masting event.
This is calculated to be the value at which all species have a prob of 0.9999, or the number of timesteps in the run, whichever is smaller.
|
protected |
Number of years per timestep.
|
protected |
Whether to draw STR once per species (true) or once per tree (false).
This is from the parameter file.
|
protected |
Whether this behavior is used by a species/type combo.
First array index is species, second is type.
|
protected |
Beta parameter.
The array is 2D - the first index is masting or non-masting. The second index is species. This value comes from the parameter file.
|
protected |
Array of species with each one's dbh for reproduction.
|
protected |
Fecundity, if it is possible to pre-calculate it.
|
protected |
Fraction participating in disperse.
Array is 2D. First index is masting or non-masting. The second index is species. This value comes from the parameter file.
|
protected |
Masting cumulative distribution function.
Array size is number of species by m_iMaxYears.
|
protected |
For testing.
Cumulative probability array for seed dispersal. Array size is mast or non-mast by # species by max distance. The 0th bucket will never be accessed.
|
protected |
STR mean (or STR value if deterministic).
The array is 2D - the first index is masting or non-masting. The second index is species. This value comes from the parameter file.
|
protected |
STR standard deviation.
The array is 2D - the first index is masting or non-masting. The second index is species. This value comes from the parameter file.
|
protected |
Function pointer array for the appropriate function for calculating the number of seeds.
Array size is number of species to which this behavior applies.
|
protected |
Which event is occurring in the current timestep for each species.
|
protected |
Group affiliation of the species.
Any species with the same group number will always mast together. Array size is species.
|
protected |
This will speed access to the other arrays by storing each species' array index so the other arrays only have to be as big as the number of unique species for this behavior.
|
protected |
Number of years since the last mast for each species.
|
protected |
Which function is used by species.
|
protected |
What PDF is used to draw the STR.
Only deterministic, normal, and lognormal are supported.