Ejemplo n.º 1
0
 def __init__(self, siteId, year, month, monthObjs, yearObj, dayObjs,
              manualDayObjs):
     self.siteId = siteId
     self.year = year
     self.month = month
     self.monthObjs = monthObjs
     self.yearObj = yearObj
     self.dayObjs = dayObjs
     self.manualDayObjs = manualDayObjs
     self.monthObj = Month(year=self.year, month=self.month)
     self.days = Month(year=self.year, month=self.month).get_days_of_month()
     self.tempMins, self.tempAvgs, self.tempMaxs = self.collect_daily_temperature(
     )
     self.indices = self.calculate_climate_index_days()
     self.tempDist = json.dumps(self.generate_temp_distribution())
     self.rhDist = json.dumps(self.generate_rh_distribution())
     self.prec = json.dumps(self.collect_daily_precipitation())
     self.precDist = Climate.get_precipitation_over_limits(
         self.collect_daily_precipitation())
     self.windDist = json.dumps(self.generate_wind_distribution())
     self.significants = json.dumps(monthObjs[0].significants)
     self.precipitation = Climate.sum(self.collect_daily_precipitation())
     self.tmin = Climate.avg(self.tempMins)
     self.tmax = Climate.avg(self.tempMaxs)
     self.tavg = Climate.avg2(self.tempMins, self.tempMaxs)
     self.dataAvailable = self.calculate_number_of_available_data()
     self.tempMins = json.dumps(self.tempMins)
     self.tempAvgs = json.dumps(self.tempAvgs)
     self.tempMaxs = json.dumps(self.tempMaxs)
     self.snowDepths = json.dumps(self.collect_snow_depth())
     self.snowDays = self.get_nr_of_snow_days()
     self.comments = self.get_comments()
Ejemplo n.º 2
0
 def test_prec_dist_zero(self):
     self.assertEqual(Climate.get_precipitation_over_limits([0, 0, 0]), {
         0: 0,
         10: 0,
         30: 0,
         50: 0
     })
Ejemplo n.º 3
0
 def test_prec_high(self):
     self.assertEqual(
         Climate.get_precipitation_over_limits([0, 0.1, 10.0, 50.0, 150]), {
             0: 4,
             10: 3,
             30: 2,
             50: 2
         })
Ejemplo n.º 4
0
 def test_prec_med(self):
     self.assertEqual(
         Climate.get_precipitation_over_limits([0, 0.1, 10.0, 10.1]), {
             0: 3,
             10: 2,
             30: 0,
             50: 0
         })
Ejemplo n.º 5
0
 def test_prec_small(self):
     self.assertEqual(
         Climate.get_precipitation_over_limits([0, 0.1, 0.5, 1]), {
             0: 3,
             10: 0,
             30: 0,
             50: 0
         })
Ejemplo n.º 6
0
 def __init__(self, siteId, year, monthObjs, yearObj, dayObjs,
              manualDayObjs):
     self.siteId = siteId
     self.year = year
     self.monthObjs = monthObjs
     self.yearObj = yearObj
     self.dayObjs = dayObjs
     self.manualDayObjs = manualDayObjs
     self.months = Year.get_months_of_year()
     self.temps = {
         'mins': json.dumps(self.collect_monthly_data('tempMin')),
         'minAvgs': json.dumps(self.collect_monthly_data('tempMinAvg')),
         'avgs': json.dumps(self.collect_monthly_data('tempAvg')),
         'maxAvgs': json.dumps(self.collect_monthly_data('tempMaxAvg')),
         'maxs': json.dumps(self.collect_monthly_data('tempMax'))
     }
     self.tempIndices = {
         'summerDays': json.dumps(self.collect_monthly_data('summerDays')),
         'frostDays': json.dumps(self.collect_monthly_data('frostDays')),
         'winterDays': json.dumps(self.collect_monthly_data('winterDays')),
         'coldDays': json.dumps(self.collect_monthly_data('coldDays')),
         'warmNights': json.dumps(self.collect_monthly_data('warmNights')),
         'warmDays': json.dumps(self.collect_monthly_data('warmDays')),
         'hotDays': json.dumps(self.collect_monthly_data('hotDays'))
     }
     self.prec = json.dumps(self.collect_monthly_data('precipitation'))
     self.tempDist = json.dumps(self.generate_temperature_distribution())
     self.rhDist = json.dumps(self.generate_rh_distribution())
     self.windDist = json.dumps(self.generate_wind_distribution())
     self.precipitation = Climate.sum(
         self.collect_monthly_data('precipitation'))
     self.precDist = Climate.get_precipitation_over_limits(
         self.collect_daily_data('precipitation'))
     self.tmin = Climate.avg(self.collect_monthly_data('tempMin'))
     self.tmax = Climate.avg(self.collect_monthly_data('tempMax'))
     self.tavg = Climate.avg2(self.collect_monthly_data('tempMin'),
                              self.collect_monthly_data('tempMax'))
     self.dataAvailable = self.calculate_number_of_available_data()
     self.snowDays = self.get_nr_of_snow_days()