ALMaSS  1.2 (after EcoStack, March 2024)
The Animal, Landscape and Man Simulation System
Weather Class Reference

#include <Weather.h>

Public Member Functions

 Weather (const char *a_weatherdatafile="default")
 
 ~Weather (void)
 
double GetTempHour (int hour)
 Get today's weather data at the given hour. More...
 
double GetSoilTempHour (int hour)
 
double GetWindHour (int hour)
 
double GetRainHour (int hour)
 
double GetRadiationHour (int hour)
 
double GetDDDegs (long a_date)
 
double GetGlobalRadiation (long a_date)
 
double GetGlobalRadiation (void)
 
double GetTemp (long a_date)
 Get the temperature on a particular date. More...
 
double GetSoilTemp (void)
 Get the current soil temperature. More...
 
double GetSoilTemp (long a_date)
 Get the soil temperature on a particular date. More...
 
double GetTemp (void)
 Get the temperature today. More...
 
double GetTempAfterDays (int days)
 Get the temperature at the given number of days which is the number of days after today. More...
 
double GetMinTemp (void)
 Get the min temperature today. More...
 
double GetMaxTemp (void)
 Get the max temperature today. More...
 
double GetMinTempYesterday (void)
 Get the min temperature yesterday. More...
 
double GetMaxTempYesterday (void)
 Get the max temperature yesterday. More...
 
double GetMinTempTomorrow (void)
 Get the min temperature tomorrow. More...
 
double GetMaxTempTomorrow (void)
 Get the max temperature tomorrow. More...
 
double GetRadiation (void)
 Get the max temperature today. More...
 
double GetFlyingHours (void)
 Get the max temperature today. More...
 
double GetHumidity (void)
 Get the humidity score today. More...
 
double GetHumidity (long a_date)
 Get the humidity score today. More...
 
double GetMeanTemp (long a_date, unsigned int a_period)
 
double GetRain (long a_date)
 
double GetRain (void)
 
double GetWind (long a_date)
 
double GetWind (void)
 
int GetWindDirection (void)
 Four wind directions N = 0, clockwise. More...
 
int GetWindDirection8 (void)
 Eight wind directions N = 0, NE = 1, ..., clockwise. More...
 
double GetWindDirectionRadians (void)
 East is 0, anticlockwise. More...
 
bool GetSnow (long a_date)
 
bool GetSnow (void)
 
double GetSnowDepth (void)
 Get the current snow depth. More...
 
bool Raining (void)
 
bool Get_fsoiltemp (void)
 
bool Get_fsnow (void)
 
bool Get_fminmaxtemp (void)
 
bool Get_frelhumidity (void)
 
bool Get_fsoiltemptwilight (void)
 
bool Get_fradiation (void)
 
int GetNoDays (void)
 
double GetRainPeriod (long a_date, unsigned int a_period)
 
double GetWindPeriod (long a_date, unsigned int a_period)
 
double GetTempPeriod (long a_date, unsigned int a_period)
 
double GetRHPeriod (long a_date, unsigned int a_period)
 
void Tick (void)
 
void readWeatherFile (int NoDays, ifstream &inFile)
 
void readWeatherFileHourly (int NoHours, int NoDays, ifstream &inFile)
 

Protected Member Functions

double DeriveSnowCover (double a_snowdepth, double a_rainfall, double a_temperature)
 
double DeriveSoilTemp (double a_temperature)
 

Private Attributes

vector< double > m_rain
 
vector< double > m_wind
 
vector< double > m_winddir
 
vector< double > m_winddir8
 
vector< double > m_WindDirRadians
 
vector< double > m_temp
 
vector< double > m_soiltemp
 
vector< double > m_snow
 
vector< double > m_mintemp
 
vector< double > m_maxtemp
 
vector< double > m_relhumidity
 
vector< double > m_soiltemptwilight
 
vector< double > m_radiation
 
vector< double > m_flyinghours
 
vector< vector< double > > m_rain_h
 
vector< vector< double > > m_wind_h
 
vector< vector< double > > m_winddir_h
 
vector< vector< double > > m_winddir8_h
 
vector< vector< double > > m_temp_h
 
vector< vector< double > > m_radiation_h
 
vector< vector< double > > m_soiltemp_h
 
vector< vector< double > > m_snow_h
 
vector< vector< double > > m_humidity_h
 
int m_hourly_today_index
 
bool m_fsoiltemp = false
 
bool m_fsnow = false
 
bool m_fminmaxtemp = false
 
bool m_frelhumidity = false
 
bool m_fsoiltemptwilight = false
 
bool m_fradiation = false
 
bool m_fflyinghours = false
 
double m_temptoday
 
double m_raintoday
 
double m_windtoday
 
int m_winddirtoday
 
int m_winddir8today
 
double m_WindDirTodayRadians
 
bool m_snowtoday
 
bool m_rainingtoday
 
double m_insolation
 
double m_humiditytoday
 
double m_soiltemptoday
 
double m_mintempyesterday
 
double m_maxtempyesterday
 
double m_mintemptoday
 
double m_maxtemptoday
 
double m_mintemptomorrow
 
double m_maxtemptomorrow
 
double m_radiationtoday
 
double m_flyinghourstoday
 
double m_temp_variation {0}
 
bool m_wind_valid
 
bool m_winddir_valid
 
bool m_winddir8_valid
 
long m_datemodulus
 
double m_snowdepth
 The snow depth in cm. More...
 
bool m_hourly_flag
 Flag for hourly data. More...
 
int m_NoDays
 Holds the number of days we have weather data for. More...
 
int m_weather_day
 

Constructor & Destructor Documentation

◆ Weather()

Weather::Weather ( const char *  a_weatherdatafile = "default")
218 {
219  int NoDays;
220  CfgFloat l_weather_temp_variation("WEATHER_TEMP_VARIATION", CFG_CUSTOM, 7);
221  m_temp_variation = l_weather_temp_variation.value();
222  ifstream inFile;
223  std::string filename;
224 
225  if (strcmp(a_weatherdatafile, "default") == 0)
226  filename = l_map_weather_file.value();
227  else
228  filename = a_weatherdatafile;
229 
230  std::cout << "Reading Weather File " << filename << "\n";
231  inFile.open(filename);
232  if (!inFile) {
233  g_msg->Warn(WARN_FILE, "Weather::Weather(): Unable to open file",
234  filename );
235  exit(1);
236  }
237 
238  string buf;
239  std::getline(inFile,buf);
240  try
241  {
242  NoDays = std::stoi(buf);
243  }
244  catch (const std::invalid_argument& ia) {
245  // cannot conver to int, means I am reading the header line
246  std::getline(inFile, buf);
247  try
248  {
249  NoDays = std::stoi(buf);
250  }
251  catch (const std::invalid_argument& ia) {
252  g_msg->Warn(WARN_FILE, "Weather::Weather(): File format error, expected (optional: header line and) the total number of file entries.","");
253  exit(1);
254  }
255  }
256 
257  if (NoDays == 2) { // 2 means weather file version 2 which is hourly data
258 
259 
260  //the hourly weather data file, get the number of data point
261  int NoHours;
262  std::getline(inFile, buf);
263  NoHours = std::stoi(buf);
264  if(NoHours <0){
265  g_msg->Warn(WARN_FILE, "Weather::Weather(): File format error, expected total number of file entries, got ",
266  NoHours);
267  exit(1);
268  }
269  NoDays = NoHours/24; // We have 24 hours for each day.
270  std::getline(inFile, buf); //read the header line and throw them away
271  readWeatherFileHourly(NoHours, NoDays, inFile);
272  }
273 
274  else{
275  readWeatherFile(NoDays, inFile);
276  m_NoDays = NoDays;
277  }
278 
279  Tick();
280 }

