Skip to content

Commit

Permalink
fix year start
Browse files Browse the repository at this point in the history
  • Loading branch information
malmans2 committed Mar 25, 2024
1 parent 1a91844 commit aa1748c
Showing 1 changed file with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -231,12 +231,10 @@
"def select_timeseries(ds, timeseries, year_stop_historical):\n",
" datasets = []\n",
" for ds in separate_historical_and_future(ds, year_stop_historical):\n",
" year_start = ds[\"time\"].dt.year.min().values + 1\n",
" year_stop = ds[\"time\"].dt.year.max().values\n",
" if timeseries == \"annual\":\n",
" ds = ds.sel(time=slice(str(year_start), str(year_stop)))\n",
" else:\n",
" ds = ds.sel(time=slice(f\"{year_start-1}-12\", f\"{year_stop}-11\"))\n",
" if timeseries == \"DJF\":\n",
" year_start = ds[\"time\"].dt.year.min().values\n",
" year_stop = ds[\"time\"].dt.year.max().values\n",
" ds = ds.sel(time=slice(f\"{year_start}-12\", f\"{year_stop}-11\"))\n",
" datasets.append(ds)\n",
" ds = xr.concat(datasets, \"time\")\n",
" return ds.where(ds[\"time\"].dt.season == timeseries, drop=True)\n",
Expand Down

0 comments on commit aa1748c

Please sign in to comment.