SORTIE Core C++ Documentation
Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
clNeighborhoodSeedPredation Class Reference

Neighborhood Seed Predationon - version 1.1. More...

#include <NeighborhoodSeedPredation.h>

Inheritance diagram for clNeighborhoodSeedPredation:
clBehaviorBase clWorkerBase

Public Member Functions

 clNeighborhoodSeedPredation (clSimManager *p_oSimManager)
 Constructor. More...
 
 ~clNeighborhoodSeedPredation ()
 Destructor. More...
 
void Action ()
 Performs neighborhood seed predation. More...
 
void SetNameData (std::string sNameString)
 Captures the behavior name passed from the parameter file. 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...
 
clSimManagerGetSimManager ()
 
void DoObjectSetup (xercesc::DOMDocument *p_oDoc, fileType iFileType)
 Triggers the setup process. More...
 
virtual void TimestepCleanup ()
 Performs any necessary cleanup operations at the end of a timestep. More...
 
virtual void EndOfRunCleanup ()
 Performs any necessary cleanup operations at the end of a run. More...
 

Protected Member Functions

void GetData (xercesc::DOMDocument *p_oDoc)
 Does setup. More...
 
void DoStandalonePredation ()
 Performs neighborhood seed predation for the standalone version of this behavior. More...
 
void DoLinkedPredation ()
 Performs neighborhood seed predation for the linked version of this behavior. More...
 
void GetOfftakes (clTreePopulation *p_oPop, const double *p_fP0, double **p_fPn, float *p_fOfftake, const int &iX, const int &iY)
 Gets the offtake (Y) values for all behavior species for a given grid cell. More...
 
void SetupGrids ()
 Gets a pointer to the "Dispersed Seeds" grid, and sets up the output grid. More...
 
void ReadParameterFileData (xercesc::DOMDocument *p_oDoc)
 Reads parameter file data. 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

clGridmp_oSeedGrid
 Pointer to the "Dispersed Seeds" grid created by disperse behaviors. More...
 
double * mp_fNonMastingP0
 Non-masting "p0" parameter. More...
 
double ** mp_fNonMastingPn
 Non-masting pn. More...
 
double * mp_fMastingP0
 Masting "p0" parameter. More...
 
double * mp_fMinNeighDBH
 Minimum neighbor DBH. More...
 
double ** mp_fMastingPn
 Masting pn. More...
 
short int * mp_iSeedGridCode
 Data member codes for seed grid for number of seeds. More...
 
short int * mp_iStartSeedsCode
 Data member codes for the "startseeds_x" member of the output grid. More...
 
short int * mp_iPropEatenCode
 Data member codes for the "propeaten_x" member of the output grid. More...
 
short int * mp_iIndexes
 For accessing the other arrays. More...
 
bool * mp_bCountInMast
 Whether or not a species counts when making masting decisions. More...
 
float m_fPlotArea
 Area of the plot, in square meters. More...
 
double m_fRadius
 Radius of neighborhoods. More...
 
double m_fMastingThreshold
 Threshold of seeds per square meter for a masting timestep. More...
 
bool m_bIsLinked
 Whether this is the linked (true) or standalone (false) version. More...
 
bool m_bUseThresholdToDecideMast
 Whether to use a seed density threshold (true) or ask the masting disperse behaviors (false) when deciding whether this is a masting timestep. More...
 
- 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...
 
stcSpeciesTypeCombomp_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...
 
clSimManagermp_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...
 

Static Protected Attributes

static clGridmp_oOutputGrid
 Grid to output details of seed predation. More...
 

Detailed Description

Neighborhood Seed Predationon - version 1.1.

This behavior reduces the number of seeds by simulating seed predation. Rate of offtake is a function of neighborhood composition.

This can be used in two forms. In the standalone form, masting is also used to determine offtake. In the linked form, the clFuncResponseSeedPredation class determines the offtake rate, and this class figures out where seeds get eaten. In this case, masting is ignored.

In the standalone version, there are two choices for assessing masting: in the first, masting is assessed by counting the seeds to which this behavior applies and which participate in masting (two different things - the latter is controlled by a boolean parameter ) and comparing it to a density per timestep threshold. Above the threshold is masting; below is not. The second choice is to ask the masting disperse behaviors if any species has masted; if any have, then it is a masting event. (If masting disperse behaviors are not used, then masting never occurs.) The only difference between masting and non-masting timesteps is the parameters used.

For both versions, the proportion of seed removed is calculated as:

