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

PLOT CLASS - Version 1.0 This class represents the underlying plot. More...

#include <Plot.h>

Inheritance diagram for clPlot:
clWorkerBase

Public Member Functions

 ~clPlot ()
 Destructor. More...
 
 clPlot (clSimManager *p_oSimManager)
 Constructor. More...
 
double GetLatitude ()
 Gets the latitude. More...
 
double GetXPlotLength ()
 Gets the plot X length. More...
 
double GetYPlotLength ()
 Gets the plot Y length. More...
 
float GetXCellLength ()
 Gets the length of cells in the X direction. More...
 
float GetYCellLength ()
 Gets the length of cells in the Y direction. More...
 
float GetPlotArea ()
 Gets the plot area. More...
 
double GetMeanAnnualPrecip ()
 Gets the mean annual precipitation. More...
 
void SetMeanAnnualPrecip (double fMeanAnnualPrecip)
 Sets the mean annual precipitation. More...
 
double GetMeanAnnualTemp ()
 Gets the mean annual temperature. More...
 
void SetMeanAnnualTemp (double fMeanTemp)
 Sets the mean annual temperature. More...
 
double GetNDeposition ()
 Gets the annual N deposition. More...
 
void SetNDeposition (double fNDep)
 Sets the annual N deposition. More...
 
std::string GetPlotTitle ()
 Gets the plot title. More...
 
int GetNumXGrids ()
 Gets number of X grid cells. More...
 
int GetNumYGrids ()
 Gets number of Y grid cells. More...
 
float GetGridCellArea ()
 Gets the area of a grid cell. More...
 
int GetGridCellSize ()
 Gets the length of a grid cell side (cells are square). More...
 
float CorrectX (float fX)
 Translates an X coordinate to a position guaranteed to be valid. More...
 
float CorrectY (float fY)
 Translates a Y coordinate to a position guaranteed to be valid. More...
 
float GetDistance (float fFromX, float fFromY, float fToX, float fToY)
 Calculates the effective distance between two points, correcting for the torus. More...
 
float GetAzimuthAngle (float fFromX, float fFromY, float fToX, float fToY)
 Calculates the azimuth angle between two points on the plot. More...
 
int GetFastAzimuthAngle (float fFromX, float fFromY, float fToX, float fToY)
 Speedy way to do an azimuth calculation. More...
 
float GetUncorrectedX (float fFromX, float fAzimuth, float fDistance)
 Gets the X coordinate of a point defined in polar coordinates relative to another point, uncorrected for torus topology. More...
 
float GetUncorrectedY (float fFromY, float fAzimuth, float fDistance)
 Gets the Y coordinate of a point defined in polar coordinates relative to another point, uncorrected for torus topology. More...
 
float GetXDistance (float fFromX, float fToX)
 Gets the distance between two points in the X plane, corrected for torus wrapping. More...
 
float GetYDistance (float fFromY, float fToY)
 Gets the distance between two points in the Y plane, corrected for torus wrapping. More...
 
double GetSeasonalPrecipitation ()
 
void SetSeasonalPrecipitation (double fSeasonalPrecipitation)
 
double GetWaterDeficit ()
 
void SetWaterDeficit (double fWaterDeficit)
 
- 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)
 Reads data from the parameter file. More...
 
void PopulateAziTans ()
 Declares and populates the tangents of the azimuth angles. 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

std::string m_sPlotTitle
 Name for this plot. More...
 
int m_iNumXGrids
 Number of grid divisions along the X axis. More...
 
int m_iNumYGrids
 Number of grid divisions along the Y axis. More...
 
int m_iCellSize
 Length of one side of a grid cell, in meters. More...
 
float m_fPlotArea
 Plot area, in hectares. More...
 
double m_fPlotLenX
 Plot length along the X axis, in m. More...
 
double m_fPlotLenY
 Plot length along the Y axis, in m. More...
 
float m_fMaxX
 Max allowed X value - m_fPlotLenX minus a small value. More...
 
float m_fMaxY
 Max allowed Y value - m_fPlotLenY minus a small value. More...
 
double m_fLatitude
 Plot latitude, in decimal degrees - from the par file. More...
 