References CFG_CUSTOM, g_msg, l_map_weather_file, m_NoDays, m_temp_variation, readWeatherFile(), readWeatherFileHourly(), Tick(), CfgFloat::value(), CfgStr::value(), MapErrorMsg::Warn(), and WARN_FILE.

Referenced by CreateWeather().

◆ ~Weather()

Weather::~Weather ( void  )
660 {
661 }

Member Function Documentation

◆ DeriveSnowCover()

double Weather::DeriveSnowCover ( double  a_snowdepth,
double  a_rainfall,
double  a_temperature 
)
protected
669 {
670  double snowtempthreshold = -1.0;
671  if (a_snowdepth > 0.0 && a_temperature < snowtempthreshold) {
672  a_snowdepth -= 0.1; // We decay the snow depth by 0.1 cm per day when temperatures are sub zero
673  }
674  else if (a_snowdepth > 0.0) // If temperatures are above 0.0, we decay snow 1 cm per degree C
675  {
676  a_snowdepth -= a_temperature;
677  }
678  if (a_temperature < snowtempthreshold && a_rainfall > 0.0) {
679  a_snowdepth += a_rainfall; // rain is in mm and snow in cm, so we get the conversion for free.
680  }
681  if (a_temperature > snowtempthreshold && a_rainfall > 0.0) {
682  a_snowdepth -= a_rainfall; // rain is in mm and snow in cm, so we get the conversion for free.
683  }
684  if (a_snowdepth < 0.0) a_snowdepth = 0.0;
685  return a_snowdepth;
686 }

Referenced by readWeatherFile().

◆ DeriveSoilTemp()

double Weather::DeriveSoilTemp ( double  a_temperature)
protected
664 {
665  return a_airtemp - 0; // ***ELA*** here we need to add the conversion equation using config variables
666 }

Referenced by readWeatherFile().

◆ Get_fminmaxtemp()

bool Weather::Get_fminmaxtemp ( void  )
inline
524 { return m_fminmaxtemp; } // if true exists, if false it does not

◆ Get_fradiation()

bool Weather::Get_fradiation ( void  )
inline
527 { return m_fradiation; } // if true exists, if false it does not

◆ Get_frelhumidity()

bool Weather::Get_frelhumidity ( void  )
inline
525 { return m_frelhumidity; } // if true exists, if false it does not

◆ Get_fsnow()

bool Weather::Get_fsnow ( void  )
inline
523 { return m_fsnow; } // if true read, if false calculated

◆ Get_fsoiltemp()

bool Weather::Get_fsoiltemp ( void  )
inline
522 { return m_fsoiltemp; } // if true read, if false calculated

◆ Get_fsoiltemptwilight()

bool Weather::Get_fsoiltemptwilight ( void  )
inline
526 { return m_fsoiltemptwilight; } // if true exists, if false it does not

◆ GetDDDegs()

double Weather::GetDDDegs ( long  a_date)
206 {
207  double temp = m_temp[ a_date%m_datemodulus ];
208  if ( temp < 0.0 ) {
209  temp = 0.0;
210  }
211 
212  return temp;
213 }

References m_datemodulus, and m_temp.

Referenced by VegElement::DoDevelopment(), and VegElement::SetGrowthPhase().

◆ GetFlyingHours()

double Weather::GetFlyingHours ( void  )
inline

Get the max temperature today.

500 { return m_flyinghourstoday; }

◆ GetGlobalRadiation() [1/2]

double Weather::GetGlobalRadiation ( long  a_date)
inline
473 { if(m_hourly_flag) return m_radiation.at(a_date % m_datemodulus); return (double)c_insolation[a_date % m_datemodulus]; }

References c_insolation.

Referenced by Landscape::SupplyGlobalRadiation().

◆ GetGlobalRadiation() [2/2]

double Weather::GetGlobalRadiation ( void  )
inline
474 { return m_insolation; }

◆ GetHumidity() [1/2]

double Weather::GetHumidity ( long  a_date)
inline

Get the humidity score today.

504 { return m_relhumidity[a_date % m_datemodulus]; }

◆ GetHumidity() [2/2]

double Weather::GetHumidity ( void  )
inline

Get the humidity score today.

502 { return m_humiditytoday; }

Referenced by GetRHPeriod(), and Landscape::SupplyHumidity().

◆ GetMaxTemp()

double Weather::GetMaxTemp ( void  )
inline

Get the max temperature today.

488 { return m_maxtemptoday; }

Referenced by Landscape::SupplyMaxTemp().

◆ GetMaxTempTomorrow()

double Weather::GetMaxTempTomorrow ( void  )
inline

Get the max temperature tomorrow.

496 { return m_maxtemptomorrow; }

Referenced by Landscape::SupplyMaxTempTomorrow().

◆ GetMaxTempYesterday()

double Weather::GetMaxTempYesterday ( void  )
inline

Get the max temperature yesterday.

492 { return m_maxtempyesterday; }

Referenced by Landscape::SupplyMaxTempYesterday().

◆ GetMeanTemp()

double Weather::GetMeanTemp ( long  a_date,
unsigned int  a_period 
)
171 {
172  double sum = 0.0;
173 
174  for ( unsigned int i=0; i<a_period; i++ )
175  sum += GetTemp( a_date - i );
176 
177  return sum/(double)a_period;
178 }

References GetTemp().

Referenced by Landscape::SupplyMeanTemp().

◆ GetMinTemp()

double Weather::GetMinTemp ( void  )
inline

Get the min temperature today.

486 { return m_mintemptoday; }

Referenced by Landscape::SupplyMinTemp().

◆ GetMinTempTomorrow()

double Weather::GetMinTempTomorrow ( void  )
inline

Get the min temperature tomorrow.

494 { return m_mintemptomorrow; }

Referenced by Landscape::SupplyMinTempTomorrow().

◆ GetMinTempYesterday()

double Weather::GetMinTempYesterday ( void  )
inline

Get the min temperature yesterday.

490 { return m_mintempyesterday; }

Referenced by Landscape::SupplyMinTempYesterday().

◆ GetNoDays()

int Weather::GetNoDays ( void  )
inline
528 { return m_NoDays; }

◆ GetRadiation()

double Weather::GetRadiation ( void  )
inline

Get the max temperature today.

498 { return m_radiationtoday; }

◆ GetRadiationHour()

double Weather::GetRadiationHour ( int  hour)
inline
471 {return m_radiation_h.at(m_hourly_today_index).at(hour);}

Referenced by Landscape::SupplyRadiationHour().

◆ GetRain() [1/2]

double Weather::GetRain ( long  a_date)
inline

◆ GetRain() [2/2]

double Weather::GetRain ( void  )
inline
507 { return m_raintoday; }

Referenced by GetRainPeriod(), and Tick().

◆ GetRainHour()

double Weather::GetRainHour ( int  hour)
inline

◆ GetRainPeriod()

double Weather::GetRainPeriod ( long  a_date,
unsigned int  a_period 
)

◆ GetRHPeriod()

