From 9fdbb1a39ea5263f82cb373b38fbc1804d3de0de Mon Sep 17 00:00:00 2001 From: Weatherbench authors Date: Sun, 22 Dec 2024 23:23:44 -0800 Subject: [PATCH] No public description PiperOrigin-RevId: 708963703 --- weatherbench2/derived_variables.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/weatherbench2/derived_variables.py b/weatherbench2/derived_variables.py index e7d8199..70b1a54 100644 --- a/weatherbench2/derived_variables.py +++ b/weatherbench2/derived_variables.py @@ -691,11 +691,13 @@ class AggregatePrecipitationAccumulation(DerivedVariable): Attributes: accumulation_hours: Hours to accumulate precipitaiton over raw_accumulation_name: Name of the 6hr accumulation + raw_accumulation_hours: Hours of the raw accumulation lead_time_name: Name of lead_time dimension """ accumulation_hours: int raw_accumulation_name: str = 'total_precipitation_6hr' + raw_accumulation_hours: int = 6 lead_time_name: str = 'prediction_timedelta' @property @@ -711,7 +713,8 @@ def compute(self, dataset: xr.Dataset): # Compute aggregation steps steps = float( - np.timedelta64(self.accumulation_hours, 'h') / np.timedelta64(6, 'h') + np.timedelta64(self.accumulation_hours, 'h') + / np.timedelta64(self.raw_accumulation_hours, 'h') ) assert steps.is_integer(), 'Accumulation time must be multiple of timestep.' # Compute accumulation @@ -763,4 +766,10 @@ def compute(self, dataset: xr.Dataset): accumulation_hours=24, lead_time_name='prediction_timedelta', ), + 'total_precipitation_24hr_from_12hr': AggregatePrecipitationAccumulation( + accumulation_hours=24, + lead_time_name='prediction_timedelta', + raw_accumulation_name='total_precipitation_12hr', + raw_accumulation_hours=12, + ), }