logit(Y) = p0 + Σ pn * RBA n
where, summing over the species from n = 1...N, pn is the loading factor for species n, and RBAn is the relative basal area of species n. There is a species specific minimum DBH for neighbors to include.

In the standalone version, this is used directly as the amount of seed removed. In the linked version, it is used to distribute the offtake rate from the functional response seed predation behavior. Conceptually, the local offtake rate is adjusted by a correction factor, calculated by dividing the FR offtake Z by the mean off the local offtakes, so the plot-level offtake remains the same. Mathematically it is a little more complicated:

  1. Calculate logit(Z)
  2. Calculate the logit(Ys) and subtract the minimum value from each (as well as the logit(Z)) so they will all be positive
  3. Average the logit(Y)s
  4. Divide logit(Z) by average logit(Y) to get a correction factor
  5. Multiply each logit(Y) by the correction factor
  6. Add back the same minimum value formerly subtracted
  7. Backtransform logit(Y) to Y and use when removing seeds

A fatal error is thrown if a disperse behavior is not also defined for the run, and additionally if this is linked and the clFuncResponseSeedPredation class is missing.

This class's namestring is "NeighborhoodSeedPredation". If standalone, the parameter call string is "NeighborhoodSeedPredation". If linked, the parameter call string is "LinkedNeighborhoodSeedPredation".


Copyright 2011 Charles D. Canham.

Author
Lora E. Murphy


Edit history:
--------------—
October 20, 2011 - Wiped the slate clean for SORTIE 7.0 (LEM)

Constructor & Destructor Documentation

◆ clNeighborhoodSeedPredation()

clNeighborhoodSeedPredation::clNeighborhoodSeedPredation ( clSimManager p_oSimManager)

Constructor.

Parameters
p_oSimManagerSim Manager object.

◆ ~clNeighborhoodSeedPredation()

clNeighborhoodSeedPredation::~clNeighborhoodSeedPredation ( )

Destructor.

Frees memory.

Member Function Documentation

◆ Action()

void clNeighborhoodSeedPredation::Action ( )
virtual

Performs neighborhood seed predation.

If the behavior is in linked mode, this calls DoLinkedPredation. If not, this calls DoStandalonePredation. Before the appropriate predation function is called, this copies the values from the "Dispersed Seeds" grid to the "startseeds_x" data members of the output grid; after the function is called, this calculates and posts the values of the "propeaten_x" data members.

Reimplemented from clBehaviorBase.

◆ DoLinkedPredation()

void clNeighborhoodSeedPredation::DoLinkedPredation ( )
protected

Performs neighborhood seed predation for the linked version of this behavior.

This calculates all offtakes, then adjusts them according to the offtake calculated by clFuncResponseSeedPredation. A random round is used to take care of fractional parts of seeds.

◆ DoStandalonePredation()

void clNeighborhoodSeedPredation::DoStandalonePredation ( )
protected

Performs neighborhood seed predation for the standalone version of this behavior.

First, for the whole plot, this assesses whether masting has occurred by comparing the density of seeds of species to which this behavior applies to the threshold. Then for each cell, the neighborhood relative BAs and the proportion to remove is calculated. A random round is used to take care of fractional parts of seeds. This also checks plot adult tree density; if it is zero, it is automatically not a masting time step.

◆ GetData()

void clNeighborhoodSeedPredation::GetData ( xercesc::DOMDocument *  p_oDoc)
protectedvirtual

Does setup.

This reads in values from the parameter file, gets the pointer to the dispersed seeds grid, and sets up the output grid.

Parameters
p_oDocDOM tree of parsed input file.
Exceptions
modelErrif this is linked and there is no functional response seed predation.

Implements clWorkerBase.

◆ GetOfftakes()

void clNeighborhoodSeedPredation::GetOfftakes ( clTreePopulation p_oPop,
const double *  p_fP0,
double **  p_fPn,
float *  p_fOfftake,
const int &  iX,
const int &  iY 
)
protected

Gets the offtake (Y) values for all behavior species for a given grid cell.

Parameters
p_oPopTree population object.
p_fP0p0 values to use, as an array sized m_iNumBehaviorSpecies.
p_fPnpn values to use, as an array sized m_iNumBehaviorSpecies by the total number of species.
p_fOfftakePlace to put offtake values, as an array sized m_iNumBehaviorSpecies.
iXSeed grid X cell number.
iYSeed grid Y cell number.
Returns
Array of offtakes sized m_iNumBehaviorSpecies.