double Weather::GetRHPeriod ( long  a_date,
unsigned int  a_period 
)

Sums the temperature for the period from a_date back a_period days.

Parameters
[in]a_datethe day to start summing degrees
[in]a_periodthe number of days períod to sum
Returns
The sum of day degrees
724 {
731  double sum = 0.0;
732 
733  for (unsigned int i = 0; i < a_period; i++)
734  sum += GetHumidity(a_date - i);
735  return sum;
736 }

References GetHumidity().

Referenced by Erigone_Population_Manager::DoFirst(), and Oedothorax_Population_Manager::DoFirst().

◆ GetSnow() [1/2]

bool Weather::GetSnow ( long  a_date)
183 {
184  if ( a_date == g_date->Date() ) {
185  return m_snowtoday;
186  }
187 
188  int m_weather_day = a_date % m_datemodulus;
189  bool snow = false;
190 
191  if ( m_temp[ m_weather_day ] < 0 &&
192  m_rain[ m_weather_day ] > 1 &&
193  g_random_fnc(100) < 50 ) {
194  snow = true;
195  }
196 
197  // if ( ((dayinyear<90) || (dayinyear>330)) && (random(4)==1) )
198  // snow = true;
199 
200  return snow;
201 }

References Calendar::Date(), g_date, g_random_fnc(), m_datemodulus, m_rain, m_snowtoday, m_temp, and m_weather_day.

Referenced by Landscape::SupplySnowcover().

◆ GetSnow() [2/2]

bool Weather::GetSnow ( void  )
inline
517 { return m_snowtoday; }

◆ GetSnowDepth()

double Weather::GetSnowDepth ( void  )
inline

Get the current snow depth.

519 { return m_snowdepth; }

Referenced by Landscape::SupplySnowDepth().

◆ GetSoilTemp() [1/2]

double Weather::GetSoilTemp ( long  a_date)
inline

Get the soil temperature on a particular date.

480 { return m_soiltemp[a_date % m_datemodulus]; }

◆ GetSoilTemp() [2/2]

double Weather::GetSoilTemp ( void  )
inline

Get the current soil temperature.

478 { return m_soiltemptoday; }

Referenced by Landscape::SupplySoilTemp().

◆ GetSoilTempHour()

double Weather::GetSoilTempHour ( int  hour)
inline
468 { return m_soiltemp_h.at(m_hourly_today_index).at(hour); }

Referenced by Landscape::SupplySoilTempHour().

◆ GetTemp() [1/2]

double Weather::GetTemp ( long  a_date)
inline

Get the temperature on a particular date.

476 { return m_temp[a_date % m_datemodulus]; }

Referenced by Farm::FP_Slurry(), Landscape::SupplyTemp(), and Pesticide::Tick().

◆ GetTemp() [2/2]

double Weather::GetTemp ( void  )
inline

Get the temperature today.

482 { return m_temptoday; }

Referenced by GetMeanTemp(), and GetTempPeriod().

◆ GetTempAfterDays()

double Weather::GetTempAfterDays ( int  days)
inline

Get the temperature at the given number of days which is the number of days after today.

484 { return m_temp[(m_weather_day + days) % m_datemodulus]; }

Referenced by LE::CalculateFlowerResourceForCrop(), and PollenNectarDevelopmentData::RecalculatePollenNectarCurvesForYear().

◆ GetTempHour()

double Weather::GetTempHour ( int  hour)
inline

Get today's weather data at the given hour.

467 {return m_temp_h.at(m_hourly_today_index).at(hour);}

Referenced by Osmia_Population_Manager::CalForageHours(), Erigone_Population_Manager::DoFirst(), and Landscape::SupplyTempHour().

◆ GetTempPeriod()

double Weather::GetTempPeriod ( long  a_date,
unsigned int  a_period 
)

Sums the temperature for the period from a_date back a_period days.

Parameters
[in]a_datethe day to start summing degrees
[in]a_periodthe number of days períod to sum
Returns
The sum of day degrees
708 {
715  double sum = 0.0;
716 
717  for (unsigned int i = 0; i < a_period; i++)
718  sum += GetTemp(a_date - i);
719 
720  return sum;
721 }

References GetTemp().

Referenced by Erigone_Population_Manager::DoFirst(), Oedothorax_Population_Manager::DoFirst(), Skylark_Population_Manager::DoFirst(), Landscape::SupplyTempPeriod(), and Tick().

◆ GetWind() [1/2]

◆ GetWind() [2/2]

double Weather::GetWind ( void  )
inline
509 { return m_windtoday; }

Referenced by GetWindPeriod().

◆ GetWindDirection()

int Weather::GetWindDirection ( void  )
inline

Four wind directions N = 0, clockwise.

511 { return m_winddirtoday; }

Referenced by Landscape::SupplyWindDirection().

◆ GetWindDirection8()

int Weather::GetWindDirection8 ( void  )
inline

Eight wind directions N = 0, NE = 1, ..., clockwise.

513 { return m_winddir8today; }

Referenced by Landscape::SupplyWindDirection8().

◆ GetWindDirectionRadians()

double Weather::GetWindDirectionRadians ( void  )
inline

East is 0, anticlockwise.

515 {return m_WindDirTodayRadians;}

Referenced by Landscape::SupplyWindDirectionRadians().

◆ GetWindHour()

double Weather::GetWindHour ( int  hour)
inline

◆ GetWindPeriod()

double Weather::GetWindPeriod ( long  a_date,
unsigned int  a_period 
)
698 {
699  double sum = 0.0;
700 
701  for ( unsigned int i=0; i<a_period; i++ )
702  sum += GetWind( a_date - i );
703 
704  return sum;
705 }

References GetWind().

Referenced by Skylark_Population_Manager::DoFirst(), and Landscape::SupplyWindPeriod().

◆ Raining()

bool Weather::Raining ( void  )
inline
520 { return m_rainingtoday; }

Referenced by Farm::AutumnHarrow(), Farm::AutumnPlough(), Farm::AutumnRoll(), Farm::AutumnSow(), Farm::AutumnSowWithFerti(), Farm::BedForming(), Farm::BiocideTreat(), Farm::CutOrch(), Farm::CutToSilage(), Farm::CutWeeds(), Farm::DeepPlough(), Farm::FA_AmmoniumSulphate(), Farm::FA_Boron(), Farm::FA_Calcium(), Farm::FA_Cu(), Farm::FA_GreenManure(), Farm::FA_K(), Farm::FA_ManganeseSulphate(), Farm::FA_Manure(), Farm::FA_N(), Farm::FA_NK(), Farm::FA_NPK(), Farm::FA_NPKS(), Farm::FA_P(), Farm::FA_PK(), Farm::FA_PKS(), Farm::FA_RSM(), Farm::FA_SK(), Farm::FA_Sludge(), Farm::FA_Slurry(), Farm::FiberCovering(), Farm::FiberRemoval(), Farm::FlowerCutting(), Farm::FP_AmmoniumSulphate(), Farm::FP_Boron(), Farm::FP_Calcium(), Farm::FP_Cu(), Farm::FP_GreenManure(), Farm::FP_K(), Farm::FP_LiquidNH3(), Farm::FP_ManganeseSulphate(), Farm::FP_Manure(), Farm::FP_N(), Farm::FP_NC(), Farm::FP_NK(), Farm::FP_NPK(), Farm::FP_NPKS(), Farm::FP_NS(), Farm::FP_P(), Farm::FP_PK(), Farm::FP_PKS(), Farm::FP_RSM(), Farm::FP_SK(), Farm::FP_Sludge(), Farm::FP_Slurry(), Farm::FruitHarvest(), Farm::FungicideTreat(), Farm::GreenHarvest(), Farm::GrowthRegulator(), Farm::HarvestShoots(), Farm::HeavyCultivatorAggregate(), Farm::HerbicideTreat(), Farm::HillingUp(), Farm::InsecticideTreat(), Farm::Irrigation(), Farm::LeafThinning(), Farm::Molluscicide(), Farm::Mowing(), Farm::OrganicFungicide(), Farm::OrganicHerbicide(), Farm::OrganicInsecticide(), Farm::Pheromone(), Farm::PreseedingCultivator(), Farm::PreseedingCultivatorSow(), Farm::ProductApplication(), Farm::Pruning(), Farm::ShallowHarrow(), Farm::Shredding(), Farm::SpringHarrow(), Farm::SpringPlough(), Farm::SpringRoll(), Farm::SpringSow(), Farm::SpringSowWithFerti(), Farm::StrawCovering(), Farm::StrawRemoval(), Farm::StriglingHill(), Farm::StubbleCultivatorHeavy(), Farm::StubblePlough(), Farm::Suckering(), Farm::Swathing(), Farm::Water(), Farm::WinterHarrow(), and Farm::WinterPlough().

