Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No public description #221

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions weatherbench2/derived_variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -686,16 +686,16 @@ def interp_at_one_lat(da: xr.DataArray) -> xr.DataArray:
class AggregatePrecipitationAccumulation(DerivedVariable):
"""Compute longer aggregation periods from existing shorter accumulations.

Note: This assumes a 6h raw time step and prediction_timedelta starting at 6h.

Attributes:
accumulation_hours: Hours to accumulate precipitaiton over
raw_accumulation_name: Name of the 6hr accumulation
raw_accumulation_name: Name of the 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
Expand All @@ -711,7 +711,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
Expand Down Expand Up @@ -763,4 +764,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,
),
}
Loading