Commit 9a128f46 authored by Aaron Spring's avatar Aaron Spring 🚼
Browse files

fix add_year_week_coords

parent e3cded0a
Pipeline #234503 passed with stages
in 4 minutes
......@@ -147,11 +147,11 @@ def ensure_attributes(da, biweekly=False):
def add_year_week_coords(ds):
import numpy as np
if 'week' not in ds.coords and 'year' not in ds.coords:
year = ds.forecast_time.dt.year.to_index().unique()
week = sorted(list(ds.forecast_time.dt.week.to_index().unique()))
week = (list(np.arange(1,54)))
weeks = week * len(year)
import numpy as np
years = np.repeat(year,len(week))
ds.coords["week"] = ("forecast_time", weeks)
ds.coords['week'].attrs['description'] = "This week represents the number of forecast_time starting from 1 to 53. Note: This week is different from the ISO week from groupby('forecast_time.weekofyear'), see https://en.wikipedia.org/wiki/ISO_week_date and https://renkulab.io/gitlab/aaron.spring/s2s-ai-challenge/-/issues/29"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment