Skip to content

Commit

Permalink
Use datetime64[ns] dtypes rather than datetime64[D]. Day resoluti…
Browse files Browse the repository at this point in the history
…on is not fully supported in Xarray. See pydata/xarray#7493

PiperOrigin-RevId: 625092146
  • Loading branch information
langmore authored and Weatherbench2 authors committed Apr 15, 2024
1 parent b2cc3d7 commit ed83272
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions scripts/resample_daily.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def main(argv: abc.Sequence[str]) -> None:
orig_times.min() - np.timedelta64(rolling_window - 1, 'D'),
orig_times.max() - np.timedelta64(rolling_window - 2, 'D'),
dtype='datetime64[D]',
)
).astype('datetime64[ns]')
elif METHOD.value == 'resample':
if PERIOD.value[-1] == 'w':
raise NotImplementedError(
Expand All @@ -181,7 +181,7 @@ def main(argv: abc.Sequence[str]) -> None:
orig_times.min(),
orig_times.max() + np.timedelta64(1, 'D'),
dtype='datetime64[D]',
)
).astype('datetime64[ns]')
else:
raise ValueError(f'Method {METHOD.value} not supported.')

Expand Down
2 changes: 1 addition & 1 deletion weatherbench2/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def select_hour(ds: xr.Dataset, hour: int) -> xr.Dataset:
# Select hour
ds = ds.isel(time=ds.time.dt.hour == hour)
# Adjust time dimension
ds = ds.assign_coords({'time': ds.time.astype('datetime64[D]')})
ds = ds.assign_coords({'time': ds.time.astype('datetime64[ns]')})
return ds


Expand Down

0 comments on commit ed83272

Please sign in to comment.