Update data/climate_data.py
Browse files- data/climate_data.py +7 -4
data/climate_data.py
CHANGED
|
@@ -117,10 +117,13 @@ class ClimateLocation:
|
|
| 117 |
self.summer_design_temp_db = round(np.nanpercentile(dry_bulb, 99.6), 1)
|
| 118 |
self.summer_design_temp_wb = round(np.nanpercentile(wet_bulb, 99.6), 1)
|
| 119 |
|
| 120 |
-
# Calculate degree days
|
| 121 |
-
daily_temps =
|
| 122 |
-
|
| 123 |
-
|
|
|
|
|
|
|
|
|
|
| 124 |
|
| 125 |
# Calculate summer daily temperature range (June–August, Southern Hemisphere)
|
| 126 |
summer_mask = (months >= 6) & (months <= 8)
|
|
|
|
| 117 |
self.summer_design_temp_db = round(np.nanpercentile(dry_bulb, 99.6), 1)
|
| 118 |
self.summer_design_temp_wb = round(np.nanpercentile(wet_bulb, 99.6), 1)
|
| 119 |
|
| 120 |
+
# Calculate degree days using (T_max + T_min)/2
|
| 121 |
+
daily_temps = dry_bulb.reshape(-1, 24)
|
| 122 |
+
daily_max = np.nanmax(daily_temps, axis=1)
|
| 123 |
+
daily_min = np.nanmin(daily_temps, axis=1)
|
| 124 |
+
daily_avg = (daily_max + daily_min) / 2
|
| 125 |
+
self.heating_degree_days = round(np.nansum(np.where(daily_avg < 18, 18 - daily_avg, 0)))
|
| 126 |
+
self.cooling_degree_days = round(np.nansum(np.where(daily_avg > 18, daily_avg - 18, 0)))
|
| 127 |
|
| 128 |
# Calculate summer daily temperature range (June–August, Southern Hemisphere)
|
| 129 |
summer_mask = (months >= 6) & (months <= 8)
|