Skip to content

Commit e099868

Browse files
committed
Set reduced date to 0 and cosmetic changes
1 parent a4fe3b0 commit e099868

File tree

2 files changed

+13
-16
lines changed

2 files changed

+13
-16
lines changed

climada/hazard/forecast.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -106,29 +106,29 @@ def _check_sizes(self):
106106
size(exp_len=num_entries, var=self.member, var_name="Forecast.member")
107107
size(exp_len=num_entries, var=self.lead_time, var_name="Forecast.lead_time")
108108

109-
def _reduce_attrs(self, reduce_method: str):
109+
def _reduce_attrs(self, event_name: str):
110110
"""
111111
Reduce the attributes of a HazardForecast to a single value.
112112
113113
Attributes are modified as follows:
114114
- lead_time: set to NaT
115115
- member: set to -1
116116
- event_id: set to 0
117-
- event_name: set to reduce_method
118-
- date: set to the minimum value
117+
- event_name: set to the name of the reduction method (default)
118+
- date: set to 0
119119
- frequency: set to 1
120120
121121
Parameters
122122
----------
123-
reduce_method : str
124-
The reduction method used to reduce the attributes.
123+
event_name : str
124+
The event_name given to the reduced data.
125125
"""
126126
reduced_attrs = {
127127
"lead_time": np.array([np.timedelta64("NaT")]),
128128
"member": np.array([-1]),
129129
"event_id": np.array([0]),
130-
"event_name": np.array([reduce_method]),
131-
"date": np.array([self.date.min()]),
130+
"event_name": np.array([event_name]),
131+
"date": np.array([0]),
132132
"frequency": np.array([1]),
133133
"orig": np.array([True]),
134134
}
@@ -137,7 +137,7 @@ def _reduce_attrs(self, reduce_method: str):
137137

138138
def min(self):
139139
"""
140-
Reduce the impact matrix and at_event of a HazardForecast to the minimum
140+
Reduce the intensity and fraction of a HazardForecast to the minimum
141141
value.
142142
143143
Parameters
@@ -171,7 +171,7 @@ def min(self):
171171

172172
def max(self):
173173
"""
174-
Reduce the impact matrix and at_event of a HazardForecast to the maximum
174+
Reduce the intensity and fraction of a HazardForecast to the maximum
175175
value.
176176
177177
Parameters
@@ -205,10 +205,7 @@ def max(self):
205205

206206
def mean(self):
207207
"""
208-
Reduce the impact matrix and at_event of a HazardForecast to the mean value.
209-
210-
The mean value is computed by taking the mean of the impact matrix along the
211-
exposure points axis (axis=1) and then taking the mean of the resulting array.
208+
Reduce the intensity and fraction of a HazardForecast to the mean value.
212209
213210
Parameters
214211
----------

climada/hazard/test/test_forecast.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,9 +209,9 @@ def test_hazard_forecast_mean_min_max(haz_fc):
209209
assert haz_fcst_mean.frequency == 1
210210
assert haz_fcst_min.frequency == 1
211211
assert haz_fcst_max.frequency == 1
212-
assert haz_fcst_mean.date == haz_fc.date.min()
213-
assert haz_fcst_min.date == haz_fc.date.min()
214-
assert haz_fcst_max.date == haz_fc.date.min()
212+
assert haz_fcst_mean.date == 0
213+
assert haz_fcst_min.date == 0
214+
assert haz_fcst_max.date == 0
215215
assert np.all(haz_fcst_mean.orig)
216216
assert np.all(haz_fcst_min.orig)
217217
assert np.all(haz_fcst_max.orig)

0 commit comments

Comments
 (0)