Skip to content

Commit

Permalink
fix cordex
Browse files Browse the repository at this point in the history
  • Loading branch information
malmans2 committed Feb 22, 2024
1 parent b7b1fae commit 5d7335f
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions notebooks/wp4/extreme_temperature_indices.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -304,13 +304,14 @@
" xr.save_mfdataset(datasets, paths)\n",
"\n",
" ds = xr.open_mfdataset(paths)\n",
" print(ds)\n",
" (da,) = ds.data_vars.values()\n",
" mask = da.notnull().any(\"time\")\n",
"\n",
" in_files = f\"{tmpdir}/rechunked.zarr\"\n",
" ds.chunk(\n",
" {dim: -1 if dim == \"time\" else \"auto\" for dim in set(ds.dims) & set(ds.cf.axes)}\n",
" ).to_zarr(in_files)\n",
" ds.chunk({dim: -1 if dim == \"time\" else \"auto\" for dim in da.dims}).to_zarr(\n",
" in_files\n",
" )\n",
"\n",
" datasets = [\n",
" icclim.index(\n",
Expand All @@ -321,6 +322,7 @@
" )\n",
" for index_name in index_names\n",
" ]\n",
"\n",
" return xr.merge(datasets).where(mask).drop_dims(\"bounds\")\n",
"\n",
"\n",
Expand Down Expand Up @@ -356,6 +358,10 @@
" resample,\n",
" **regrid_kwargs,\n",
"):\n",
" if \"rotated_pole\" in ds:\n",
" ds = ds.drop_vars(\"rotated_pole\")\n",
"\n",
" # Original bounds for conservative interpolation\n",
" if regrid_kwargs.get(\"method\") == \"conservative\":\n",
" bounds = [\n",
" ds.cf.get_bounds(coord).reset_coords(drop=True)\n",
Expand Down

0 comments on commit 5d7335f

Please sign in to comment.