![]() |
ALMaSS
1.2 (after EcoStack, March 2024)
The Animal, Landscape and Man Simulation System
|
#include <Pesticide.h>
Public Member Functions | |
void | Tick (void) |
Main pesticide method that is called every day. More... | |
void | DailyQueueAdd (LE *a_element_sprayed, double a_amount, PlantProtectionProducts a_ppp, int a_drifttype=0) |
Adds new pesticide spray event to the daily queue. More... | |
void | DailyQueueAddSeedCoating (LE *a_element_sprayed, double a_amount, PlantProtectionProducts a_ppp) |
Adds new seed coating event to the daily queue. More... | |
void | DailyQueueAddGranular (LE *a_element_sprayed, double a_amount, PlantProtectionProducts a_ppp) |
Adds new granular application event to the daily queue. More... | |
bool | GetAnythingToDecay (PlantProtectionProducts a_ppp) |
Checks if there are any pesticides to decay. More... | |
void | RemovePlantPesticide (int a_minx, int a_maxx, int a_miny, int a_maxy, int a_map_index) |
Sets all plant pesticide maps (so all except soil) to 0. More... | |
void | ReducePlantPesticide (int a_minx, int a_maxx, int a_miny, int a_maxy, int a_map_index, float a_reduc, bool a_remove_from_surface=false) |
Reduce the amount in plant pesticide maps. Everything is removed for surface if boolean is true (used for harvest but not cutting) More... | |
void | DecreaseVegetationPesticide (int a_x, int a_y, PlantProtectionProducts a_ppp, double a_amount) |
Decrease the amount of pesticide in the vegetation compartment (used by foraging bees) More... | |
double | SupplyPesticideSeed (int a_x, int a_y, PlantProtectionProducts a_ppp) |
Supplies the seed coating pesticide amount in cell. More... | |
double | SupplyPesticideSeed (int a_polyref, PlantProtectionProducts a_ppp) |
Supplies the seed coating pesticide amount in polygon. Note that the result is not precise, since pesticide amount can vary within polygon. More... | |
double | SupplyPesticide (int a_x, int a_y, PlantProtectionProducts a_ppp) |
Supplies the pesticide amount in cell. More... | |
double | SupplyPesticide (int a_polyref, PlantProtectionProducts a_ppp) |
Supplies the pesticide amount in polygon. Note that the result is not precise, since pesticide amount can vary within polygon. More... | |
Pesticide (Landscape *a_map) | |
Constructer of pesticide engine. More... | |
virtual | ~Pesticide (void) |
Destructor of pesticide engine. More... | |
bool | RecordPesticideLoad (int a_ppp) |
Records the pesticide load at landscape level. More... | |
bool | RecordPesticideMap (int a_ppp, ofstream &outfile, vector< Eigen::MatrixXf > &map) |
Records the current pesticide amount in map. More... | |
void | RecordPesticideConcentrationPollenNectar (int a_x, int a_y, PlantProtectionProducts a_ppp, ofstream &outfile) |
Records the current pesticide concentration in pollen and nectar. More... | |
void | RecordAllPesticideCompartments (int a_x, int a_y, PlantProtectionProducts a_ppp, ofstream &outfile) |
Records the current pesticide in all compartments + biomass. More... | |
bool | SavePPM (double *a_map, int a_beginx, int a_width, int a_beginy, int a_height, char *a_filename) |
For testing of the pesticide engine. More... | |
void | DiffusionVectorTest (void) |
For saving diffusion vector in file. More... | |
Protected Member Functions | |
void | DailyQueueClear (PlantProtectionProducts a_ppp) |
Resets the pesticide action queue. More... | |
void | DailyQueueProcess (PlantProtectionProducts a_ppp) |
Sprays the pesticides that are listed in the daily queue. More... | |
bool | ElementIsWater (int a_x, int a_y) |
Checks if cell has a water type. More... | |
void | MainMapDecay (PlantProtectionProducts a_ppp) |
Applies rain washoff and decays the pesticides in all maps by calling Pesticide::DecayMap. More... | |
void | DecayMap (vector< Eigen::MatrixXf > &map, vector< double > &decay_frac, int a_ppp) |
Decays the pesticide in the entire map in a parallel manner. More... | |
void | TwinMapClear () |
Clears the twin map. More... | |
void | TwinMapSpray (LE *a_element_spryaed, double a_amount, int a_minx, int a_miny, int a_maxx, int a_maxy) |
Sprays a_amount of the pesticide in each cell in the polygon in the twin map by calling Pesticide::TwinMapSprayPixel. More... | |
void | TwinMapSprayPixel (int a_large_map_x, int a_large_map_y, double a_fractional_amount) |
Sprays pesticide in the cell. More... | |
void | TwinMapSprayCorrectBorders (void) |
Corrects the border in case the pesticide map size doens't fit the landscape map size. More... | |
void | TwinMapDiffusion (int a_minx, int a_miny, int a_maxx, int a_maxy, double a_cover, PlantProtectionProducts a_ppp) |
Diffuses the pesticide in the twin map and adds it to the main map. More... | |
void | TwinMapDiffusionMatrix (int a_minx, int a_miny, int a_maxx, int a_maxy, double a_cover, PlantProtectionProducts a_ppp, vector< Eigen::MatrixXf > *a_drift_matrices_ptr) |
Diffuses the pesticide in the twin map and adds it to the main map using Eigen. More... | |
void | DiffusionVectorInit (void) |
Initializes the diffusion vector that is used to drift the pesticide. More... | |
void | DiffusionMatrixInit (void) |
Initializes the diffusion matrices that are used to drift the pesticide. More... | |
void | DiffusionSprayPixel (int a_x, int a_limit_x, int a_y, int a_limit_y, double a_amount, double a_cover, PlantProtectionProducts a_ppp) |
Adds the diffused pesticide to the cell in the main map(s) More... | |
void | AddGranularPesticide (int a_minx, int a_miny, int a_maxx, int a_maxy, double a_cover, PlantProtectionProducts a_ppp) |
Adds granular pesticide to polygon. More... | |
Protected Attributes | |
bool | m_something_to_decay [ppp_foobar] |
Main class for pesticide engine. More... | |
bool | m_seedcoating_to_decay [ppp_foobar] |
Structure to keep track of whether there is any seed coating to decay or transfer. More... | |
int | m_NoPPPs |
The number of active PPPs to track. More... | |
int | m_x_excess |
int | m_y_excess |
double | m_prop |
Constant related to the grid area (i.e. how many landscape map squares are in one grid square). More... | |
double | m_corr_x |
Corrected proportions for the edge squares along the x-axis. More... | |
double | m_corr_y |
Corrected proportions for the edge squares along the y-axis. More... | |
int | m_wind |
The daily wind direction. More... | |
int | m_pest_drift_max |
The maximum distance away from the spraying point we want to consider the pesticide drift downwind. More... | |
vector< double > | m_pest_daily_decay_frac |
Daily decay fraction, precalculated from the pesticide environmental half life parameter, for one pesticide compartment use. More... | |
vector< double > | m_dead_biomass |
Vector saving the dead biomass in each polygon from the previous day. More... | |
vector< double > | m_green_biomass |
Vector saving the green biomass in each polygon from the previous day. More... | |
vector< double > | m_pollen_mass |
Vector saving the pollen in each polygon from the previous day. More... | |
vector< double > | m_nectar_mass |
Vector saving the nectar in each polygon from the previous day. More... | |
RasterMap * | m_land |
Local copy of pointer to the main map object. More... | |
Landscape * | m_map |
Local copy of pointer to the main landscape object. More... | |
vector< Eigen::MatrixXf > | m_pest_map_main |
Map to track the pesticide amount. More... | |
Eigen::MatrixXf | m_pest_map_twin |
A temporary map used when new pesticide is sprayed. More... | |
vector< vector< double > > | m_pest_map_record |
If we are recording pesticide load we need this map. More... | |
unsigned int | m_pest_map_size |
The total size of one map in cellsize resolution. More... | |
unsigned int | m_pest_map_width |
The width of one map in cellsize resolution. More... | |
unsigned int | m_pest_map_height |
The height of one map in cellsize resolution. More... | |
vector< vector< double > > | m_RainWashoffFactor |
a structure to hold pre-calculated pesticide rain washoff factor (Rw) More... | |
unsigned | m_rainfallcategory |
Daily rainfall saved here * 100 to use as an index to the Pesticide::m_RainWashoffFactor array - an optimisation to stop repeated calls to Landscape::SupplyRain. More... | |
vector< double > | m_diffusion_vector |
Pre-calculated diffusion vector. More... | |
vector< Eigen::MatrixXf > | m_diffusion_matrices |
Pre-calculated diffusion matrices Used after spraying an element in the pesticide map to determine how much of the sprayed material spreads into the surroundings. More... | |
vector< Eigen::MatrixXf > | m_diffusion_matrices_orchard_early |
Pre-calculated diffusion matrices for orchards (early application) More... | |
vector< Eigen::MatrixXf > | m_diffusion_matrices_orchard_late |
Pre-calculated diffusion matrices for orchards (late application) More... | |
vector< Eigen::MatrixXf > | m_diffusion_matrices_vineyard_early |
Pre-calculated diffusion matrices for vineyards (early application) More... | |
vector< Eigen::MatrixXf > | m_diffusion_matrices_vineyard_late |
Pre-calculated diffusion matrices for vineyards (late application) More... | |
vector< Eigen::MatrixXf > | m_diffusion_matrices_dust_drift |
Pre-calculated diffusion matrices for dust drift, used for seed coating and granular application. More... | |
float | m_dust_drift_remainder |
Remaining pesticide at 0 meter after dust drift, used for seed coating and granular application. More... | |
int | m_orchard_drift_type |
Type of orchard drift, can be early or late application. More... | |
int | m_drift_distance |
Length of drift vector. How far away from spraying point we consider drift. More... | |
vector< vector< PesticideEvent * > > | m_daily_spray_queue |
List of landscape elements, which was sprayed on a given day. One for each PPP we track. More... | |
vector< vector< PesticideEvent * > > | m_daily_seedcoating_queue |
List of landscape elements, which had seed coating on a given day. One for each PPP we track. More... | |
vector< vector< PesticideEvent * > > | m_daily_granular_queue |
List of landscape elements, which had a granular application on a given day. One for each PPP we track. More... | |
ofstream | m_pesticideRecord |
a file for recording pesticide loads More... | |
ofstream | m_pesticide_file_rec |
ofstream | m_pesticide_file_rec_all_comp |
File for recording pesticide in all compartments including biomass etc. More... | |
Pesticide::Pesticide | ( | Landscape * | a_map | ) |
Constructer of pesticide engine.
If the pesticide engine is on, then maps and vectors are initialized here. The rain washoff factor and diffusion vector are also calculated.
References DiffusionMatrixInit(), DiffusionVectorInit(), DiffusionVectorTest(), g_landscape_ptr, l_pest_enable_pesticide_engine, l_pest_NoPPPs, l_pest_record_grid_size, l_pest_record_used, l_pest_save_all_compartments, l_pest_save_map_daily, l_pest_use_single_nozzle_drift, m_corr_x, m_corr_y, m_daily_granular_queue, m_daily_seedcoating_queue, m_daily_spray_queue, m_dead_biomass, m_green_biomass, m_land, m_map, m_nectar_mass, m_NoPPPs, m_pest_drift_max, m_pest_map_height, m_pest_map_main, m_pest_map_record, m_pest_map_size, m_pest_map_twin, m_pest_map_width, m_pesticide_file_rec, m_pesticide_file_rec_all_comp, m_pesticideRecord, m_pollen_mass, m_prop, m_RainWashoffFactor, m_seedcoating_to_decay, m_something_to_decay, m_x_excess, m_y_excess, RasterMap::MapHeight(), RasterMap::MapWidth(), PEST_GRIDAREA, PEST_GRIDSIZE, PEST_GRIDSIZE_POW2, Landscape::SupplyMaxPoly(), Landscape::SupplyRasterMap(), CfgInt::value(), and CfgBool::value().
Referenced by CreatePesticide().
|
protected |
Adds granular pesticide to polygon.
References l_pest_enable_dust_drift, m_diffusion_matrices_dust_drift, m_dust_drift_remainder, m_pest_map_main, m_pest_map_twin, TwinMapDiffusionMatrix(), and CfgBool::value().
Referenced by DailyQueueProcess().
void Pesticide::DailyQueueAdd | ( | LE * | a_element_sprayed, |
double | a_amount, | ||
PlantProtectionProducts | a_ppp, | ||
int | a_drifttype = 0 |
||
) |
Adds new pesticide spray event to the daily queue.
Pesticide spraying event is added to the end of the daily spraying queue.
References m_daily_spray_queue.
Referenced by Orchard::DoDevelopment(), OrchardBand::DoDevelopment(), Farm::ProductApplication(), and Farm::ProductApplication_DateLimited().
void Pesticide::DailyQueueAddGranular | ( | LE * | a_element_sprayed, |
double | a_amount, | ||
PlantProtectionProducts | a_ppp | ||
) |
Adds new granular application event to the daily queue.
Pesticide granular applicaiton event is added to the end of the daily granular queue.
References m_daily_granular_queue.
Referenced by Farm::ProductApplication(), and Farm::ProductApplication_DateLimited().
void Pesticide::DailyQueueAddSeedCoating | ( | LE * | a_element_sprayed, |
double | a_amount, | ||
PlantProtectionProducts | a_ppp | ||
) |
Adds new seed coating event to the daily queue.
Pesticide seed coating event is added to the end of the daily seed coating queue.
References m_daily_seedcoating_queue.
Referenced by Farm::AutumnSow(), Farm::AutumnSowWithFerti(), Farm::PreseedingCultivatorSow(), Farm::SpringSow(), Farm::SpringSowWithFerti(), and Farm::StriglingSow().
|
protected |
Resets the pesticide action queue.
Empties and resets the pesticide action queue. On calling any event not yet carried out will be deleted.
References m_daily_granular_queue, m_daily_seedcoating_queue, and m_daily_spray_queue.
Referenced by Tick().
|
protected |
Sprays the pesticides that are listed in the daily queue.
Method runs if we are spraying at least one field. Sets something_to_decay to true so the decay method will run tomorrow. First we make sure the twin map is cleared. Then we add the amount m_amount to the twin map (all squares covered with the polygon get m_amount added) using TwinMapSpray
Next this twin map is added to the main map taking into acount drift and if necessary it is here we sort out the allocation between different compartments. This is done by TwinMapDiffusion
References AddGranularPesticide(), g_msg, l_pest_use_single_nozzle_drift, m_daily_granular_queue, m_daily_seedcoating_queue, m_daily_spray_queue, m_diffusion_matrices, m_diffusion_matrices_orchard_early, m_diffusion_matrices_orchard_late, m_diffusion_matrices_vineyard_early, m_diffusion_matrices_vineyard_late, m_something_to_decay, tole_Orchard, tole_Vineyard, TwinMapClear(), TwinMapDiffusion(), TwinMapDiffusionMatrix(), TwinMapSpray(), CfgBool::value(), MapErrorMsg::Warn(), and WARN_FATAL.
Referenced by Tick().
|
protected |
Decays the pesticide in the entire map in a parallel manner.
Loops over each cell in the map and decays the pesticide.
Referenced by MainMapDecay().
void Pesticide::DecreaseVegetationPesticide | ( | int | a_x, |
int | a_y, | ||
PlantProtectionProducts | a_ppp, | ||
double | a_amount | ||
) |
Decrease the amount of pesticide in the vegetation compartment (used by foraging bees)
References l_pest_enable_pesticide_engine, m_pest_map_width, PEST_GRIDSIZE_POW2, and CfgBool::value().
|
protected |
Initializes the diffusion matrices that are used to drift the pesticide.
References g_landscape_ptr, LE::GetMaxX(), LE::GetMaxY(), LE::GetMinX(), LE::GetMinY(), m_diffusion_matrices, m_diffusion_matrices_dust_drift, m_diffusion_matrices_orchard_early, m_diffusion_matrices_orchard_late, m_diffusion_matrices_vineyard_early, m_diffusion_matrices_vineyard_late, m_drift_distance, m_dust_drift_remainder, Landscape::SupplyElementTypeFromVector(), Landscape::SupplyMaxPoly(), Landscape::SupplyPolyLEptr(), tole_Field, tole_Orchard, and tole_Vineyard.
Referenced by Pesticide().
|
inlineprotected |
Adds the diffused pesticide to the cell in the main map(s)
This sprays the pesticide (a_amount) by placing this into a pesticide cell in the main map. If more detailed pesticide fate is needed then a_amount will be partitioned between soil and canopy.
First a test is made to ensure that the coordinates given are within the landscape. If not the pesticide is sprayed off world, and lost.
Partioning, if occuring, is done based on two components - the canopy and the soil. The pesticide is partioned between the two based on the asssumed vegetation cover of the crop based on Beer's Law.
References l_pest_record_used, m_pest_map_main, m_pest_map_record, and CfgBool::value().
Referenced by TwinMapDiffusion().
|
protected |
Initializes the diffusion vector that is used to drift the pesticide.
The diffusion vector depends on the type of nozzle and the driving speed (7.2 or 14.4 km/h) The diffusion vectors are derived from the results in "Single Nozzle spray drift measurements of drift reducing nozzles at two forward speed" by H Stallinga et al. The results are found in table form in the Dutch report names "Enkeldops validatiemetingen driftreducerende spuitdoppen en rijsnelheid". The first entry is 1 meter up wind, the second is at the spraying point and the rest are from 1 to 10 meter downwind.
References l_pest_driving_slow, l_pest_nozzle_type, m_diffusion_vector, CfgInt::value(), and CfgBool::value().
Referenced by Pesticide().
void Pesticide::DiffusionVectorTest | ( | void | ) |
For saving diffusion vector in file.
For debugging purposes. Allows us to see the diffusion used for the point source in each cell.
References m_diffusion_vector, and m_pest_drift_max.
Referenced by Pesticide().
|
inlineprotected |
Checks if cell has a water type.
References m_map, Landscape::SupplyElementType(), tole_FishFarm, tole_Freshwater, tole_Pond, tole_River, and tole_Saltwater.
Referenced by SupplyPesticide().
|
inline |
Checks if there are any pesticides to decay.
References m_something_to_decay.
Referenced by Landscape::SupplyPesticideDecay().
|
protected |
Applies rain washoff and decays the pesticides in all maps by calling Pesticide::DecayMap.
This is where the environmental decay takes place. Here we assume a first order decay based on a daily proportion of the cell total. If using detailed fate modelling first the rain wash-off is calculated, transfering some of the pesticide from the plant surface to the soil. The decay of each map is done by calling the DecayMap method.
References DecayMap(), g_landscape_ptr, LE::GetDeadBiomass(), LE::GetGreenBiomass(), LE::GetMaxX(), LE::GetMaxY(), LE::GetMinX(), LE::GetMinY(), l_pest_zero_threshold, m_dead_biomass, m_green_biomass, m_map, m_nectar_mass, m_pest_daily_decay_frac, m_pest_map_main, m_pollen_mass, m_rainfallcategory, m_RainWashoffFactor, m_something_to_decay, Landscape::SupplyMaxPoly(), Landscape::SupplyNectarQuantity(), Landscape::SupplyPesticide(), Landscape::SupplyPollenQuantity(), Landscape::SupplyPolyIdMapPtr(), Landscape::SupplyPolyLEptr(), Landscape::SupplyVegCover(), and CfgFloat::value().
Referenced by Tick().
void Pesticide::RecordAllPesticideCompartments | ( | int | a_x, |
int | a_y, | ||
PlantProtectionProducts | a_ppp, | ||
ofstream & | outfile | ||
) |
Records the current pesticide in all compartments + biomass.
Print out pesticide in all compartments and biomass
References Calendar::Date(), g_date, LE::GetVegDDegs(), m_map, m_pest_map_main, PEST_GRIDSIZE_POW2, Landscape::SupplyDeadBiomass(), Landscape::SupplyGreenBiomass(), Landscape::SupplyNectarQuantity(), Landscape::SupplyPollenQuantity(), Landscape::SupplyPolyLEptr(), Landscape::SupplyVegBiomass(), and Landscape::SupplyVegHeight().
Referenced by Tick().
void Pesticide::RecordPesticideConcentrationPollenNectar | ( | int | a_x, |
int | a_y, | ||
PlantProtectionProducts | a_ppp, | ||
ofstream & | outfile | ||
) |
Records the current pesticide concentration in pollen and nectar.
Referenced by Tick().
bool Pesticide::RecordPesticideLoad | ( | int | a_ppp | ) |
Records the pesticide load at landscape level.
The challenge here is that we do not know in advance the size of the pesticide grid, so this needs to be included in the translation of the pesticide grid to the output grid. This is done here rather than when m_pest_map_record is filled since this needs to be done only once here, rather than every time a pesticide amount is applied. To get to the pesticide grid the formula is (PEST_GRID_SIZE * grid ref) = ALMaSS Coord. ALMaSS Coord/Grid Size = index.
References Calendar::Date(), g_date, l_pest_record_grid_size, m_land, m_pest_map_height, m_pest_map_record, m_pest_map_width, m_pesticideRecord, RasterMap::MapHeight(), RasterMap::MapWidth(), PEST_GRIDSIZE, and CfgInt::value().
Referenced by Tick().
bool Pesticide::RecordPesticideMap | ( | int | a_ppp, |
ofstream & | outfile, | ||
vector< Eigen::MatrixXf > & | map | ||
) |
Records the current pesticide amount in map.
Saves the pesticide amount together with the type of pesticide and the date. This is a very heavy operation if it is called every day.
References Calendar::Date(), g_date, l_pest_record_grid_size, m_land, m_pest_map_height, m_pest_map_width, RasterMap::MapHeight(), RasterMap::MapWidth(), PEST_GRIDSIZE, and CfgInt::value().
Referenced by Tick().
void Pesticide::ReducePlantPesticide | ( | int | a_minx, |
int | a_maxx, | ||
int | a_miny, | ||
int | a_maxy, | ||
int | a_map_index, | ||
float | a_reduc, | ||
bool | a_remove_from_surface = false |
||
) |
Reduce the amount in plant pesticide maps. Everything is removed for surface if boolean is true (used for harvest but not cutting)
Sets every entry in vegcanopy, in vegetation and seed maps to 0
References g_landscape_ptr, g_msg, l_pest_enable_pesticide_engine, m_NoPPPs, Landscape::SupplyPolyIdMapPtr(), CfgBool::value(), and MapErrorMsg::Warn().
Referenced by Farm::BulbHarvest(), FlowerStrip::Cutting(), FieldBoundary::Cutting(), RoadsideVerge::Cutting(), Orchard::Cutting(), MownGrassStrip::Cutting(), VegElement::GrazeVegetation(), VegElement::GrazeVegetationHeight(), Farm::Harvest(), Farm::HarvestLong(), VegElement::ReduceVeg(), and VegElement::ReduceVeg_Extended().
void Pesticide::RemovePlantPesticide | ( | int | a_minx, |
int | a_maxx, | ||
int | a_miny, | ||
int | a_maxy, | ||
int | a_map_index | ||
) |
Sets all plant pesticide maps (so all except soil) to 0.
Sets every entry in vegcanopy, in vegetation and seed maps to 0
References g_landscape_ptr, l_pest_enable_pesticide_engine, m_NoPPPs, Landscape::SupplyPolyIdMapPtr(), and CfgBool::value().
Referenced by VegElement::ZeroVeg().
bool Pesticide::SavePPM | ( | double * | a_map, |
int | a_beginx, | ||
int | a_width, | ||
int | a_beginy, | ||
int | a_height, | ||
char * | a_filename | ||
) |
For testing of the pesticide engine.
References g_msg, m_pest_map_height, m_pest_map_width, SV_UINT32, SV_UINT8, MapErrorMsg::Warn(), and WARN_FATAL.
|
inline |
Supplies the pesticide amount in polygon. Note that the result is not precise, since pesticide amount can vary within polygon.
a_ele | the polygon reference number of the relevant polygon |
a_ppp | the index number of the pesticide asked for |
References m_map, m_pest_map_main, m_pest_map_width, and Landscape::SupplyPesticideCell().
|
inline |
Supplies the pesticide amount in cell.
a_x | the x-coord in landscape x units |
a_y | the y-coord in landscape x units |
a_ppp | the index number of the pesticide asked for |
References ElementIsWater(), m_pest_map_main, and PEST_GRIDSIZE_POW2.
Referenced by Landscape::SupplyPesticide(), Landscape::SupplyPesticideInPlant(), Landscape::SupplyPesticideNectar(), Landscape::SupplyPesticideP(), Landscape::SupplyPesticidePlantSurface(), Landscape::SupplyPesticidePollen(), and Landscape::SupplyPesticideS().
double Pesticide::SupplyPesticideSeed | ( | int | a_polyref, |
PlantProtectionProducts | a_ppp | ||
) |
Supplies the seed coating pesticide amount in polygon. Note that the result is not precise, since pesticide amount can vary within polygon.
double Pesticide::SupplyPesticideSeed | ( | int | a_x, |
int | a_y, | ||
PlantProtectionProducts | a_ppp | ||
) |
Supplies the seed coating pesticide amount in cell.
Referenced by Landscape::SupplySeedCoating().
void Pesticide::Tick | ( | void | ) |
Main pesticide method that is called every day.
Run once per day. If the pesticide engine is not on the daily queue is cleared and the method is ended. First the daily weather conditions are read (rainfall, wind direction and temperature) and the temperature-dependent decay rate is calculated. Then the pesticides, that are currently in the map, are decayed and the queued pesticides are sprayed whereafter the queue is emptied. If seed coating is turned on that is then decayed as well. If turned on, the pesticide load is saved to output files. Then as a last step the pesticides are transfered between the different compartments (only for detailed pesticide model).
References DailyQueueClear(), DailyQueueProcess(), g_date, g_land, g_weather, Calendar::GetDayInMonth(), Weather::GetTemp(), l_map_dump_veg_x, l_map_dump_veg_y, l_pest_ai_half_life, l_pest_enable_pesticide_engine, l_pest_record_used, l_pest_save_all_compartments, l_pest_save_map_daily, m_NoPPPs, m_pest_daily_decay_frac, m_pest_map_main, m_pesticide_file_rec, m_pesticide_file_rec_all_comp, m_rainfallcategory, m_wind, MainMapDecay(), ppp_1, RecordAllPesticideCompartments(), RecordPesticideConcentrationPollenNectar(), RecordPesticideLoad(), RecordPesticideMap(), Landscape::SupplyRain(), Landscape::SupplyWindDirection(), CfgInt::value(), CfgBool::value(), and CfgArray_Double::value().
Referenced by Landscape::Tick().
|
protected |
Clears the twin map.
Clears the twin map
References m_pest_map_twin.
Referenced by DailyQueueProcess().
|
protected |
Diffuses the pesticide in the twin map and adds it to the main map.
Applies drift (which depends on the wind direction) to the pesticide from the twin map and adds it to the main map by calling DiffusionSprayPixel
References DiffusionSprayPixel(), m_diffusion_vector, m_pest_drift_max, m_pest_map_height, m_pest_map_twin, m_pest_map_width, m_wind, and PEST_GRIDSIZE_POW2.
Referenced by DailyQueueProcess().
|
protected |
Diffuses the pesticide in the twin map and adds it to the main map using Eigen.
References g_landscape_ptr, m_drift_distance, m_pest_map_height, m_pest_map_main, m_pest_map_twin, m_pest_map_width, m_wind, Landscape::SupplyNectarMapPtr(), and Landscape::SupplyPollenMapPtr().
Referenced by AddGranularPesticide(), and DailyQueueProcess().
|
protected |
Sprays a_amount of the pesticide in each cell in the polygon in the twin map by calling Pesticide::TwinMapSprayPixel.
This is where the initial pesticide amount is applied to the map. A twin of the real maps is used for spraying the amount of pesticide that is sprayed over each cell and then copied to the real one by using a 'diffusion' process to spread it out to all surrounding cells for drift.
Going through the whole landscape is very slow and unnecessary for small polygons. Since our polygons do not extend beyond the edge of the map ie do not wrap round, then we only need a measure of minx, maxx, miny, maxy. This is set up at the start of the simulation.
References RasterMap::Get(), LE::GetMapIndex(), m_land, m_prop, TwinMapSprayCorrectBorders(), and TwinMapSprayPixel().
Referenced by DailyQueueProcess().
|
protected |
Corrects the border in case the pesticide map size doens't fit the landscape map size.
Checks if the borders of the pesticide map doesn't fit the landscape map and makes a correction to the affected cells if needed
References m_corr_x, m_corr_y, m_pest_map_height, m_pest_map_twin, m_pest_map_width, m_x_excess, m_y_excess, and PEST_GRIDAREA.
Referenced by TwinMapSpray().
|
inlineprotected |
Sprays pesticide in the cell.
References m_pest_map_twin, PEST_GRIDAREA, and PEST_GRIDSIZE_POW2.
Referenced by TwinMapSpray().
|
protected |
Corrected proportions for the edge squares along the x-axis.
Referenced by Pesticide(), and TwinMapSprayCorrectBorders().
|
protected |
Corrected proportions for the edge squares along the y-axis.
Referenced by Pesticide(), and TwinMapSprayCorrectBorders().
|
protected |
List of landscape elements, which had a granular application on a given day. One for each PPP we track.
Referenced by DailyQueueAddGranular(), DailyQueueClear(), DailyQueueProcess(), and Pesticide().
|
protected |
List of landscape elements, which had seed coating on a given day. One for each PPP we track.
Referenced by DailyQueueAddSeedCoating(), DailyQueueClear(), DailyQueueProcess(), and Pesticide().
|
protected |
List of landscape elements, which was sprayed on a given day. One for each PPP we track.
Referenced by DailyQueueAdd(), DailyQueueClear(), DailyQueueProcess(), and Pesticide().
|
protected |
Vector saving the dead biomass in each polygon from the previous day.
Referenced by MainMapDecay(), and Pesticide().
|
protected |
Pre-calculated diffusion matrices
Used after spraying an element in the pesticide map to determine how much of the sprayed material spreads into the surroundings.
Referenced by DailyQueueProcess(), and DiffusionMatrixInit().
|
protected |
Pre-calculated diffusion matrices for dust drift, used for seed coating and granular application.
Referenced by AddGranularPesticide(), and DiffusionMatrixInit().
|
protected |
Pre-calculated diffusion matrices for orchards (early application)
Referenced by DailyQueueProcess(), and DiffusionMatrixInit().
|
protected |
Pre-calculated diffusion matrices for orchards (late application)
Referenced by DailyQueueProcess(), and DiffusionMatrixInit().
|
protected |
Pre-calculated diffusion matrices for vineyards (early application)
Referenced by DailyQueueProcess(), and DiffusionMatrixInit().
|
protected |
Pre-calculated diffusion matrices for vineyards (late application)
Referenced by DailyQueueProcess(), and DiffusionMatrixInit().
|
protected |
Pre-calculated diffusion vector.
Referenced by DiffusionVectorInit(), DiffusionVectorTest(), and TwinMapDiffusion().
|
protected |
Length of drift vector. How far away from spraying point we consider drift.
Referenced by DiffusionMatrixInit(), and TwinMapDiffusionMatrix().
|
protected |
Remaining pesticide at 0 meter after dust drift, used for seed coating and granular application.
Referenced by AddGranularPesticide(), and DiffusionMatrixInit().
|
protected |
Vector saving the green biomass in each polygon from the previous day.
Referenced by MainMapDecay(), and Pesticide().
|
protected |
Local copy of pointer to the main map object.
Referenced by Pesticide(), RecordPesticideLoad(), RecordPesticideMap(), and TwinMapSpray().
|
protected |
Local copy of pointer to the main landscape object.
Referenced by ElementIsWater(), MainMapDecay(), Pesticide(), RecordAllPesticideCompartments(), and SupplyPesticide().
|
protected |
Vector saving the nectar in each polygon from the previous day.
Referenced by MainMapDecay(), and Pesticide().
|
protected |
The number of active PPPs to track.
Referenced by Pesticide(), ReducePlantPesticide(), RemovePlantPesticide(), and Tick().
|
protected |
Type of orchard drift, can be early or late application.
|
protected |
Daily decay fraction, precalculated from the pesticide environmental half life parameter, for one pesticide compartment use.
Referenced by MainMapDecay(), and Tick().
|
protected |
The maximum distance away from the spraying point we want to consider the pesticide drift downwind.
Referenced by DiffusionVectorTest(), Pesticide(), and TwinMapDiffusion().
|
protected |
The height of one map in cellsize resolution.
Referenced by Pesticide(), RecordPesticideLoad(), RecordPesticideMap(), SavePPM(), TwinMapDiffusion(), TwinMapDiffusionMatrix(), and TwinMapSprayCorrectBorders().
|
protected |
Map to track the pesticide amount.
Referenced by AddGranularPesticide(), DiffusionSprayPixel(), MainMapDecay(), Pesticide(), RecordAllPesticideCompartments(), SupplyPesticide(), Tick(), and TwinMapDiffusionMatrix().
|
protected |
If we are recording pesticide load we need this map.
Referenced by DiffusionSprayPixel(), Pesticide(), and RecordPesticideLoad().
|
protected |
The total size of one map in cellsize resolution.
Referenced by Pesticide().
|
protected |
A temporary map used when new pesticide is sprayed.
Referenced by AddGranularPesticide(), Pesticide(), TwinMapClear(), TwinMapDiffusion(), TwinMapDiffusionMatrix(), TwinMapSprayCorrectBorders(), and TwinMapSprayPixel().
|
protected |
The width of one map in cellsize resolution.
Referenced by DecreaseVegetationPesticide(), Pesticide(), RecordPesticideLoad(), RecordPesticideMap(), SavePPM(), SupplyPesticide(), TwinMapDiffusion(), TwinMapDiffusionMatrix(), and TwinMapSprayCorrectBorders().
|
protected |
Referenced by Pesticide(), and Tick().
|
protected |
File for recording pesticide in all compartments including biomass etc.
Referenced by Pesticide(), and Tick().
|
protected |
a file for recording pesticide loads
Referenced by Pesticide(), and RecordPesticideLoad().
|
protected |
Vector saving the pollen in each polygon from the previous day.
Referenced by MainMapDecay(), and Pesticide().
|
protected |
Constant related to the grid area (i.e. how many landscape map squares are in one grid square).
Referenced by Pesticide(), and TwinMapSpray().
|
protected |
Daily rainfall saved here * 100 to use as an index to the Pesticide::m_RainWashoffFactor array - an optimisation to stop repeated calls to Landscape::SupplyRain.
Referenced by MainMapDecay(), and Tick().
|
protected |
a structure to hold pre-calculated pesticide rain washoff factor (Rw)
Referenced by MainMapDecay(), and Pesticide().
|
protected |
Structure to keep track of whether there is any seed coating to decay or transfer.
Referenced by Pesticide().
|
protected |
Main class for pesticide engine.
Speed hack. Only actually run the daily decay routine on the pesticide map if and only if we are sure that there is some pesticide anywhere on the map for us to process.
Cleared daily by MainMapDecay().
Set to true when either adding pesticide to the map, or by the MainMapDecay() method itself, when it finds remains of pesticide anywhere on the pesticide map during its run. One copy is needed for each active PPP
Referenced by DailyQueueProcess(), GetAnythingToDecay(), MainMapDecay(), and Pesticide().
|
protected |
The daily wind direction.
Referenced by Tick(), TwinMapDiffusion(), and TwinMapDiffusionMatrix().
|
protected |
Main map x-coordinate beyond which we have to use special proportional constants when adding new amounts of pesticide to the pesticide map to maintain a mass balance.
Referenced by Pesticide(), and TwinMapSprayCorrectBorders().
|
protected |
Main map y-coordinate beyond which we have to use special proportional constants when adding new amounts of pesticide to the pesticide map to maintain a mass balance.
Referenced by Pesticide(), and TwinMapSprayCorrectBorders().