double m_fMeanAnnualPrecipMm
 Mean annual precipitation, mm. More...
 
double m_fWaterDeficit
 Water deficit. More...
 
double m_fSeasonalPrecipitation
 Seasonal precipitation. More...
 
double m_fMeanTempC
 Mean annual temperature, degrees Celsius. More...
 
double m_fNDep
 Annual N deposition. More...
 
float * mp_fAziTans
 Tangent of each azimuth angle. 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...
 

Detailed Description

PLOT CLASS - Version 1.0 This class represents the underlying plot.

It controls for torus topology and manages the grid coordinates. It also contains geographic and climate information about the plot, for those behaviors that require it.

There are some changes in the coordinate structure. The origin is in the southwest corner of the plot (unwrapped). The Y axis is NS and values increase to the north. The X axis is EW and values increase to the east. There are no negative values. The azimuth is north zero, east positive.

The truly underlying grid cell structure is no longer in the hands of the users. The base coordinates will be structured as 8 X 8 grid cells, which is what the trees will be organized into.

This class inherits from clWorkerBase to take advantage of the XML parsing functions in that class.

Copyright 2003 Charles D. Canham.

Author
Lora E. Murphy


Edit history:
--------------—
October 20, 2011 - Wiped the slate clean for SORTIE 7.0 (LEM)
June 27, 2013 - Added N deposition value (LEM)
October 31, 2013 - Added water deficit and seasonal precipitation

Constructor & Destructor Documentation

◆ ~clPlot()

clPlot::~clPlot ( )

Destructor.

◆ clPlot()

clPlot::clPlot ( clSimManager p_oSimManager)

Constructor.

Parameters
p_oSimManagerSim Manager object.

Member Function Documentation

◆ CorrectX()

float clPlot::CorrectX ( float  fX)

Translates an X coordinate to a position guaranteed to be valid.

If the number passed is already within the plot, it is left alone. If the number is outside of the plot, it is "wrapped" by adding or subtracting the appropriate plot length until it is inside the plot. Because of the torus shape of the plot, a number corrected in this way will have the same geometric relationships as the original number. This function is recursive - it will call itself until the number is correct. The edge of the plot is actually considered to be m_fMaxX; this catches numbers so close to the edge of the plot that they are likely to be rounded up and then be out of the plot.

Parameters
fXCoordinate to correct.
Returns
Corrected version of the coordinate.

◆ CorrectY()

float clPlot::CorrectY ( float  fY)

Translates a Y coordinate to a position guaranteed to be valid.

If the number passed is already within the plot, it is left alone. If the number is outside of the plot, it is "wrapped" by adding or subtracting the appropriate plot length until it is inside the plot. Because of the torus shape of the plot, a number corrected in this way will have the same geometric relationships as the original number. This function is recursive - it will call itself until the number is correct. The edge of the plot is actually considered to be m_fMaxY; this catches numbers so close to the edge of the plot that they are likely to be rounded up and then be out of the plot.

Parameters
fYCoordinate to correct.
Returns
Corrected version of the coordinate.

◆ GetAzimuthAngle()

float clPlot::GetAzimuthAngle ( float  fFromX,
float  fFromY,
float  fToX,
float  fToY 
)

Calculates the azimuth angle between two points on the plot.

Parameters
fFromXX coordinate of the "from" point.
fFromYY coordinate of the "from" point.
fToXX coordinate of the "to" point.
fToYY coordinate of the "to" point.
Returns
Azimuth, in RADIANS, north = 0.

◆ GetData()

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

Reads data from the parameter file.

Parameters
p_oDocDOM tree of parsed input file.

Implements clWorkerBase.

◆ GetDistance()

float clPlot::GetDistance ( float  fFromX,
float  fFromY,
float  fToX,
float  fToY 
)

Calculates the effective distance between two points, correcting for the torus.

Note that because of the torus, there are always two possible distances to any two points. This will return the shorter.

Parameters
fFromXX coordinate of the "from" point.
fFromYY coordinate of the "from" point.
fToXX coordinate of the "to" point.
fToYY coordinate of the "to" point.
Returns
Distance between the two points in meters.
Exceptions
BAD_DATAerror if either of the points is not in the plot.