◆ readWeatherFile()

void Weather::readWeatherFile ( int  NoDays,
ifstream &  inFile 
)
487  {
488  m_hourly_flag = false;
489  int Day, Month, Year, FirstYear=0, LastYear=0;
490  double Temp, Rain, Wind, SoilTemp, SnowCover, minTemp, maxTemp, soilTempTwilight, relHumidity, Radiation, FlyingHours;
491  m_rain.resize(NoDays);
492  m_wind.resize(NoDays);
493  m_temp.resize(NoDays);
494  m_soiltemp.resize(NoDays); // when absent, this is calculated
495  m_snow.resize(NoDays); // when absent, this is calculated
496  if (l_weather_soiltemp.value() == true)
497  {
498  m_fsoiltemp = true;
499  }
500  if (l_weather_snowcover.value() == true)
501  {
502  m_fsnow = true;
503  }
504  if (l_weather_relhumidity.value() == true)
505  {
506  m_relhumidity.resize(NoDays);
507  m_frelhumidity = true;
508  }
509  if (l_weather_soiltemptwilight.value() == true)
510  {
511  m_soiltemptwilight.resize(NoDays);
512  m_fsoiltemptwilight = true;
513  }
514  if (l_weather_minmaxtemp.value() == true)
515  {
516  m_mintemp.resize(NoDays);
517  m_maxtemp.resize(NoDays);
518  m_fminmaxtemp = true;
519  }
520  if (l_weather_radiation.value() == true)
521  {
522  m_radiation.resize(NoDays);
523  m_fradiation = true;
524  }
525  if (l_weather_flyinghours.value() == true)
526  {
527  m_flyinghours.resize(NoDays);
528  m_fflyinghours = true;
529  }
530 
531 
532  bool storing = false; // Whether we are storing weather data.
533  unsigned int index = 0;
534 
535  g_date->SetLastYear( 0 );
536 
537 
538  for ( int i=0; i<NoDays; i++) {
539 
540  // Year Month Day AirTemp Wind Rain [MinAirTemp MaxAirTemp] [SoilTemp] [SnowCover] [RelHumidity] [SoilTempTwilight] [Radiation]
541 
542  inFile >> Year >> Month >> Day >> Temp >> Wind >> Rain;
543  if ( m_fminmaxtemp == true )
544  inFile >> minTemp >> maxTemp;
545  if ( m_fsoiltemp == true )
546  inFile >> SoilTemp;
547  if ( m_fsnow == true )
548  inFile >> SnowCover;
549  if ( m_frelhumidity == true )
550  inFile >> relHumidity;
551  if ( m_fsoiltemptwilight == true )
552  inFile >> soilTempTwilight;
553  if (m_fradiation == true)
554  inFile >> Radiation;
555  if (m_fflyinghours == true)
556  inFile >> FlyingHours;
557 
558  if ( Month == 2 && Day == 29 ) {
559  // Skip leap days.
560  continue;
561  }
562 
563  if ( Month == 1 && Day == 1 && !storing &&
564  (
567  )
568  ) {
569  // Commence storing of data from Jan. 1st of the first
570  // year requested.
571  storing = true;
572  g_date->SetFirstYear( Year );
573  FirstYear = Year;
574  g_date->Reset();
575  }
576 
577 
578  if ( storing )
579  {
580 
581  m_rain[ index ] = Rain;
582 
583  m_wind[ index ] = Wind;
584 
585  m_temp[ index ] = Temp;
586 
587  if (m_fsoiltemp == true)
588  {
589  m_soiltemp[index] = SoilTemp;
590  }
591  else
592  {
593  m_soiltemp[index] = DeriveSoilTemp(Temp);
594  }
595 
596  double snowdepth = 0;
597  if (index > 0)
598  {
599  snowdepth = m_snow[index - 1];
600  }
601  if (m_fsnow == true)
602  {
603  m_snow[index] = SnowCover;
604  }
605  else
606  {
607  m_snow[index] = DeriveSnowCover(snowdepth, Rain, Temp);
608  }
609 
610  if (m_fminmaxtemp == true)
611  {
612  m_mintemp[index] = minTemp;
613  m_maxtemp[index] = maxTemp;
614  }
615 
616  if (m_frelhumidity == true)
617  {
618  m_relhumidity[index] = relHumidity;
619  }
620 
621  if (m_fsoiltemptwilight == true)
622  {
623  m_soiltemptwilight[index] = soilTempTwilight;
624  }
625  if (m_fradiation == true)
626  {
627  m_radiation[index] = Radiation;
628  }
629  if (m_fflyinghours == true)
630  {
631  m_flyinghours[index] = FlyingHours;
632  }
633  index++;
634  }
635 
636  //cout << "i: " << i << " index: " << index << " Month: " << Month << " Year: " << Year <<"\n";
637  //cout << "i: " << i << " index: " << index << " Month: " << Month << " Year: " << Year << " Temp: " << Temp << " Wind: " << Wind << " Rain: " << Rain << " RelHumidity: " << relHumidity << " minTemp: " << minTemp << " maxTemp: " << maxTemp << "\n";
638 
639  if ( (Month == 12) && (Day == 31) && (storing) ) {
640  cout << "LastYear: " << Year << "\n";
641  // Found yet another full year worth of weather data.
642  g_date->SetLastYear( Year );
643  LastYear = Year;
644  }
645  }
646 
647  // Did we find at least one full year worth of data?
648  if ( g_date->GetLastYear() == 0 ) {
649  // Nope...
650  g_msg->Warn(WARN_FILE, "Weather::Weather(): Weather data file did",
651  "not contain at least one year of data!" );
652  exit(1);
653  }
654  //fclose( ifile );
655  m_datemodulus = (LastYear - FirstYear + 1)*365;
656  m_snowdepth = 0;
657 }