◆ ReadParameterFileData()

void clNeighborhoodSeedPredation::ReadParameterFileData ( xercesc::DOMDocument *  p_oDoc)
protected

Reads parameter file data.

Parameters
p_oDocDOM tree of parsed input file.
Exceptions
modelErrif any of the following are negative: neighborhood radius, min neighbor DBH, masting threshold

◆ SetNameData()

void clNeighborhoodSeedPredation::SetNameData ( std::string  sNameString)
virtual

Captures the behavior name passed from the parameter file.

This is useful since this class can produce different kinds of behaviors.

Parameters
sNameStringBehavior name from parameter file.

Reimplemented from clBehaviorBase.

◆ SetupGrids()

void clNeighborhoodSeedPredation::SetupGrids ( )
protected

Gets a pointer to the "Dispersed Seeds" grid, and sets up the output grid.

Exceptions
modelErrif the seed grid is not found

Member Data Documentation

◆ m_bIsLinked

bool clNeighborhoodSeedPredation::m_bIsLinked
protected

Whether this is the linked (true) or standalone (false) version.

◆ m_bUseThresholdToDecideMast

bool clNeighborhoodSeedPredation::m_bUseThresholdToDecideMast
protected

Whether to use a seed density threshold (true) or ask the masting disperse behaviors (false) when deciding whether this is a masting timestep.

◆ m_fMastingThreshold

double clNeighborhoodSeedPredation::m_fMastingThreshold
protected

Threshold of seeds per square meter for a masting timestep.

This comes as an annual amount in the parameter file and is converted to a timestep amount. Only necessary if m_bUseThresholdToDecideMast is true.

◆ m_fPlotArea

float clNeighborhoodSeedPredation::m_fPlotArea
protected

Area of the plot, in square meters.

◆ m_fRadius

double clNeighborhoodSeedPredation::m_fRadius
protected

Radius of neighborhoods.

◆ mp_bCountInMast

bool* clNeighborhoodSeedPredation::mp_bCountInMast
protected

Whether or not a species counts when making masting decisions.

Only necessary if m_bUseThresholdToDecideMast is true.

◆ mp_fMastingP0

double* clNeighborhoodSeedPredation::mp_fMastingP0
protected

Masting "p0" parameter.

Array size is number of species to which this behavior applies.

◆ mp_fMastingPn

double** clNeighborhoodSeedPredation::mp_fMastingPn
protected

Masting pn.

Array size is number of behavior species by number of total species.

◆ mp_fMinNeighDBH

double* clNeighborhoodSeedPredation::mp_fMinNeighDBH
protected

Minimum neighbor DBH.

◆ mp_fNonMastingP0

double* clNeighborhoodSeedPredation::mp_fNonMastingP0
protected

Non-masting "p0" parameter.

Array size is number of species to which this behavior applies.

◆ mp_fNonMastingPn

double** clNeighborhoodSeedPredation::mp_fNonMastingPn
protected

Non-masting pn.

Array size is number of behavior species by number of total species.

◆ mp_iIndexes

short int* clNeighborhoodSeedPredation::mp_iIndexes
protected

For accessing the other arrays.

◆ mp_iPropEatenCode

short int* clNeighborhoodSeedPredation::mp_iPropEatenCode
protected

Data member codes for the "propeaten_x" member of the output grid.

Array size is total number of species.

◆ mp_iSeedGridCode

short int* clNeighborhoodSeedPredation::mp_iSeedGridCode
protected

Data member codes for seed grid for number of seeds.

Array size is number of species to which this behavior applies.

◆ mp_iStartSeedsCode

short int* clNeighborhoodSeedPredation::mp_iStartSeedsCode
protected

Data member codes for the "startseeds_x" member of the output grid.

Array size is total number of species.

◆ mp_oOutputGrid

clGrid* clNeighborhoodSeedPredation::mp_oOutputGrid
staticprotected

Grid to output details of seed predation.

The name of this grid Seed Predation Predation". Its cell size matches that of the "Dispersed Seeds" grid. For each species there are two data members: "startseeds_x" and "propeaten_x" for the pre-predation seed numbers and proportion eaten, respectively, where X is the species number. Both of the data members are float. Initial conditions maps of this grid are not respected.

◆ mp_oSeedGrid

clGrid* clNeighborhoodSeedPredation::mp_oSeedGrid
protected

Pointer to the "Dispersed Seeds" grid created by disperse behaviors.


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