Skip to content

Commit

Permalink
fix extremes
Browse files Browse the repository at this point in the history
  • Loading branch information
malmans2 committed Mar 26, 2024
1 parent 976799c commit 4957885
Show file tree
Hide file tree
Showing 3 changed files with 195 additions and 91 deletions.
10 changes: 7 additions & 3 deletions notebooks/wp4/extreme_temperature_indices.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,8 @@
" \"time\": [f\"{hour:02d}:00\" for hour in range(24)],\n",
" \"variable\": \"2m_temperature\",\n",
" \"year\": [\n",
" str(year) for year in range(year_start - 1, year_stop + 1)\n",
" str(year)\n",
" for year in range(year_start - int(timeseries == \"DJF\"), year_stop + 1)\n",
" ], # Include D(year-1)\n",
" \"month\": [f\"{month:02d}\" for month in range(1, 13)],\n",
" \"day\": [f\"{day:02d}\" for day in range(1, 32)],\n",
Expand Down Expand Up @@ -241,12 +242,13 @@
"def get_cordex_years(\n",
" year_start,\n",
" year_stop,\n",
" timeseries,\n",
" start_years=list(range(1951, 2097, 5)),\n",
" end_years=list(range(1955, 2101, 5)),\n",
"):\n",
" start_year = []\n",
" end_year = []\n",
" years = set(range(year_start - 1, year_stop + 1)) # Include D(year-1)\n",
" years = set(range(year_start - int(timeseries == \"DJF\"), year_stop + 1))\n",
" for start, end in zip(start_years, end_years):\n",
" if years & set(range(start, end + 1)):\n",
" start_year.append(start)\n",
Expand All @@ -265,7 +267,9 @@
" \"start_year\": start_year,\n",
" \"end_year\": end_year,\n",
" }\n",
" for start_year, end_year in zip(*get_cordex_years(year_start, year_stop))\n",
" for start_year, end_year in zip(\n",
" *get_cordex_years(year_start, year_stop, timeseries)\n",
" )\n",
" ],\n",
" )\n",
"elif collection_id == \"CMIP6\":\n",
Expand Down
9 changes: 6 additions & 3 deletions notebooks/wp4/extreme_temperature_indices_future.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@
"\n",
"def get_cordex_years(\n",
" year_slice,\n",
" timeseries,\n",
" start_years=list(range(1951, 2097, 5)),\n",
" end_years=list(range(1955, 2101, 5)),\n",
"):\n",
Expand Down Expand Up @@ -254,7 +255,9 @@
" \"start_year\": start_year,\n",
" \"end_year\": end_year,\n",
" }\n",
" for start_year, end_year in zip(*get_cordex_years(historical_slice))\n",
" for start_year, end_year in zip(\n",
" *get_cordex_years(historical_slice, timeseries)\n",
" )\n",
" ]\n",
" + [\n",
" {\n",
Expand All @@ -263,7 +266,7 @@
" \"start_year\": start_year,\n",
" \"end_year\": end_year,\n",
" }\n",
" for start_year, end_year in zip(*get_cordex_years(future_slice))\n",
" for start_year, end_year in zip(*get_cordex_years(future_slice, timeseries))\n",
" ],\n",
" )\n",
"elif collection_id == \"CMIP6\":\n",
Expand All @@ -277,7 +280,7 @@
" )\n",
" requests_future = download.split_request(\n",
" request_cmip6\n",
" | {\"year\": get_cmip6_years(future_slice), \"experiment\": \"ssp5_8_5\"},\n",
" | {\"year\": get_cmip6_years(future_slice), \"experiment\": \"rcp_8_5\"},\n",
" chunks=chunks,\n",
" )\n",
" request_sim = (\n",
Expand Down
Loading

0 comments on commit 4957885

Please sign in to comment.