References DeriveSnowCover(), DeriveSoilTemp(), g_date, g_msg, Calendar::GetLastYear(), l_weather_flyinghours, l_weather_minmaxtemp, l_weather_radiation, l_weather_relhumidity, l_weather_snowcover, l_weather_soiltemp, l_weather_soiltemptwilight, l_weather_starting_year, m_datemodulus, m_fflyinghours, m_flyinghours, m_fminmaxtemp, m_fradiation, m_frelhumidity, m_fsnow, m_fsoiltemp, m_fsoiltemptwilight, m_hourly_flag, m_maxtemp, m_mintemp, m_radiation, m_rain, m_relhumidity, m_snow, m_snowdepth, m_soiltemp, m_soiltemptwilight, m_temp, m_wind, Calendar::Reset(), Calendar::SetFirstYear(), Calendar::SetLastYear(), CfgInt::value(), CfgBool::value(), MapErrorMsg::Warn(), and WARN_FILE.

Referenced by Weather().

◆ readWeatherFileHourly()

void Weather::readWeatherFileHourly ( int  NoHours,
int  NoDays,
ifstream &  inFile 
)
Note
cover it to J for daily
282  {
283  m_hourly_flag = true;
284  int Hour, Day, Month, Year, FirstYear=0, LastYear=0;
285  double Temp, Rain, Wind, Winddir, Radiation, SoilTemp, SnowCover, minTemp, maxTemp, soilTempTwilight, relHumidity;
286 
287  // these are used to calculate the average value (except the rain) for a day
288  double sum_temp = 0.0, sum_rain = 0.0, sum_wind = 0.0, sum_winddir = 0.0, sum_winddir8 = 0.0, sum_soiltemp = 0.0, sum_snow = 0.0, sum_humidity = 0.0, sum_radiation = 0.0;
289  m_rain.resize(NoDays);
290  m_wind.resize(NoDays);
291  m_winddir.resize(NoDays);
292  m_winddir8.resize(NoDays);
293  m_WindDirRadians.resize(NoDays);
294  m_temp.resize(NoDays);
295  m_soiltemp.resize(NoDays);
296  m_snow.resize(NoDays);
297  m_mintemp.resize(NoDays);
298  m_maxtemp.resize(NoDays);
299  m_relhumidity.resize(NoDays);
300  m_soiltemptwilight.resize(NoDays);
301  m_radiation.resize(NoDays);
302 
303 
304  //initialise the vectors for storing the hourly weather data
305  m_temp_h.resize(NoDays);
306  m_rain_h.resize(NoDays);
307  m_wind_h.resize(NoDays);
308  m_winddir_h.resize(NoDays);
309  m_winddir8_h.resize(NoDays);
310  m_radiation_h.resize(NoDays);
311  m_soiltemp_h.resize(NoDays);
312  m_snow_h.resize(NoDays);
313  m_humidity_h.resize(NoDays);
314 
315  for(int i = 0; i < NoDays; i++){
316  m_temp_h.at(i).resize(24);
317  m_rain_h.at(i).resize(24);
318  m_wind_h.at(i).resize(24);
319  m_winddir_h.at(i).resize(24);
320  m_winddir8_h.at(i).resize(24);
321  m_radiation_h.at(i).resize(24);
322  m_soiltemp_h.at(i).resize(24);
323  m_snow_h.at(i).resize(24);
324  m_humidity_h.at(i).resize(24);
325  }
326 
327  m_fsoiltemp = true;
328  m_fsnow = true;
329  m_frelhumidity = true;
330  m_fsoiltemptwilight = true;
331  m_fminmaxtemp = true;
332 
333 
334  bool storing = false; // Whether we are storing weather data.
335  unsigned int index = 0;
336 
337  g_date->SetLastYear( 0 );
338 
339  int hour_counter = -1;
340 
341 
342 
343  for ( int i=0; i<NoHours; i++) {
344  inFile >> Year >> Month >> Day >> Hour >> Temp >> Wind >> Winddir >> Rain >> SoilTemp >> SnowCover >> relHumidity >> Radiation;
345 
346 
347  if ( Month == 2 && Day == 29 ) {
348  // Skip leap days.
349  continue;
350  }
351 
352  if ( Month == 1 && Day == 1 && Hour == 0 && !storing &&
353  (
356  )
357  ) {
358  // Commence storing of data from Jan. 1st of the first
359  // year requested.
360  storing = true;
361  g_date->SetFirstYear( Year );
362  FirstYear = Year;
363  g_date->Reset();
364  }
365 
366 
367  if ( storing )
368  {
369  hour_counter += 1;
370  if (hour_counter == 24)
371  {
372  hour_counter = 0;
373  }
374 
375  if (hour_counter == 0){
376  sum_rain = 0.0;
377  sum_temp = 0.0;
378  sum_radiation = 0.0;
379  sum_wind = 0.0;
380  sum_winddir = 0.0;
381 
382  sum_soiltemp = 0.0;
383  sum_snow = 0.0;
384  sum_humidity = 0.0;
385  maxTemp = -9999;
386  minTemp = 9999;
387  }
388 
389 
390  m_rain_h.at(index).at(hour_counter) = Rain;
391  sum_rain += Rain;
392  m_wind_h.at(index).at(hour_counter) = Wind;
393  sum_wind += Wind;
394  m_winddir_h.at(index).at(hour_counter) = Winddir;
395  sum_winddir += Winddir;
396 
397  m_temp_h.at(index).at(hour_counter) = Temp;
398  sum_temp += Temp;
399  if(Temp > maxTemp) maxTemp = Temp;
400  if(Temp < minTemp) minTemp = Temp;
401  m_radiation_h.at(index).at(hour_counter) = Radiation;
402  sum_radiation += Radiation*3600;
403  m_soiltemp_h.at(index).at(hour_counter) = SoilTemp;
404  sum_soiltemp += SoilTemp;
409  if(hour_counter == 5){
410  m_soiltemptwilight[index] = SoilTemp;
411  }
412 
413  m_snow_h.at(index).at(hour_counter) = SnowCover;
414  sum_snow += SnowCover;
415  m_humidity_h.at(index).at(hour_counter) = relHumidity;
416  sum_humidity += relHumidity;
417 
418 
419  //process the daily data
420  if(hour_counter == 23)
421  {
422  m_rain[ index ] = sum_rain;
423 
424  m_wind[ index ] = sum_wind/24.0;
429  m_WindDirRadians[index] = sum_winddir/24.0;
430  if (m_WindDirRadians[index]>=M_PI*5/4 && m_WindDirRadians[index]<M_PI*7/4) m_winddir[index] = 2; // South
431  else if (m_WindDirRadians[index]>=M_PI*3/4 && m_WindDirRadians[index]<M_PI*5/4) m_winddir[index] = 3; // West
432  else if (m_WindDirRadians[index]>=M_PI/4 && m_WindDirRadians[index]<M_PI*3/4) m_winddir[index] = 0; // North
433  else m_winddir[index] = 1; // east
434 
435  if (m_WindDirRadians[index]>=M_PI*13/8 && m_WindDirRadians[index]<M_PI*15/8) m_winddir8[index] = 3; // South East
436  else if (m_WindDirRadians[index]>=M_PI*11/8 && m_WindDirRadians[index]<M_PI*13/8) m_winddir8[index] = 4; // South
437  else if (m_WindDirRadians[index]>=M_PI*9/8 && m_WindDirRadians[index]<M_PI*11/8) m_winddir8[index] = 5; // South west
438  else if (m_WindDirRadians[index]>=M_PI*7/8 && m_WindDirRadians[index]<M_PI*9/8) m_winddir8[index] = 6; // West
439  else if (m_WindDirRadians[index]>=M_PI*5/8 && m_WindDirRadians[index]<M_PI*7/8) m_winddir8[index] = 7; // North west
440  else if (m_WindDirRadians[index]>=M_PI*3/8 && m_WindDirRadians[index]<M_PI*5/8) m_winddir8[index] = 0; // North
441  else if (m_WindDirRadians[index]>=M_PI*1/8 && m_WindDirRadians[index]<M_PI*3/8) m_winddir8[index] = 1; // North east
442  else m_winddir8[index] = 2; // east
443 
444 
445 
446 
447 
448  m_temp[ index ] = sum_temp/24.0;
449  m_soiltemp[index] = sum_soiltemp/24.0;
450  m_radiation[index] = sum_radiation/1000000;
455  m_snow[index] = sum_snow/24.0;
456  m_mintemp[index] = minTemp;
457  m_maxtemp[index] = maxTemp;
458  m_relhumidity[index] = sum_humidity/24.0;
459 
460 
461  index++;
462  if ( (Month == 12) && (Day == 31) && (storing) ) {
463  cout << "LastYear: " << Year << "\n";
464  // Found yet another full year worth of weather data.
465  g_date->SetLastYear( Year );
466  LastYear = Year;
467  }
468  }
469  }
470 
471  //cout << "i: " << i << " index: " << index << " Month: " << Month << " Year: " << Year <<"\n";
472 
473  }
474 
475  // Did we find at least one full year worth of data?
476  if ( g_date->GetLastYear() == 0 ) {
477  // Nope...
478  g_msg->Warn(WARN_FILE, "Weather::Weather(): Weather data file did",
479  "not contain at least one year of data!" );
480  exit(1);
481  }
482  //fclose( ifile );
483  m_datemodulus = (LastYear - FirstYear + 1)*365;
484  m_snowdepth = 0;
485 }

