ALMaSS Rabbit ODdox  1.1
The rabbit model description following ODdox protocol
PollenNectarDevelopmentData Class Reference

A standard class to manage a range of pollen and nectar development curves based on indexed rates. More...

#include <plants.h>

Public Member Functions

 PollenNectarDevelopmentData (string a_tovinputfile, string a_toleinputfile, Landscape *a_land)
 
 ~PollenNectarDevelopmentData ()
 
double toleGetPollen (int a_tole, int a_index)
 
double toleGetNectar (int a_tole, int a_index)
 
double tovGetPollen (int a_tov, int a_index)
 
double tovGetNectar (int a_tov, int a_index)
 
int tovGetNPCurveNum (TTypesOfVegetation a_tov)
 
int toleGetNPCurveNum (TTypesOfVegetation a_tov)
 
PollenNectarDevelopmentCurveSet GetPollenNectarCurvePtr (int a_almassLEref)
 
PollenNectarDevelopmentCurveSet tovGetPollenNectarCurvePtr (int a_tov_ref)
 

Protected Attributes

vector< PollenNectarDevelopmentCurve * > m_tovPollenCurves
 
vector< PollenNectarDevelopmentCurve * > m_tovNectarCurves
 
vector< PollenNectarDevelopmentCurve * > m_tolePollenCurves
 
vector< PollenNectarDevelopmentCurve * > m_toleNectarCurves
 
vector< int > m_tov_pollencurvetable
 
vector< int > m_tole_pollencurvetable
 

Detailed Description

A standard class to manage a range of pollen and nectar development curves based on indexed rates.

Definition at line 224 of file plants.h.

Constructor & Destructor Documentation

◆ PollenNectarDevelopmentData()

PollenNectarDevelopmentData::PollenNectarDevelopmentData ( string  a_tovinputfile,
string  a_toleinputfile,
Landscape a_land 
)

Reads in the number of pollen and nectar curves. Either we have one pair for each tov or we need a look-up table, but because many have the same curves a look up table was used. This however requires another input file for tov types to pollen/nectar curve number. If not using pollen and nectar then this is waste of space, so there is a cfg to turn it off and set all curves to a zero curve.

There are two sets of data structures - some based on tole types and the rest are crops that can be on a field tole. the methods of input is duplicated as far as possible.

tov
We need to open the input file and read in the tov types that have associated curves. Those not specified are assumed to have no nectar or pollen. Numbers used are those defined in LE_TypeClass::TranslateVegTypes for each tov type. First file entry is the number of defined tov_types, followed by pairs of tov_refnum & pollen curve refnum. The next line has a single number for the number of pollen/nectar curves The next lines are in pairs, pollen curve followed by nectar curve each with 365 entries and preceded by the curve number.

tole
We need to open the input file and read in the tov types that have associated curves. Those not specified are assumed to have no nectar or pollen. Numbers used are those defined in LE_TypeClass::TranslateEleTypes for each tole type. First file entry is the number of defined tole_types, followed by pairs of tole_refnum & pollen curve refnum. The next line has a single number for the number of pollen/nectar curves The next lines are in pairs, pollen curve followed by nectar curve each with 365 entries and preceded by the curve number.

Definition at line 416 of file plants.cpp.