◆ GetFastAzimuthAngle()

int clPlot::GetFastAzimuthAngle ( float  fFromX,
float  fFromY,
float  fToX,
float  fToY 
)

Speedy way to do an azimuth calculation.

Parameters
fFromXX coordinate of the "from" point.
fFromYY coordinate of the "from" point.
fToXX coordinate of the "to" point.
fToYY coordinate of the "to" point.
Returns
Azimuth in number of DEGREES (whole number).

◆ GetGridCellArea()

float clPlot::GetGridCellArea ( )
inline

Gets the area of a grid cell.

Returns
The area of a grid cell in square meters.

◆ GetGridCellSize()

int clPlot::GetGridCellSize ( )
inline

Gets the length of a grid cell side (cells are square).

Returns
Grid cell side length, in meters.

◆ GetLatitude()

double clPlot::GetLatitude ( )
inline

Gets the latitude.

Returns
Latitude, in decimal degrees.

◆ GetMeanAnnualPrecip()

double clPlot::GetMeanAnnualPrecip ( )
inline

Gets the mean annual precipitation.

Returns
Mean annual precipitation, in mm.

◆ GetMeanAnnualTemp()

double clPlot::GetMeanAnnualTemp ( )
inline

Gets the mean annual temperature.

Returns
Mean annual precipitation, in degrees C.

◆ GetNDeposition()

double clPlot::GetNDeposition ( )
inline

Gets the annual N deposition.

Returns
Annual N deposition.

◆ GetNumXGrids()

int clPlot::GetNumXGrids ( )
inline

Gets number of X grid cells.

Returns
Number of grid cells in the X direction.

◆ GetNumYGrids()

int clPlot::GetNumYGrids ( )
inline

Gets number of Y grid cells.

Returns
Number of grid cells in the Y direction.

◆ GetPlotArea()

float clPlot::GetPlotArea ( )
inline

Gets the plot area.

Returns
Plot area, in hectares.

◆ GetPlotTitle()

std::string clPlot::GetPlotTitle ( )
inline

Gets the plot title.

Returns
Plot title.

◆ GetSeasonalPrecipitation()

double clPlot::GetSeasonalPrecipitation ( )
inline

◆ GetUncorrectedX()

float clPlot::GetUncorrectedX ( float  fFromX,
float  fAzimuth,
float  fDistance 
)

Gets the X coordinate of a point defined in polar coordinates relative to another point, uncorrected for torus topology.

If you want a torus-corrected point, use CorrectX() on the result of this function.

Parameters
fFromXX coordinate of point that the desired point is defined relative to.
fAzimuthAzimuth angle from fFromX to the unknown point, in radians, north 0.
fDistanceDistance from fFromX to the unknown point, in meters.
Returns
The uncorrected X value of the point (meaning that it could be negative or greater than the plot length).
Exceptions
modelErrif the distance is negative, the azimuth is negative, or the azimuth is greater than 2PI.

◆ GetUncorrectedY()

float clPlot::GetUncorrectedY ( float  fFromY,
float  fAzimuth,
float  fDistance 
)

Gets the Y coordinate of a point defined in polar coordinates relative to another point, uncorrected for torus topology.

If you want a torus-corrected point, use CorrectY() on the result of this function.

Parameters
fFromYY coordinate of point that the desired point is defined relative to.
fAzimuthAzimuth angle from fFromX to the unknown point, in radians, north 0.
fDistanceDistance from fFromX to the unknown point, in meters.
Returns
The uncorrected Y value of the point (meaning that it could be negative or greater than the plot length).
Exceptions
modelErrif the distance is negative, the azimuth is negative, or the azimuth is greater than 2PI.

◆ GetWaterDeficit()

double clPlot::GetWaterDeficit ( )
inline

◆ GetXCellLength()

float clPlot::GetXCellLength ( )
inline

Gets the length of cells in the X direction.

Returns
Length of cells in the X direction, in m.

◆ GetXDistance()

float clPlot::GetXDistance ( float  fFromX,
float  fToX 
)
inline

Gets the distance between two points in the X plane, corrected for torus wrapping.