References g_date, g_msg, Calendar::GetLastYear(), l_weather_starting_year, m_datemodulus, m_fminmaxtemp, m_frelhumidity, m_fsnow, m_fsoiltemp, m_fsoiltemptwilight, m_hourly_flag, m_humidity_h, m_maxtemp, m_mintemp, M_PI, m_radiation, m_radiation_h, m_rain, m_rain_h, m_relhumidity, m_snow, m_snow_h, m_snowdepth, m_soiltemp, m_soiltemp_h, m_soiltemptwilight, m_temp, m_temp_h, m_wind, m_wind_h, m_winddir, m_winddir8, m_winddir8_h, m_winddir_h, m_WindDirRadians, Calendar::Reset(), Calendar::SetFirstYear(), Calendar::SetLastYear(), CfgInt::value(), MapErrorMsg::Warn(), and WARN_FILE.

Referenced by Weather().

◆ Tick()

void Weather::Tick ( void  )

The complicated calculation of m_weather_day is due to the potential to run off either end of the rain data, especially since this is called on Day0

Humidity calculation. This is based on an assumption that humidity is relative to rainfall in the days before. The humidity score is the mean of rainfall over the last 5 days assuming 50% loss each day. Therefore rainfall of 10,0,0,2,0 mm in the previous 5 days would give a humidity of 0.625+0+0+1+0 = 1.625/5 = 0.325 But we also need to calculate temperature into this. Lets assume <10 degrees has no effect, 10-20 and this figure is halved, 20-40 and it is half again.

datemodulus is added to prevent negative overun on the rain or temperature data array, important since this is called on Day0

Wind directions is based on probabilities. Can also use the WindDirections array which allows monthly probabilities

66  {
69 
70  //update index for today's index
72 
73  if (m_snow[m_weather_day] > 0.0) {
74  m_snowtoday = true; // Means snow cover not new snow
75  }
76  else {
77  m_snowtoday = false;
78  }
79 
80 
85  if(m_fminmaxtemp && m_weather_day - 1 < 0){
88  }else{
91  }
92 
93  if (m_fminmaxtemp){
96  }else{
99  }
100 
101  if (m_fminmaxtemp){
104  }
105  else{
108  }
109  if (m_fradiation) {
111  }
112  if (m_fflyinghours) {
114  }
115  if (m_raintoday > 0.1)
116  m_rainingtoday = true;
117  else
118  m_rainingtoday = false;
119 
120  if (m_hourly_flag){ //new hourly weather, no need to calculate humidity and wind direction
126  }
127 
128  else //old daily weather
129  {
136  double rainscale = 0;
137  for (int i = 0; i < 5; i++) {
139  rainscale += GetRain( (m_weather_day + m_datemodulus) - (i + 1) ) * pow( 0.5, i );
140  }
141  double temp = GetTempPeriod( m_weather_day + m_datemodulus - 1, 5 ) / 5.0;
142  if (temp > 10.0) rainscale *= 0.5;
143  if (temp > 20.0) rainscale *= 0.5;
144  if (temp > 30.0) rainscale *= 0.5;
145  m_humiditytoday = rainscale;
147  double chance = g_rand_uni_fnc();
148  if (chance < 0.1) m_winddirtoday = 2; // South
149  else if (chance < 0.3) m_winddirtoday = 1; // East
150  else if (chance < 0.5) m_winddirtoday = 0; // North
151  else m_winddirtoday = 3; // West
152 
153 
154  if (chance < 0.12) m_winddir8today = 0; // North
155  else if (chance < 0.24) m_winddir8today = 1; // NE
156  else if (chance < 0.35) m_winddir8today = 2; // E
157  else if (chance < 0.42) m_winddir8today = 3; // SE
158  else if (chance < 0.48) m_winddir8today = 4; // S
159  else if (chance < 0.57) m_winddir8today = 5; // SW
160  else if (chance < 0.86) m_winddir8today = 6; // W
161  else m_winddir8today = 7; // NW
162  }
163 
164 
165 
166 }

References c_insolation, Calendar::Date(), Calendar::DayInYear(), g_date, g_rand_uni_fnc(), GetRain(), GetTempPeriod(), m_datemodulus, m_fflyinghours, m_flyinghours, m_flyinghourstoday, m_fminmaxtemp, m_fradiation, m_hourly_flag, m_hourly_today_index, m_humiditytoday, m_insolation, m_maxtemp, m_maxtemptoday, m_maxtemptomorrow, m_maxtempyesterday, m_mintemp, m_mintemptoday, m_mintemptomorrow, m_mintempyesterday, m_radiation, m_radiationtoday, m_rain, m_rainingtoday, m_raintoday, m_relhumidity, m_snow, m_snowtoday, m_soiltemp, m_soiltemptoday, m_temp, m_temp_variation, m_temptoday, m_weather_day, m_wind, m_winddir, m_winddir8, m_winddir8today, m_WindDirRadians, m_winddirtoday, m_WindDirTodayRadians, and m_windtoday.

Referenced by Landscape::Tick(), and Weather().

Member Data Documentation

◆ m_datemodulus

long Weather::m_datemodulus
private

◆ m_fflyinghours

bool Weather::m_fflyinghours = false
private

Referenced by readWeatherFile(), and Tick().

◆ m_flyinghours

vector<double> Weather::m_flyinghours
private

Referenced by readWeatherFile(), and Tick().

◆ m_flyinghourstoday

