Loading [MathJax]/extensions/ams.js
ALMaSS  1.2 (after EcoStack, March 2024)
The Animal, Landscape and Man Simulation System
All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PesticideTable Class Reference

#include <Pesticide.h>

Inheritance diagram for PesticideTable:
PesticideOutput

Public Member Functions

 PesticideTable (int a_startyear, int a_noyears, int a_cellsize, Landscape *a_landscape, RasterMap *a_land)
 
 ~PesticideTable ()
 
virtual void Spray (LE *a_element_sprayed, TTypesOfPesticideCategory a_type)
 
virtual void PrintPTable ()
 
void PrintITable ()
 
void PrintHTable ()
 
void PrintFTable ()
 
void Clear ()
 
- Public Member Functions inherited from PesticideOutput
 PesticideOutput (int a_startyear, int a_noyears, int a_cellsize, Landscape *a_landscape, RasterMap *a_land)
 
 ~PesticideOutput ()
 

Protected Attributes

ofstream * m_PTableI
 
ofstream * m_PTableH
 
ofstream * m_PTableF
 
- Protected Attributes inherited from PesticideOutput
vector< double > * m_pmap_insecticides
 insecticide map/table data More...
 
vector< double > * m_pmap_fungicides
 herbicide map/table data More...
 
vector< double > * m_pmap_herbicides
 fungicide map/table data More...
 
int m_startyear
 first simultion year to record More...
 
int m_endyear
 last year of data to record More...
 
int m_cellsize
 the size of the cell for pesticide data in m More...
 
int m_pmap_width
 based on cellsize the width of the map More...
 
int m_pmap_height
 based on cellsize the height of the map More...
 
Landscapem_OurLandscape
 pointer to the landscape
More...
 
RasterMapm_Rastermap
 pointer to the landscape map More...
 

Constructor & Destructor Documentation

◆ PesticideTable()

PesticideTable::PesticideTable ( int  a_startyear,
int  a_noyears,
int  a_cellsize,
Landscape a_landscape,
RasterMap a_land 
)
1896  : PesticideOutput(a_startyear, a_noyears, a_cellsize, a_landscape, a_land)
1897 {
1898  // We need all three in this case
1900  m_pmap_insecticides = new vector<double>;
1901  m_pmap_insecticides->resize(sz+1);
1902  fill(m_pmap_insecticides->begin(), m_pmap_insecticides->end(), 0);
1903  m_pmap_herbicides = new vector<double>;
1904  m_pmap_herbicides->resize(sz);
1905  fill(m_pmap_herbicides->begin(), m_pmap_herbicides->end(), 0);
1906  m_pmap_fungicides = new vector<double>;
1907  m_pmap_fungicides->resize(sz);
1908  fill(m_pmap_fungicides->begin(), m_pmap_fungicides->end(), 0);
1909 
1910  m_PTableI = new ofstream("ALMaSS_InsecticideTable.txt", ios::out);
1911  (*m_PTableI) << "Years" << ' ' << a_noyears << endl;
1912  m_PTableH = new ofstream("ALMaSS_HerbicideTable.txt", ios::out);
1913  (*m_PTableH) << "Years" << ' ' << a_noyears << endl;
1914  m_PTableF = new ofstream("ALMaSS_FungicideTable.txt", ios::out);
1915  (*m_PTableF) << "Years" << ' ' << a_noyears << endl;
1916 }

References PesticideOutput::m_OurLandscape, PesticideOutput::m_pmap_fungicides, PesticideOutput::m_pmap_herbicides, PesticideOutput::m_pmap_insecticides, m_PTableF, m_PTableH, m_PTableI, and Landscape::SupplyLargestPolyNumUsed().

◆ ~PesticideTable()

PesticideTable::~PesticideTable ( )
inline
780  {
781  m_PTableI->close();
782  m_PTableH->close();
783  m_PTableF->close();
784  }

References m_PTableF, m_PTableH, and m_PTableI.

Member Function Documentation

◆ Clear()

