SORTIE Core C++ Documentation
|
Spatial dispersal - Version 1.0. More...
#include <SpatialDisperse.h>
Public Member Functions | |
clSpatialDispersal (clSimManager *p_oSimManager) | |
Constructor. More... | |
~clSpatialDispersal () | |
Destructor. More... | |
void | SetNameData (std::string sNameString) |
Captures the behavior name passed from the parameter file. 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 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 Member Functions | |
void | DoShellSetup (xercesc::DOMDocument *p_oDoc) |
Reads in values from the parameter file. More... | |
float | CalculateFunctionValue (float fDistance, int iSpecies, function iFunction, cover iCover) |
Calculates the function value at a particular point. More... | |
void | DeclareArrays () |
Declares the arrays. More... | |
void | SpatialDisperse (clTree *p_oTree, clTreePopulation *p_oPop, clPlot *p_oPlot, float fDbh) |
Performs dispersal of seeds for one tree according to gap disperse. More... | |
void | NonSpatialDisperse (clTree *p_oTree, clTreePopulation *p_oPop, clPlot *p_oPlot, float fDbh) |
Performs dispersal of seeds for one tree according to non-gap disperse. More... | |
void | GetParameterFileData (xercesc::DOMDocument *p_oDoc) |
Extracts needed parameter file data. More... | |
void | CalcFecAndFunctions () |
Calculates fecundity and the probability distribution functions. More... | |
void | PopulateUsedTable (clTreePopulation *p_oPop) |
Declares and populates the mp_bIsUsed array. More... | |
void | CalculateGapStatus (clTreePopulation *p_oPop) |
Updates the gap status of the seed grid, if this is "GapDisperse". More... | |
void | CalculateProbabilityDistribution (double *p_fProbArray, int iMaxDistance, int iSpecies, function iFunction, cover iCover) |
Calculates the normalized probability distribution for a function for one species. More... | |
void | AddSeeds () |
Performs dispersal. More... | |
float | GetNumberOfSeeds (float fDbh, short int iSp, int iCover, int iFunc) |
Gets the number of seeds to disperse for a tree, corrected for the number of years per timestep. 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 | |
double *** | mp_fDispersalX0 |
For testing. More... | |
double *** | mp_fThetaXb |
Theta (weibull) or Xb (lognormal) parameter. More... | |
double *** | mp_fStr |
STR parameter. More... | |
double *** | mp_fBeta |
Beta parameter. More... | |
double *** | mp_fFecundity |
Fecundity for 30 cm dbh tree for each species. More... | |
double * | mp_fStumpBeta |
Beta parameter for stumps. More... | |
double * | mp_fStumpStr |
STR parameter for stumps. More... | |
double * | mp_fStumpFecundity |
Fecundity for stumps. More... | |
double * | mp_fDbhForReproduction |
Array of species with each one's dbh for reproduction. More... | |
double **** | mp_fCumProb |
Cumulative probability array for gap and canopy cover. More... | |
int | m_iNumYearsPerTimestep |
Number of years per timestep. More... | |
int | m_iMaxDistance |
Maximum distance, in meters, a seed can disperse. More... | |
int | m_iMaxGapDensity |
Maximum number of reproductively mature trees allowed in a grid cell for the grid cell to retain gap status. 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 | m_iNumFunctions |
How many functions there are - 2. More... | |
short int | m_iNumCovers |
How many cover types there are - 2. More... | |
function ** | mp_iWhatFunction |
Which function is used - array indexes are cover by species. More... | |
char * | m_cQuery |
Query to perform to search for trees. More... | |
bool ** | mp_bIsUsed |
Whether this behavior is used by a species/type combo. More... | |
bool | m_bIsGap |
True if this is gap disperse; false if not. More... | |
bool | m_bStumps |
True if this behavior applies to stumps. 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... | |
Additional Inherited Members | |
Protected Types inherited from clDisperseBase | |
enum | function { weibull, lognormal } |
What PDF is used by a species. More... | |
enum | cover { gap, canopy } |
Cover status. More... | |
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 dispersal - Version 1.0.
This class creates and disperses seeds according to the spatially-explicit model. Parent trees of greater than the minimum reproductive DBH have the number of seeds calculated. The seeds are dispersed around the plot according to either the Weibull or Lognormal probability distribution functions.
Forest cover can be taken into account during seed distribution (gap) or ignored (non-gap).
This behavior can also be used for suckering of stumps. If this is desired, apply this to the species which sucker, tree type stump. If this is gap disperse, stumps reproduce pretending they're always in gap conditions. They use the probability distribution function of their species' gap function. If this is non-gap disperse, they reproduce like other adults of their species.
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.
To call this as gap disperse in the parameter file, use the string "GapDisperse". To call this as non-gap disperse, use the string "NonGapDisperse". There is a place in the parameters for indicating which probability distribution function should be used under each cover type. The namestring for this class is "SpatialDisperse".
Copyright 2011 Charles D. Canham.
Edit history:
--------------—
October 20, 2011 - Wiped the slate clean for SORTIE 7.0 (LEM)
clSpatialDispersal::clSpatialDispersal | ( | clSimManager * | p_oSimManager | ) |
Constructor.
p_oSimManager | Sim Manager object. |
clSpatialDispersal::~clSpatialDispersal | ( | ) |
Destructor.
|
protectedvirtual |
Performs dispersal.
This searches for all types to which it is applied. For trees which are of the appropriate species/type combo, either SpatialDisperse() or NonSpatialDisperse() is called.
Implements clDisperseBase.
|
protected |
Calculates fecundity and the probability distribution functions.
Fecundity is calculated as
|
protected |
Calculates the function value at a particular point.
fDistance | Distance at which to calculate function value. |
iSpecies | Species for which to calculate function value. |
iFunction | Which function to calculate (weibull or lognormal). |
iCover | Cover for which to calculate function value. |
|
protected |
Updates the gap status of the seed grid, if this is "GapDisperse".
It counts all parent trees present in each grid cell (those that have a DBH of at least the minimum reproductive age for their species). The counts are placed in each grid cell and when the count is higher than the cutoff for gap status, the grid is under canopy; otherwise, it is under gap.
This counts all species, not just the ones to which this behavior applies. However, for those species that do not use this behavior, their minimum adult DBH will be used as the cutoff for counting, even if they have a minimum reproductive DBH listed. That's because I haven't bothered with the logistics of figuring out if a species uses another disperse behavior.
p_oPop | Tree population object. |
|
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. |
iSpecies | Species for which we're calculating. |
iFunction | Function flag. |
iCover | Cover flag. |
|
protected |
Declares the arrays.
|
protectedvirtual |
Reads in values from the parameter file.
p_oDoc | DOM tree of parsed input file. |
Implements clDisperseBase.
|
protected |
Gets the number of seeds to disperse for a tree, corrected for the number of years per timestep.
The equation is seeds = fecundity * DBHβ, where all parameters are appropriate for forest cover if this is gap disperse.
fDbh | DBH of the tree, in cm |
iSp | Tree species number |
iCover | Forest cover |
iFunc | Disperse function used |
|
protected |
Extracts needed parameter file data.
This function takes into account whether or not this is gap.
The minimum reproductive DBH array is pre-loaded with the minimum adult DBH values, so if there is a species that is not used by this behavior, CalculateGapStatus() still has something to use.
p_oDoc | Parsed parameter file document. |
stcErr | if:
|
|
protected |
Performs dispersal of seeds for one tree according to non-gap disperse.
The number of seeds is calculated. 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 |
|
protected |
Declares and populates the mp_bIsUsed array.
p_oPop | Tree Population object |
|
virtual |
Captures the behavior name passed from the parameter file.
This is useful since this class can produce a few different kinds of behaviors.
sNameString | Behavior name from parameter file. |
Reimplemented from clBehaviorBase.
|
protected |
Performs dispersal of seeds for one tree according to gap disperse.
The number of seeds for a tree is calculated with the higher of gap or canopy STR.
Each seed is given a random azimuth angle. It is then given a random distance that conforms to the probability distribution function of the current forest cover of the parent. (This distance is gotten by comparing a random value to successive values in the appropriate cumulative probability array until the first array bucket that has a greater value than the random number.) Once the seed has an azimuth and a distance, the function determines which grid cell it should drop in.
Once the seed has a target grid cell, that cell's cover is checked. Then the seed's survival is evaluated. If the seed is in the cover type with the higher STR, it automatically survives. Otherwise, a random number is compared to the ratio of the lower STR to the higher STR to determine if it survives.
If the seed survives, it may need to be repositioned. If both parent and seed are under closed canopy, the seed is dropped where it is. If the parent is in gap and seedling is in canopy, a new distance is calculated as though the parent was also in canopy. The shortest of the two distances is used to determine where the seed lands. If the seed lands in a gap cell, the function "walks out" the line of the seed's path from parent to target landing cell, checking each intermediate grid cell's cover along the way. If any of the grid cells in the line are under canopy cover, the seed drops in the first canopy cell it reaches.
p_oTree | Tree for which to perform dispersal. |
fDbh | DBH of the tree, in cm. |
p_oPlot | Plot object |
p_oPop | Tree Population object |
|
protected |
True if this is gap disperse; false if not.
|
protected |
True if this behavior applies to stumps.
|
protected |
Query to perform to search for trees.
|
protected |
Maximum distance, in meters, a seed can disperse.
|
protected |
Maximum number of reproductively mature trees allowed in a grid cell for the grid cell to retain gap status.
|
protected |
How many cover types there are - 2.
|
protected |
How many functions there are - 2.
|
protected |
Number of years per timestep.
|
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 3D - first index is which disperse function is used. The second index is cover. The third index is species. This value comes from the parameter file.
|
protected |
Cumulative probability array for gap and canopy cover.
Array size is
|
protected |
Array of species with each one's dbh for reproduction.
|
protected |
For testing.
Dispersal (weibull) or X0 (lognormal) parameter. The array is 3D - first index is which disperse function is used. The second index is cover. The third index is species. This value comes from the parameter file.
|
protected |
Fecundity for 30 cm dbh tree for each species.
The array is 3D - first index is which disperse function is used. The second index is cover. The third index is species.
|
protected |
STR parameter.
The array is 3D - first index is which disperse function is used. The second index is cover. The third index is species. This value comes from the parameter file.
|
protected |
Beta parameter for stumps.
This matches the beta parameter for live trees for this species.
|
protected |
Fecundity for stumps.
|
protected |
STR parameter for stumps.
This matches the STR parameter for live trees for this species.
|
protected |
Theta (weibull) or Xb (lognormal) parameter.
If this is theta, this value must be less than 50 to protect against pow overflows. The array is 3D - first index is which disperse function is used. The second index is cover. The third index is species. This value comes from the parameter file.
|
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 |
Which function is used - array indexes are cover by species.