double Weather::m_flyinghourstoday
private

Referenced by Tick().

◆ m_fminmaxtemp

bool Weather::m_fminmaxtemp = false
private

◆ m_fradiation

bool Weather::m_fradiation = false
private

Referenced by readWeatherFile(), and Tick().

◆ m_frelhumidity

bool Weather::m_frelhumidity = false
private

◆ m_fsnow

bool Weather::m_fsnow = false
private

◆ m_fsoiltemp

bool Weather::m_fsoiltemp = false
private

◆ m_fsoiltemptwilight

bool Weather::m_fsoiltemptwilight = false
private

◆ m_hourly_flag

bool Weather::m_hourly_flag
private

Flag for hourly data.

Referenced by readWeatherFile(), readWeatherFileHourly(), and Tick().

◆ m_hourly_today_index

int Weather::m_hourly_today_index
private

Referenced by Tick().

◆ m_humidity_h

vector<vector<double> > Weather::m_humidity_h
private

Referenced by readWeatherFileHourly().

◆ m_humiditytoday

double Weather::m_humiditytoday
private

Referenced by Tick().

◆ m_insolation

double Weather::m_insolation
private

Referenced by Tick().

◆ m_maxtemp

vector<double> Weather::m_maxtemp
private

◆ m_maxtemptoday

double Weather::m_maxtemptoday
private

Referenced by Tick().

◆ m_maxtemptomorrow

double Weather::m_maxtemptomorrow
private

Referenced by Tick().

◆ m_maxtempyesterday

double Weather::m_maxtempyesterday
private

Referenced by Tick().

◆ m_mintemp

vector<double> Weather::m_mintemp
private

◆ m_mintemptoday

double Weather::m_mintemptoday
private

Referenced by Tick().

◆ m_mintemptomorrow

double Weather::m_mintemptomorrow
private

Referenced by Tick().

◆ m_mintempyesterday

double Weather::m_mintempyesterday
private

Referenced by Tick().

◆ m_NoDays

int Weather::m_NoDays
private

Holds the number of days we have weather data for.

Referenced by Weather().

◆ m_radiation

vector<double> Weather::m_radiation
private

◆ m_radiation_h

vector<vector<double> > Weather::m_radiation_h
private

Referenced by readWeatherFileHourly().

◆ m_radiationtoday

double Weather::m_radiationtoday
private

Referenced by Tick().

◆ m_rain

vector<double> Weather::m_rain
private

◆ m_rain_h

vector<vector<double> > Weather::m_rain_h
private

Referenced by readWeatherFileHourly().

◆ m_rainingtoday

bool Weather::m_rainingtoday
private

Referenced by Tick().

◆ m_raintoday

double Weather::m_raintoday
private

Referenced by Tick().

◆ m_relhumidity

vector<double> Weather::m_relhumidity
private

◆ m_snow

vector<double> Weather::m_snow
private

◆ m_snow_h

vector<vector<double> > Weather::m_snow_h
private

Referenced by readWeatherFileHourly().

◆ m_snowdepth

double Weather::m_snowdepth
private

The snow depth in cm.

Referenced by readWeatherFile(), and readWeatherFileHourly().

◆ m_snowtoday

bool Weather::m_snowtoday
private

Referenced by GetSnow(), and Tick().

◆ m_soiltemp

vector<double> Weather::m_soiltemp
private

◆ m_soiltemp_h

vector<vector<double> > Weather::m_soiltemp_h
private

Referenced by readWeatherFileHourly().

◆ m_soiltemptoday

double Weather::m_soiltemptoday
private

Referenced by Tick().

◆ m_soiltemptwilight

vector<double> Weather::m_soiltemptwilight
private

◆ m_temp

vector<double> Weather::m_temp
private

◆ m_temp_h

vector<vector<double> > Weather::m_temp_h
private

Referenced by readWeatherFileHourly().

◆ m_temp_variation

double Weather::m_temp_variation {0}
private

Referenced by Tick(), and Weather().

◆ m_temptoday

double Weather::m_temptoday
private

Referenced by Tick().

◆ m_weather_day

int Weather::m_weather_day
private

Referenced by GetSnow(), and Tick().

◆ m_wind

vector<double> Weather::m_wind
private

◆ m_wind_h

vector<vector<double> > Weather::m_wind_h
private

Referenced by readWeatherFileHourly().

◆ m_wind_valid

bool Weather::m_wind_valid
private

◆ m_winddir

vector<double> Weather::m_winddir
private

Referenced by readWeatherFileHourly(), and Tick().

◆ m_winddir8

vector<double> Weather::m_winddir8
private

Referenced by readWeatherFileHourly(), and Tick().

◆ m_winddir8_h

vector<vector<double> > Weather::m_winddir8_h
private

Referenced by readWeatherFileHourly().

◆ m_winddir8_valid

bool Weather::m_winddir8_valid
private

◆ m_winddir8today

int Weather::m_winddir8today
private

Referenced by Tick().

◆ m_winddir_h

vector<vector<double> > Weather::m_winddir_h
private

Referenced by readWeatherFileHourly().

◆ m_winddir_valid

bool Weather::m_winddir_valid
private

◆ m_WindDirRadians

vector<double> Weather::m_WindDirRadians
private

Referenced by readWeatherFileHourly(), and Tick().

◆ m_winddirtoday

int Weather::m_winddirtoday
private

Referenced by Tick().

◆ m_WindDirTodayRadians

double Weather::m_WindDirTodayRadians
private

Referenced by Tick().

◆ m_windtoday

double Weather::m_windtoday
private

Referenced by Tick().