void PesticideTable::Clear ( )
inline
790  {
791  fill(m_pmap_insecticides->begin(), m_pmap_insecticides->end(), 0.0);
792  fill(m_pmap_herbicides->begin(), m_pmap_herbicides->end(), 0.0);
793  fill(m_pmap_fungicides->begin(), m_pmap_fungicides->end(), 0.0);
794  }

References PesticideOutput::m_pmap_fungicides, PesticideOutput::m_pmap_herbicides, and PesticideOutput::m_pmap_insecticides.

◆ PrintFTable()

void PesticideTable::PrintFTable ( )
1984 {
1985  string fname = "ALMaSS_FungicideTable.txt";
1986  {
1987  if (!(*m_PTableF).is_open())
1988  {
1989  g_msg->Warn(WARN_FILE, "FungicideTable::TableFile Unable to open file for append: ", fname.c_str());
1990  exit(1);
1991  }
1992  // File is OK, save the table
1993  (*m_PTableF) << "Year " << g_date->GetYearNumber() << " Month " << g_date->GetMonth() << " Day " << g_date->GetDayInMonth() << endl;
1994  for (int i = 0; i < m_pmap_fungicides->size(); i++)
1995  {
1996  if ((*m_pmap_fungicides)[i] > 0.0)
1997  {
1998  (*m_PTableF) << i << '\t' << (*m_pmap_fungicides)[i] << endl;
1999  }
2000  }
2001  }
2002  fill(m_pmap_fungicides->begin(), m_pmap_fungicides->end(), 0);
2003 }

References g_date, g_msg, Calendar::GetDayInMonth(), Calendar::GetMonth(), Calendar::GetYearNumber(), PesticideOutput::m_pmap_fungicides, MapErrorMsg::Warn(), and WARN_FILE.

Referenced by PrintPTable().

◆ PrintHTable()

void PesticideTable::PrintHTable ( )
1962 {
1963  string fname = "ALMaSS_HerbicideTable.txt";
1964  {
1965  if (!(*m_PTableH).is_open())
1966  {
1967  g_msg->Warn(WARN_FILE, "HerbicideTable::TableFile Unable to open file for append: ", fname.c_str());
1968  exit(1);
1969  }
1970  // File is OK, save the table
1971  (*m_PTableH) << "Year " << g_date->GetYearNumber() << " Month " << g_date->GetMonth() << " Day " << g_date->GetDayInMonth() << endl;
1972  for (int i = 0; i < m_pmap_herbicides->size(); i++)
1973  {
1974  if ((*m_pmap_herbicides)[i] > 0.0)
1975  {
1976  (*m_PTableH) << i << '\t' << (*m_pmap_herbicides)[i] << endl;
1977  }
1978  }
1979  }
1980  fill(m_pmap_herbicides->begin(), m_pmap_herbicides->end(), 0);
1981 }

References g_date, g_msg, Calendar::GetDayInMonth(), Calendar::GetMonth(), Calendar::GetYearNumber(), PesticideOutput::m_pmap_herbicides, MapErrorMsg::Warn(), and WARN_FILE.

Referenced by PrintPTable().

◆ PrintITable()

void PesticideTable::PrintITable ( )
1940 {
1941  string fname = "ALMaSS_InsecticideTable.txt";
1942  {
1943  if (!(*m_PTableI).is_open())
1944  {
1945  g_msg->Warn(WARN_FILE, "PesticideTable::TableFile Unable to open file for append: ", fname.c_str());
1946  exit(1);
1947  }
1948  // File is OK, save the table
1949  (*m_PTableI) << "Year " << g_date->GetYearNumber() << " Month " << g_date->GetMonth() << " Day " << g_date->GetDayInMonth() << endl;
1950  for (int i = 0; i < m_pmap_insecticides->size(); i++)
1951  {
1952  if ((*m_pmap_insecticides)[i] > 0.0)
1953  {
1954  (*m_PTableI) << i << '\t' << (*m_pmap_insecticides)[i] << endl;
1955  }
1956  }
1957  }
1958  fill(m_pmap_insecticides->begin(), m_pmap_insecticides->end(), 0);
1959 }

References g_date, g_msg, Calendar::GetDayInMonth(), Calendar::GetMonth(), Calendar::GetYearNumber(), PesticideOutput::m_pmap_insecticides, MapErrorMsg::Warn(), and WARN_FILE.

