Skip to content

Commit

Permalink
Avoid deprecated use_cftime
Browse files Browse the repository at this point in the history
  • Loading branch information
aulemahal authored Feb 13, 2025
1 parent c26ad56 commit a08ec31
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/ravenpy/utilities/forecasting.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,13 +297,14 @@ def _shift_esp_time(nc, year, dim="member"):
Modify time such that it starts on the given year, and add member dimension with original year as value.
"""
ds = xr.open_dataset(nc, use_cftime=True)
ds = xr.open_dataset(nc)

# Create new time coordinate
start = ds.time.data[0]
start = ds.indexes['time'][0]
freq = xr.infer_freq(ds.time)
ds["time"] = xr.cftime_range(
start.replace(year=year), periods=len(ds.time), freq=freq
ds["time"] = xr.date_range(
start.replace(year=year), periods=len(ds.time), freq=freq,
calendar=ds.time.dt.calendar
)

# New coordinate dimension to store the original year
Expand Down

0 comments on commit a08ec31

Please sign in to comment.