If the "to" point is lower than the "from", the answer will be negative.

Parameters
fFromXX coordinate of the "from" point.
fToXX coordinate of the "to" point.
Returns
X distance in meters.

◆ GetXPlotLength()

double clPlot::GetXPlotLength ( )
inline

Gets the plot X length.

Returns
Length of plot in X direction in meters.

◆ GetYCellLength()

float clPlot::GetYCellLength ( )
inline

Gets the length of cells in the Y direction.

Returns
Length of cells in the Y direction, in m.

◆ GetYDistance()

float clPlot::GetYDistance ( float  fFromY,
float  fToY 
)
inline

Gets the distance between two points in the Y plane, corrected for torus wrapping.

If the "to" point is lower than the "from", the answer will be negative.

Parameters
fFromYY coordinate of the "from" point.
fToYY coordinate of the "to" point.
Returns
Y distance in meters.

◆ GetYPlotLength()

double clPlot::GetYPlotLength ( )
inline

Gets the plot Y length.

Returns
Length of plot in Y direction in meters.

◆ PopulateAziTans()

void clPlot::PopulateAziTans ( )
protected

Declares and populates the tangents of the azimuth angles.

◆ SetMeanAnnualPrecip()

void clPlot::SetMeanAnnualPrecip ( double  fMeanAnnualPrecip)
inline

Sets the mean annual precipitation.

Parameters
fMeanAnnualPrecipMean annual precipitation, in mm.

◆ SetMeanAnnualTemp()

void clPlot::SetMeanAnnualTemp ( double  fMeanTemp)
inline

Sets the mean annual temperature.

Parameters
fMeanTempMean annual precipitation, in degrees C.

◆ SetNDeposition()

void clPlot::SetNDeposition ( double  fNDep)
inline

Sets the annual N deposition.

Parameters
fNDepAnnual N deposition.

◆ SetSeasonalPrecipitation()

void clPlot::SetSeasonalPrecipitation ( double  fSeasonalPrecipitation)
inline

◆ SetWaterDeficit()

void clPlot::SetWaterDeficit ( double  fWaterDeficit)
inline

Member Data Documentation

◆ m_fLatitude

double clPlot::m_fLatitude
protected

Plot latitude, in decimal degrees - from the par file.

◆ m_fMaxX

float clPlot::m_fMaxX
protected

Max allowed X value - m_fPlotLenX minus a small value.

◆ m_fMaxY

float clPlot::m_fMaxY
protected

Max allowed Y value - m_fPlotLenY minus a small value.

◆ m_fMeanAnnualPrecipMm

double clPlot::m_fMeanAnnualPrecipMm
protected

Mean annual precipitation, mm.

◆ m_fMeanTempC

double clPlot::m_fMeanTempC
protected

Mean annual temperature, degrees Celsius.

◆ m_fNDep

double clPlot::m_fNDep
protected

Annual N deposition.

◆ m_fPlotArea

float clPlot::m_fPlotArea
protected

Plot area, in hectares.

◆ m_fPlotLenX

double clPlot::m_fPlotLenX
protected

Plot length along the X axis, in m.

◆ m_fPlotLenY

double clPlot::m_fPlotLenY
protected

Plot length along the Y axis, in m.

◆ m_fSeasonalPrecipitation

double clPlot::m_fSeasonalPrecipitation
protected

Seasonal precipitation.

◆ m_fWaterDeficit

double clPlot::m_fWaterDeficit
protected

Water deficit.

◆ m_iCellSize

int clPlot::m_iCellSize
protected

Length of one side of a grid cell, in meters.

Cells are square. Make this always a power of 2! The const means the compiler can optimize divisions and multiplications into bit shifts.

◆ m_iNumXGrids

int clPlot::m_iNumXGrids
protected

Number of grid divisions along the X axis.

◆ m_iNumYGrids

int clPlot::m_iNumYGrids
protected

Number of grid divisions along the Y axis.

◆ m_sPlotTitle

std::string clPlot::m_sPlotTitle
protected

Name for this plot.

Optional.

◆ mp_fAziTans

float* clPlot::mp_fAziTans
protected

Tangent of each azimuth angle.

Array size is 360 (degrees).


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