417 {
423  // This forms an empty entry for no pollen or nectar tov types
424  vector<double> empty;
425  vector<int> index;
426  for (int i = 0; i < 366; i++) {
427  empty.push_back(0.0);
428  index.push_back(i);
429  }
430  // make space in the lookup table for all tov types
432  for (int i = 0; i < int(tov_Undefined); i++) m_tov_pollencurvetable[i] = 0;
433  // make space in the lookup table for all tole types
435  for (int i = 0; i < int(tole_Foobar); i++) m_tole_pollencurvetable[i] = 0;
436 
438  {
449  ifstream infile(a_tovinputfile.c_str(), ios::in);
450  //check if there is an input file
451  if (!infile.is_open()) {
452  g_msg->Warn("PollenNectarDevelopmentData::PollenNectarDevelopmentData Cannot open the file", a_toleinputfile.c_str());
453  exit(1);
454  }
455  int no_curves;
456  int tov, curvenum;
457  infile >> no_curves;
458  for (int i = 0; i < no_curves-1; i++)
459  {
460  infile >> tov >> curvenum;
461  // convert from the reference number to tov type
462  tov = a_land->TranslateVegTypes(tov);
463  // store the reference in the pollen nectar lookup table
464  m_tov_pollencurvetable[tov] = curvenum;
465  }
466  // Now read the curve themselves
467  m_tovPollenCurves.resize(no_curves);
468  m_tovNectarCurves.resize(no_curves);
469  // each curve is composed to two sets of 365 numbers. The first being the index set - always 1-365 so there is no need to read this in, so it is filled in here
470  vector<double> slopes(366, 0);
472  p_curve = new PollenNectarDevelopmentCurve(&index, &empty);
473  m_tovPollenCurves[0] = p_curve;
474  m_tovNectarCurves[0] = p_curve;
475  for (int i = 0; i < no_curves; i++)
476  {
477  // Read the curve number
478  infile >> curvenum;
479  infile >> slopes[365];
480  // Read in the pollen data and save
481  for (int d = 0; d < 365; d++) infile >> slopes[d];
482  p_curve = new PollenNectarDevelopmentCurve(&index, &slopes);
483  m_tovPollenCurves[curvenum] = p_curve;
484  // Read in the nectar data and save
485  infile >> slopes[365];
486  for (int d = 0; d < 365; d++) infile >> slopes[d];
487  p_curve = new PollenNectarDevelopmentCurve(&index, &slopes);
488  m_tovNectarCurves[curvenum] = p_curve;
489  }
490  infile.close();
500  infile.open(a_tovinputfile.c_str(), ios::in);
501  //check if there is an input file
502  if (!infile.is_open()) {
503  g_msg->Warn("PollenNectarDevelopmentData::PollenNectarDevelopmentData Cannot open the file", a_toleinputfile.c_str());
504  exit(1);
505  }
506  infile >> no_curves;
507  int tole, tolecurvenum;
508  for (int i = 0; i < no_curves-1; i++)
509  {
510  infile >> tole >> tolecurvenum;
511  // convert from the reference number to tov type
512  tole = a_land->TranslateVegTypes(tole);
513  // store the reference in the pollen nectar lookup table
514  m_tole_pollencurvetable[tole] = tolecurvenum;
515  }
516  // Now read the curve themselves
517  m_tolePollenCurves.resize(no_curves);
518  m_toleNectarCurves.resize(no_curves);
519  p_curve = new PollenNectarDevelopmentCurve(&index, &empty);
520  m_tolePollenCurves[0] = p_curve;
521  m_toleNectarCurves[0] = p_curve;
522  for (int i = 1; i <= no_curves; i++)
523  {
524  // Read the curve number
525  infile >> tolecurvenum;
526  // Read in the pollen data and save
527  infile >> slopes[366];
528  for (int d = 0; d < 365; d++) infile >> slopes[d];
529  p_curve = new PollenNectarDevelopmentCurve(&index, &slopes);
530  m_tolePollenCurves[tolecurvenum] = p_curve;
531  // Read in the nectar data and save
532  infile >> slopes[365];
533  for (int d = 0; d < 365; d++) infile >> slopes[d];
534  p_curve = new PollenNectarDevelopmentCurve(&index, &slopes);
535  m_toleNectarCurves[tolecurvenum] = p_curve;
536  }
537  infile.close();
538  }
539  else
540  {
542  // Set all to zero curve
543  m_tovPollenCurves.push_back(pnc);
544  m_tovNectarCurves.push_back(pnc);
545  m_tolePollenCurves.push_back(pnc);
546  m_toleNectarCurves.push_back(pnc);
547  for (int tov = 0; tov<int(tov_Undefined); tov++)
548  {
549  m_tov_pollencurvetable[tov] = 0;
550  }
551  for (int tole = 0; tole<int(tole_Foobar); tole++)
552  {
553  m_tole_pollencurvetable[tole] = 0;
554  }
555  }
556 }

