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

Condit's Relative Neighborhood Density Index (Omega) Calculator Version 1.0. More...

#include <ConditOmegaCalculator.h>

Inheritance diagram for clConditOmegaCalculator:
clBehaviorBase clWorkerBase

Public Member Functions

 clConditOmegaCalculator (clSimManager *p_oSimManager)
 Constructor. More...
 
 ~clConditOmegaCalculator ()
 Destructor. More...
 
void Action ()
 Calculates Condit's Omega. More...
 
void GetData (xercesc::DOMDocument *p_oDoc)
 Does setup for this behavior. 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...
 
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 GetParameterFileData (xercesc::DOMDocument *p_oDoc)
 Reads values from the parameter file and performs setup related to the parameters. More...
 
void SetupGrid ()
 Sets up the "Relative Neighborhood Density" grid and registers the data members. More...
 
void GetTreeCodes (clTreePopulation *p_oPop)
 Gets the X and Y tree data codes. More...
 
void SetUpSearching (clTreePopulation *p_oPop)
 Sets up the structures for searching controls. More...
 
void ProcessCell (clTreePopulation *p_oPop, clTree *p_oFirstTree, const int &iX, const int &iY, const int &iNeighX, const int &iNeighY)
 Processes a neighboring cell's trees to find distance pairs. More...
 
void ProcessOwnCell (clTree *p_oFirstTree, float *p_fNumTrees, const int &iX, const int &iY)
 Processes a single cell's trees to find distance pairs. 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_oGrid
 Grid holding Condit's Omega values for the plot plus each species. More...
 
float ** mp_fOmegaValues
 Values holding Condit's Omega for each timestep. More...
 
short int ** mp_iGridCodes
 Holds the codes for the "Relative Neighborhood Density" grid. More...
 
short int ** mp_iXCodes
 Holds codes for X data member. More...
 
short int ** mp_iYCodes
 Holds codes for Y data member. More...
 
bool ** mp_bCellsSearched
 Which cells have already been paired the current timestep. More...
 
float * mp_fIncs
 Distance increment values - array size is m_iNumIncs. More...
 
float * mp_fAnnulusAreas
 Area of each annulus - array size is m_iNumIncs. More...
 
double m_fMaxDistance
 The max distance to which to calculate Condit's Omega. More...
 
double m_fIncrement
 The distance increment used to step out to the max distance. More...
 
int m_iNumIncs
 Number of increments for which to calculate Condit's Omega. More...
 
int m_iNumXToSearch
 The number of cells to search in the X direction - if the plot is a rectangle and the search distance is long the distances along the two axes may be different. More...
 
int m_iNumYToSearch
 The number of cells to search in the Y direction - if the plot is a rectangle and the search distance is long the distances along the two axes may be different. More...
 
int m_iNumXCells
 Number of tree population grid cells in X direction. More...
 
int m_iNumYCells
 Number of tree population grid cells in Y direction. More...
 
short int m_iNumTotalSpecies
 Total number of species. 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...
 

Friends

class clTestConditOmegaCalculator
 

Detailed Description

Condit's Relative Neighborhood Density Index (Omega) Calculator Version 1.0.

This behavior calculates Condit's relative neighborhood density index (omega). This index measures the aggregation of species. It is calculated for successive distances out to a maximum. The user sets the maximum distance and the increment. Omega for a species for a given distance x + Δx is calculated as:

Ω = (ΣNx / (T * Ax))/den

where Ax is the area of the annulus described by the radii x and Δx , in square meters, Nx is the number of conspecific neighbors of trees between x and Δx , T is the total number of trees of that species in the plot, and den is the species density in the plot.

In other words, Ω is the average density of conspecific neighbors at a specific distance divided by the plot's density of that species. Saplings and adults are counted as neighbors. All other types are ignored.