The documentation for this class was generated from the following files:
Weather::m_winddir8today
int m_winddir8today
Definition: Weather.h:430
M_PI
#define M_PI
Definition: sunset.h:33
Weather::m_hourly_flag
bool m_hourly_flag
Flag for hourly data.
Definition: Weather.h:458
WARN_FILE
Definition: MapErrorMsg.h:37
g_rand_uni_fnc
double g_rand_uni_fnc()
Definition: ALMaSS_Random.cpp:56
Weather::m_snowdepth
double m_snowdepth
The snow depth in cm.
Definition: Weather.h:455
l_weather_relhumidity
static CfgBool l_weather_relhumidity("WEATHER_RELHUMIDITY", CFG_CUSTOM, false)
Weather::m_radiation
vector< double > m_radiation
Definition: Weather.h:399
Weather::m_soiltemp
vector< double > m_soiltemp
Definition: Weather.h:393
Weather::GetWind
double GetWind(void)
Definition: Weather.h:509
Weather::m_temp
vector< double > m_temp
Definition: Weather.h:392
Weather::m_radiationtoday
double m_radiationtoday
Definition: Weather.h:443
Weather::m_temptoday
double m_temptoday
Definition: Weather.h:426
Calendar::SetFirstYear
void SetFirstYear(int a_year)
Definition: Calendar.h:81
Weather::m_fradiation
bool m_fradiation
Definition: Weather.h:421
Weather::m_winddir8_h
vector< vector< double > > m_winddir8_h
Definition: Weather.h:406
CfgStr::value
char * value() const
Definition: Configurator.h:182
Weather::m_relhumidity
vector< double > m_relhumidity
Definition: Weather.h:397
l_weather_radiation
static CfgBool l_weather_radiation("WEATHER_RADIATION", CFG_CUSTOM, false)
g_date
class Calendar * g_date
Definition: Calendar.cpp:37
Weather::m_humiditytoday
double m_humiditytoday
Definition: Weather.h:435
l_weather_soiltemp
static CfgBool l_weather_soiltemp("WEATHER_SOILTEMP", CFG_CUSTOM, false)
Weather::GetRain
double GetRain(void)
Definition: Weather.h:507
l_weather_minmaxtemp
static CfgBool l_weather_minmaxtemp("WEATHER_MINMAXTEMP", CFG_CUSTOM, false)
Weather::m_fminmaxtemp
bool m_fminmaxtemp
Definition: Weather.h:418
l_weather_flyinghours
static CfgBool l_weather_flyinghours("WEATHER_FLYINGHOURS", CFG_CUSTOM, false)
l_map_weather_file
static CfgStr l_map_weather_file("MAP_WEATHER_FILE", CFG_CUSTOM, "weather.pre")
Weather::m_fsoiltemptwilight
bool m_fsoiltemptwilight
Definition: Weather.h:420
Weather::m_datemodulus
long m_datemodulus
Definition: Weather.h:452
Calendar::SetLastYear
void SetLastYear(int a_year)
Definition: Calendar.h:82
Weather::m_snow
vector< double > m_snow
Definition: Weather.h:394
Weather::Tick
void Tick(void)
Definition: Weather.cpp:66
Weather::m_mintemptomorrow
double m_mintemptomorrow
Definition: Weather.h:441
Weather::m_rain
vector< double > m_rain
Definition: Weather.h:387
CfgBool::value
bool value() const
Definition: Configurator.h:164
Weather::m_soiltemptoday
double m_soiltemptoday
Definition: Weather.h:436
Weather::m_fflyinghours
bool m_fflyinghours
Definition: Weather.h:422
Weather::m_temp_h
vector< vector< double > > m_temp_h
Definition: Weather.h:407
Weather::m_frelhumidity
bool m_frelhumidity
Definition: Weather.h:419
Weather::m_snowtoday
bool m_snowtoday
Definition: Weather.h:432
Weather::GetTemp
double GetTemp(void)
Get the temperature today.
Definition: Weather.h:482
Weather::readWeatherFileHourly
void readWeatherFileHourly(int NoHours, int NoDays, ifstream &inFile)
Definition: Weather.cpp:282
Weather::m_WindDirRadians
vector< double > m_WindDirRadians
Definition: Weather.h:391
Weather::m_snow_h
vector< vector< double > > m_snow_h
Definition: Weather.h:410
Calendar::Date
long Date(void)
Definition: Calendar.h:57
Calendar::Reset
void Reset(void)
Definition: Calendar.cpp:39
Weather::GetHumidity
double GetHumidity(void)
Get the humidity score today.
Definition: Weather.h:502
Weather::m_radiation_h
vector< vector< double > > m_radiation_h
Definition: Weather.h:408
Weather::m_mintemptoday
double m_mintemptoday
Definition: Weather.h:439
Weather::m_maxtemptomorrow
double m_maxtemptomorrow
Definition: Weather.h:442
Weather::DeriveSoilTemp
double DeriveSoilTemp(double a_temperature)
Definition: Weather.cpp:663
Calendar::GetLastYear
int GetLastYear(void)
Definition: Calendar.h:70
MapErrorMsg::Warn
void Warn(MapErrorState a_level, std::string a_msg1, std::string a_msg2)
Definition: MapErrorMsg.cpp:69
Weather::m_maxtempyesterday
double m_maxtempyesterday
Definition: Weather.h:438
Weather::m_wind_h
vector< vector< double > > m_wind_h
Definition: Weather.h:404
Weather::m_rainingtoday
bool m_rainingtoday
Definition: Weather.h:433
Weather::m_soiltemptwilight
vector< double > m_soiltemptwilight
Definition: Weather.h:398
Weather::m_WindDirTodayRadians
double m_WindDirTodayRadians
Definition: Weather.h:431
Weather::m_windtoday
double m_windtoday
Definition: Weather.h:428
Weather::m_winddir
vector< double > m_winddir
Definition: Weather.h:389
l_weather_soiltemptwilight
static CfgBool l_weather_soiltemptwilight("WEATHER_SOILTEMPTWILIGHT", CFG_CUSTOM, false)
Weather::m_temp_variation
double m_temp_variation
Definition: Weather.h:445
CfgInt::value
int value() const
Definition: Configurator.h:116
c_insolation
const double c_insolation[365]
Definition: Weather.h:16
Weather::m_rain_h
vector< vector< double > > m_rain_h
Definition: Weather.h:403
Weather::m_fsnow
bool m_fsnow
Definition: Weather.h:417
Weather::m_humidity_h
vector< vector< double > > m_humidity_h
Definition: Weather.h:411
Weather::m_weather_day
int m_weather_day
Definition: Weather.h:461
Weather::m_fsoiltemp
bool m_fsoiltemp
Definition: Weather.h:416
Weather::DeriveSnowCover
double DeriveSnowCover(double a_snowdepth, double a_rainfall, double a_temperature)
Definition: Weather.cpp:668
g_msg
MapErrorMsg * g_msg
Definition: MapErrorMsg.cpp:41
Weather::m_winddir_h
vector< vector< double > > m_winddir_h
Definition: Weather.h:405
Weather::m_hourly_today_index
int m_hourly_today_index
Definition: Weather.h:414
Weather::m_NoDays
int m_NoDays
Holds the number of days we have weather data for.
Definition: Weather.h:460
Weather::GetTempPeriod
double GetTempPeriod(long a_date, unsigned int a_period)
Definition: Weather.cpp:707
Weather::m_flyinghours
vector< double > m_flyinghours
Definition: Weather.h:400
Weather::m_wind
vector< double > m_wind
Definition: Weather.h:388
Weather::m_insolation
double m_insolation
Definition: Weather.h:434
Weather::m_raintoday
double m_raintoday
Definition: Weather.h:427
Weather::m_maxtemp
vector< double > m_maxtemp
Definition: Weather.h:396
CfgFloat
Double configurator entry class.
Definition: Configurator.h:126
Weather::m_mintempyesterday
double m_mintempyesterday
Definition: Weather.h:437
Weather::m_mintemp
vector< double > m_mintemp
Definition: Weather.h:395
Weather::m_soiltemp_h
vector< vector< double > > m_soiltemp_h
Definition: Weather.h:409
CFG_CUSTOM
Definition: Configurator.h:70
g_random_fnc
int g_random_fnc(const int a_range)
Definition: ALMaSS_Random.cpp:74
Calendar::DayInYear
int DayInYear(void)
Definition: Calendar.h:58
l_weather_starting_year
static CfgInt l_weather_starting_year("WEATHER_STARTING_YEAR", CFG_CUSTOM, 0)
l_weather_snowcover
static CfgBool l_weather_snowcover("WEATHER_SNOWCOVER", CFG_CUSTOM, false)
Weather::m_winddir8
vector< double > m_winddir8
Definition: Weather.h:390
Weather::readWeatherFile
void readWeatherFile(int NoDays, ifstream &inFile)
Definition: Weather.cpp:487
Weather::m_winddirtoday
int m_winddirtoday
Definition: Weather.h:429
Weather::m_maxtemptoday
double m_maxtemptoday
Definition: Weather.h:440
Weather::m_flyinghourstoday
double m_flyinghourstoday
Definition: Weather.h:444