References cfg_pollen_nectar_on, g_msg, m_tole_pollencurvetable, m_toleNectarCurves, m_tolePollenCurves, m_tov_pollencurvetable, m_tovNectarCurves, m_tovPollenCurves, tole_Foobar, tov_Undefined, Landscape::TranslateVegTypes(), CfgBool::value(), and MapErrorMsg::Warn().

◆ ~PollenNectarDevelopmentData()

PollenNectarDevelopmentData::~PollenNectarDevelopmentData ( )

Definition at line 558 of file plants.cpp.

559 {
560  for (int i = 0; i < m_tovPollenCurves.max_size(); i++) delete m_tovPollenCurves[i];
561  for (int i = 0; i < m_tovNectarCurves.max_size(); i++) delete m_tovNectarCurves[i];
562  for (int i = 0; i < m_tolePollenCurves.max_size(); i++) delete m_tolePollenCurves[i];
563  for (int i = 0; i < m_toleNectarCurves.max_size(); i++) delete m_toleNectarCurves[i];
564 }

References m_toleNectarCurves, m_tolePollenCurves, m_tovNectarCurves, and m_tovPollenCurves.

Member Function Documentation

◆ GetPollenNectarCurvePtr()

PollenNectarDevelopmentCurveSet PollenNectarDevelopmentData::GetPollenNectarCurvePtr ( int  a_almassLEref)

Uses the almass LE ref num to find the relevant curve set and return it as a pointer. Zero is a special case since this is the empty pollen/nectar curve - it is not an almass LE ref The other special case is rotational crop field, in which case the initialisation is done when the crop is assigned

Definition at line 566 of file plants.cpp.

567 {
576  if ((a_almassLEref == 0) || (g_letype->TranslateEleTypes(a_almassLEref) == tole_Field) || (g_letype->TranslateEleTypes(a_almassLEref) == tole_UnsprayedFieldMargin)) return set;
579  return set;
580 }

References g_letype, PollenNectarDevelopmentCurveSet::m_nectarcurveptr, PollenNectarDevelopmentCurveSet::m_pollencurveptr, m_tole_pollencurvetable, m_toleNectarCurves, m_tolePollenCurves, tole_Field, tole_UnsprayedFieldMargin, and LE_TypeClass::TranslateEleTypes().

Referenced by LE::SetPollenNectarData().

◆ toleGetNectar()

double PollenNectarDevelopmentData::toleGetNectar ( int  a_tole,
int  a_index 
)
inline

Definition at line 230 of file plants.h.

230 { return m_toleNectarCurves[int(a_tole)]->GetData(a_index); }

◆ toleGetNPCurveNum()

int PollenNectarDevelopmentData::toleGetNPCurveNum ( TTypesOfVegetation  a_tov)
inline

Definition at line 234 of file plants.h.

234 { return m_tole_pollencurvetable[a_tov]; }

◆ toleGetPollen()

double PollenNectarDevelopmentData::toleGetPollen ( int  a_tole,
int  a_index 
)
inline

Definition at line 229 of file plants.h.

229 { return m_tolePollenCurves[int(a_tole)]->GetData(a_index); }

◆ tovGetNectar()

double PollenNectarDevelopmentData::tovGetNectar ( int  a_tov,
int  a_index 
)
inline

Definition at line 232 of file plants.h.

232 { return m_tovNectarCurves[int(a_tov)]->GetData(a_index); }

◆ tovGetNPCurveNum()

int PollenNectarDevelopmentData::tovGetNPCurveNum ( TTypesOfVegetation  a_tov)
inline

Definition at line 233 of file plants.h.

233 { return m_tov_pollencurvetable[a_tov]; }

◆ tovGetPollen()

double PollenNectarDevelopmentData::tovGetPollen ( int  a_tov,
int  a_index 
)
inline

Definition at line 231 of file plants.h.

231 { return m_tovPollenCurves[int(a_tov)]->GetData(a_index); }

◆ tovGetPollenNectarCurvePtr()

PollenNectarDevelopmentCurveSet PollenNectarDevelopmentData::tovGetPollenNectarCurvePtr ( int  a_tov_ref)

Uses the tov ref num to find the relevant curve set and return it as a pointer.

Definition at line 582 of file plants.cpp.

583 {
592  return set;
593 }