Conceptually, the way to carry out this search is to take each tree, find the density of its conspecific neighbors between each pair of radii x and Δx , average those values by species, and divide by the plot density for each species. In practice I can use a quicker method. The search proceeds by tree population grid cell. For each cell, a square of cells around it is searched. A matrix is used to keep track of which cells have already been paired so they are not paired again. Each pair of conspecifics is counted into the appropriate distance bucket (twice, once for when each tree is acting as a neighbor to the other's target). Then these buckets are used to calculate Ω according to the formula above.

The statistic is calculated for all individual species.

The values are collected into a grid called "Relative Neighborhood Density".

This class's namestring and parameter file call string is "ConditsOmega". Any tree type/species assignments are ignored.


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

Constructor & Destructor Documentation

◆ clConditOmegaCalculator()

clConditOmegaCalculator::clConditOmegaCalculator ( clSimManager p_oSimManager)

Constructor.

Parameters
p_oSimManagerclSimManager object.

◆ ~clConditOmegaCalculator()

clConditOmegaCalculator::~clConditOmegaCalculator ( )

Destructor.

Member Function Documentation

◆ Action()

void clConditOmegaCalculator::Action ( )
virtual

Calculates Condit's Omega.

First, the values in the "Relative Neighborhood Density" grid are cleared. Then this moves through the grid cells looking for tree pairs. For each cell this searches cells in a circle, using ProcessCell() and ProcessOwnCell() to find pairs. Once tree pairs have been found, this finishes the Condit's Omega calculation.

Reimplemented from clBehaviorBase.

◆ GetData()

void clConditOmegaCalculator::GetData ( xercesc::DOMDocument *  p_oDoc)
virtual

Does setup for this behavior.

Calls:

  1. GetParameterFileData()
  2. GetTreeCodes()
  3. SetupGrid()
  4. SetUpSearching()
  5. Action() so that the initial conditions value will be added
Parameters
p_oDocDOM tree of parsed input file.

Implements clWorkerBase.

◆ GetParameterFileData()

void clConditOmegaCalculator::GetParameterFileData ( xercesc::DOMDocument *  p_oDoc)
protected

Reads values from the parameter file and performs setup related to the parameters.

This validates the increment and distance.

Parameters
p_oDocDOM tree of parsed input file.
Exceptions
modelErrif either the increment or the max distance are less than or equal to zero, or if the increment is less than the max distance.

◆ GetTreeCodes()

void clConditOmegaCalculator::GetTreeCodes ( clTreePopulation p_oPop)
protected

Gets the X and Y tree data codes.

Parameters
p_oPopTree population object

◆ ProcessCell()

void clConditOmegaCalculator::ProcessCell ( clTreePopulation p_oPop,
clTree p_oFirstTree,
const int &  iX,
const int &  iY,
const int &  iNeighX,
const int &  iNeighY 
)
protected

Processes a neighboring cell's trees to find distance pairs.

This finds all pairs of conspecific saplings and adults within the max distance and counts each pair into the appropriate bin in the Condit's Omega calculator array. Each pair is counted in twice (once for each tree acting as the other's neighbor).

Parameters
p_oPopTree population object.
p_oFirstTreeThe shortest valid tree in the home cell.
iXX coordinate of home cell.
iYY coordinate of home cell.
iNeighXX coordinate of the neighbor cell to search for tree pairs.
iNeighYY coordinate of the neighbor cell to search for tree pairs.

◆ ProcessOwnCell()

void clConditOmegaCalculator::ProcessOwnCell ( clTree p_oFirstTree,
float *  p_fNumTrees,
const int &  iX,
const int &  iY 
)
protected

Processes a single cell's trees to find distance pairs.

This finds all pairs of conspecific saplings and adults within the max distance, being careful not to pair a tree with itself, and counts each pair into the appropriate bin in the Condit's Omega calculator array. Each pair is counted in twice (once for each tree acting as the other's neighbor). This also counts all the trees in the cell for the purposes of finding the plot's density.

Parameters
p_oFirstTreeThe shortest valid tree in the home cell.
p_fNumTreesThe array for number of saplings and adults in the cell for each species.
iXX coordinate of home cell.
iYY coordinate of home cell.

◆ SetupGrid()

void clConditOmegaCalculator::SetupGrid ( )
protected