Referenced by PrintPTable().

◆ PrintPTable()

void PesticideTable::PrintPTable ( )
virtual
1933 {
1934  PrintITable();
1935  PrintHTable();
1936  PrintFTable();
1937 }

References PrintFTable(), PrintHTable(), and PrintITable().

◆ Spray()

void PesticideTable::Spray ( LE a_element_sprayed,
TTypesOfPesticideCategory  a_type 
)
virtual

This records a 1 in the polygon ref table for every field where pesticide is applied. This does not record drift.

This method first determines what type of pesticide and selects the correct map to record on.

Reimplemented from PesticideOutput.

1919 {
1926  int index = a_element_sprayed->GetPoly();
1927  if (a_type == fungicide) (*m_pmap_fungicides)[index]+=1.0;
1928  else if (a_type == herbicide) (*m_pmap_herbicides)[index] += 1.0;
1929  else (*m_pmap_insecticides)[index] += 1.0;
1930 }

References fungicide, LE::GetPoly(), herbicide, and PesticideOutput::m_pmap_insecticides.

Member Data Documentation

◆ m_PTableF

ofstream* PesticideTable::m_PTableF
protected

Referenced by PesticideTable(), and ~PesticideTable().

◆ m_PTableH

ofstream* PesticideTable::m_PTableH
protected

Referenced by PesticideTable(), and ~PesticideTable().

◆ m_PTableI

ofstream* PesticideTable::m_PTableI
protected

Referenced by PesticideTable(), and ~PesticideTable().


The documentation for this class was generated from the following files:
WARN_FILE
Definition: MapErrorMsg.h:37
PesticideTable::m_PTableH
ofstream * m_PTableH
Definition: Pesticide.h:798
Calendar::GetYearNumber
int GetYearNumber(void)
Definition: Calendar.h:72
PesticideTable::PrintITable
void PrintITable()
Definition: Pesticide.cpp:1939
LE::GetPoly
int GetPoly(void)
Returns the polyref number for this polygon.
Definition: Elements.h:238
g_date
class Calendar * g_date
Definition: Calendar.cpp:37
Calendar::GetMonth
int GetMonth(void)
Definition: Calendar.h:73
Calendar::GetDayInMonth
int GetDayInMonth(void)
Definition: Calendar.h:77
PesticideTable::m_PTableF
ofstream * m_PTableF
Definition: Pesticide.h:799
PesticideOutput::m_pmap_insecticides
vector< double > * m_pmap_insecticides
insecticide map/table data
Definition: Pesticide.h:754
fungicide
Definition: LandscapeFarmingEnums.h:1050
MapErrorMsg::Warn
void Warn(MapErrorState a_level, std::string a_msg1, std::string a_msg2)
Definition: MapErrorMsg.cpp:69
PesticideTable::PrintHTable
void PrintHTable()
Definition: Pesticide.cpp:1961
PesticideTable::m_PTableI
ofstream * m_PTableI
Definition: Pesticide.h:797
herbicide
Definition: LandscapeFarmingEnums.h:1050
PesticideTable::PrintFTable
void PrintFTable()
Definition: Pesticide.cpp:1983
g_msg
MapErrorMsg * g_msg
Definition: MapErrorMsg.cpp:41
PesticideOutput::m_OurLandscape
Landscape * m_OurLandscape
pointer to the landscape
Definition: Pesticide.h:770
PesticideOutput::m_pmap_herbicides
vector< double > * m_pmap_herbicides
fungicide map/table data
Definition: Pesticide.h:758
PesticideOutput::PesticideOutput
PesticideOutput(int a_startyear, int a_noyears, int a_cellsize, Landscape *a_landscape, RasterMap *a_land)
Definition: Pesticide.cpp:1774
Landscape::SupplyLargestPolyNumUsed
int SupplyLargestPolyNumUsed()
Returns m_LargestPolyNumUsed.
Definition: Landscape.h:578
PesticideOutput::m_pmap_fungicides
vector< double > * m_pmap_fungicides
herbicide map/table data
Definition: Pesticide.h:756