References PollenNectarDevelopmentCurveSet::m_nectarcurveptr, PollenNectarDevelopmentCurveSet::m_pollencurveptr, m_toleNectarCurves, m_tolePollenCurves, m_tov_pollencurvetable, m_tovNectarCurves, and m_tovPollenCurves.

Referenced by VegElement::SetVegType().

Member Data Documentation

◆ m_tole_pollencurvetable

vector<int> PollenNectarDevelopmentData::m_tole_pollencurvetable
protected

Definition at line 243 of file plants.h.

Referenced by GetPollenNectarCurvePtr(), and PollenNectarDevelopmentData().

◆ m_toleNectarCurves

vector<PollenNectarDevelopmentCurve*> PollenNectarDevelopmentData::m_toleNectarCurves
protected

◆ m_tolePollenCurves

vector<PollenNectarDevelopmentCurve*> PollenNectarDevelopmentData::m_tolePollenCurves
protected

◆ m_tov_pollencurvetable

vector<int> PollenNectarDevelopmentData::m_tov_pollencurvetable
protected

Definition at line 242 of file plants.h.

Referenced by PollenNectarDevelopmentData(), and tovGetPollenNectarCurvePtr().

◆ m_tovNectarCurves

vector<PollenNectarDevelopmentCurve*> PollenNectarDevelopmentData::m_tovNectarCurves
protected

◆ m_tovPollenCurves

vector<PollenNectarDevelopmentCurve*> PollenNectarDevelopmentData::m_tovPollenCurves
protected

The documentation for this class was generated from the following files:
PollenNectarDevelopmentData::m_tov_pollencurvetable
vector< int > m_tov_pollencurvetable
Definition: plants.h:242
tole_UnsprayedFieldMargin
Definition: tole_declaration.h:72
Landscape::TranslateVegTypes
TTypesOfVegetation TranslateVegTypes(int VegReference)
Definition: landscape.h:1655
g_letype
class LE_TypeClass * g_letype
Definition: elements.cpp:277
tov_Undefined
Definition: tov_declaration.h:114
PollenNectarDevelopmentCurveSet
Definition: plants.h:209
PollenNectarDevelopmentData::m_tolePollenCurves
vector< PollenNectarDevelopmentCurve * > m_tolePollenCurves
Definition: plants.h:240
PollenNectarDevelopmentCurveSet::m_pollencurveptr
PollenNectarDevelopmentCurve * m_pollencurveptr
Definition: plants.h:211
PollenNectarDevelopmentData::m_toleNectarCurves
vector< PollenNectarDevelopmentCurve * > m_toleNectarCurves
Definition: plants.h:241
tole_Foobar
Definition: tole_declaration.h:111
g_msg
class MapErrorMsg * g_msg
Definition: maperrormsg.cpp:41
LE_TypeClass::TranslateEleTypes
TTypesOfLandscapeElement TranslateEleTypes(int EleReference)
Definition: elements.cpp:2995
PollenNectarDevelopmentData::m_tovNectarCurves
vector< PollenNectarDevelopmentCurve * > m_tovNectarCurves
Definition: plants.h:239
MapErrorMsg::Warn
void Warn(MapErrorState a_level, std::string a_msg1, std::string a_msg2)
Definition: maperrormsg.cpp:59
PollenNectarDevelopmentCurve
A standard class to contain a pollen or nectar curve based on indexed rates.
Definition: plants.h:183
PollenNectarDevelopmentCurveSet::m_nectarcurveptr
PollenNectarDevelopmentCurve * m_nectarcurveptr
Definition: plants.h:212
PollenNectarDevelopmentData::m_tovPollenCurves
vector< PollenNectarDevelopmentCurve * > m_tovPollenCurves
Definition: plants.h:238
tole_Field
Definition: tole_declaration.h:43
PollenNectarDevelopmentData::m_tole_pollencurvetable
vector< int > m_tole_pollencurvetable
Definition: plants.h:243
cfg_pollen_nectar_on
CfgBool cfg_pollen_nectar_on
Flag to determine whether nectar and pollen models are used - should be set to true for pollinator mo...
CfgBool::value
bool value(void)
Definition: configurator.h:135