Sets up the "Relative Neighborhood Density" grid and registers the data members.

◆ SetUpSearching()

void clConditOmegaCalculator::SetUpSearching ( clTreePopulation p_oPop)
protected

Sets up the structures for searching controls.

This sets up the mp_bCellsSearched matrix and finds the search distances in the X and Y directions. If the search distance is more than half the plot length in either direction, then it will be limited to half the plot length. This also sets up the mp_fIncs and mp_fAnnulusAreas arrays.

Parameters
p_oPopTree population object

Friends And Related Function Documentation

◆ clTestConditOmegaCalculator

friend class clTestConditOmegaCalculator
friend

Member Data Documentation

◆ m_fIncrement

double clConditOmegaCalculator::m_fIncrement
protected

The distance increment used to step out to the max distance.

◆ m_fMaxDistance

double clConditOmegaCalculator::m_fMaxDistance
protected

The max distance to which to calculate Condit's Omega.

◆ m_iNumIncs

int clConditOmegaCalculator::m_iNumIncs
protected

Number of increments for which to calculate Condit's Omega.

◆ m_iNumTotalSpecies

short int clConditOmegaCalculator::m_iNumTotalSpecies
protected

Total number of species.

For the destructor.

◆ m_iNumXCells

int clConditOmegaCalculator::m_iNumXCells
protected

Number of tree population grid cells in X direction.

◆ m_iNumXToSearch

int clConditOmegaCalculator::m_iNumXToSearch
protected

The number of cells to search in the X direction - if the plot is a rectangle and the search distance is long the distances along the two axes may be different.

◆ m_iNumYCells

int clConditOmegaCalculator::m_iNumYCells
protected

Number of tree population grid cells in Y direction.

◆ m_iNumYToSearch

int clConditOmegaCalculator::m_iNumYToSearch
protected

The number of cells to search in the Y direction - if the plot is a rectangle and the search distance is long the distances along the two axes may be different.

◆ mp_bCellsSearched

bool** clConditOmegaCalculator::mp_bCellsSearched
protected

Which cells have already been paired the current timestep.

The matrix size is number of total cells by number of total cells (flattening the 2D tree population cell matrix into a single array). The index for a tree population grid cell is number of X cells * X cell index + Y cell index. Since every grid cell is paired with every other, once a pair of grid cells is searched, two matrix cells must be switched to true.

◆ mp_fAnnulusAreas

float* clConditOmegaCalculator::mp_fAnnulusAreas
protected

Area of each annulus - array size is m_iNumIncs.

◆ mp_fIncs

float* clConditOmegaCalculator::mp_fIncs
protected

Distance increment values - array size is m_iNumIncs.

◆ mp_fOmegaValues

float** clConditOmegaCalculator::mp_fOmegaValues
protected

Values holding Condit's Omega for each timestep.

Array size is number of species by m_iNumIncs.

◆ mp_iGridCodes

short int** clConditOmegaCalculator::mp_iGridCodes
protected

Holds the codes for the "Relative Neighborhood Density" grid.

The first array index is number of species, with array size being m_iNumTotalSpecies. The second array index is buckets for values along the distance line, and is sized m_iNumIncs.

◆ mp_iXCodes

short int** clConditOmegaCalculator::mp_iXCodes
protected

Holds codes for X data member.

First array index is total # species, second is number types (2 - sapling, adult).

◆ mp_iYCodes

short int** clConditOmegaCalculator::mp_iYCodes
protected

Holds codes for Y data member.

First array index is total # species, second is number types (2 - sapling, adult).

◆ mp_oGrid

clGrid* clConditOmegaCalculator::mp_oGrid
protected

Grid holding Condit's Omega values for the plot plus each species.

The grid name is "Relative Neighborhood Density". It has one data member for each increment step out to the max for each species. The names are X_Y, where X is the increment step number (starting at zero) and Y is the species number (starting at zero). It also has two more for the length of distance increment ("inc") and the max distance ("dist"), to make output display easier.

This grid is always one cell per plot. Changes to grid cell resolution are ignored.


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