Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
malmans2 committed Apr 9, 2024
1 parent 9946700 commit 996f169
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 6 deletions.
21 changes: 18 additions & 3 deletions notebooks/wp4/extreme_indices.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"import icclim\n",
"import matplotlib.pyplot as plt\n",
"import xarray as xr\n",
"from c3s_eqc_automatic_quality_control import diagnostics, download, plot\n",
"from c3s_eqc_automatic_quality_control import diagnostics, download, plot, utils\n",
"from xarrayMannKendall import Mann_Kendall_test\n",
"\n",
"plt.style.use(\"seaborn-v0_8-notebook\")\n",
Expand Down Expand Up @@ -96,6 +96,9 @@
"# Interpolation method\n",
"interpolation_method = \"bilinear\"\n",
"\n",
"# Area to show\n",
"area = [72, -22, 27, 45]\n",
"\n",
"# Chunks for download\n",
"chunks = {\"year\": 1}"
]
Expand Down Expand Up @@ -187,7 +190,6 @@
},
"outputs": [],
"source": [
"area = [72, -22, 27, 45]\n",
"request_era = (\n",
" \"reanalysis-era5-single-levels\",\n",
" {\n",
Expand Down Expand Up @@ -556,8 +558,21 @@
"metadata": {},
"outputs": [],
"source": [
"# Mask\n",
"lsm = download.download_and_transform(*request_lsm)[\"lsm\"].squeeze(drop=True)\n",
"\n",
"# Cutout\n",
"regionalise_kwargs = {\n",
" \"lon_slice\": slice(area[1], area[3]),\n",
" \"lat_slice\": slice(area[0], area[2]),\n",
"}\n",
"lsm = utils.regionalise(lsm, **regionalise_kwargs)\n",
"ds_interpolated = utils.regionalise(ds_interpolated, **regionalise_kwargs)\n",
"model_datasets = {\n",
" model: utils.regionalise(ds, **regionalise_kwargs)\n",
" for model, ds in model_datasets.items()\n",
"}\n",
"\n",
"# Mask\n",
"ds_era5 = ds_era5.where(lsm)\n",
"ds_interpolated = ds_interpolated.where(lsm)\n",
"model_datasets = {\n",
Expand Down
21 changes: 18 additions & 3 deletions notebooks/wp4/extreme_indices_future.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"import icclim\n",
"import matplotlib.pyplot as plt\n",
"import xarray as xr\n",
"from c3s_eqc_automatic_quality_control import diagnostics, download, plot\n",
"from c3s_eqc_automatic_quality_control import diagnostics, download, plot, utils\n",
"from xarrayMannKendall import Mann_Kendall_test\n",
"\n",
"plt.style.use(\"seaborn-v0_8-notebook\")\n",
Expand Down Expand Up @@ -96,6 +96,9 @@
"# Interpolation method\n",
"interpolation_method = \"bilinear\"\n",
"\n",
"# Area to show\n",
"area = [72, -22, 27, 45]\n",
"\n",
"# Chunks for download\n",
"chunks = {\"year\": 1}"
]
Expand Down Expand Up @@ -182,7 +185,6 @@
"metadata": {},
"outputs": [],
"source": [
"area = [72, -22, 27, 45]\n",
"request_lsm = (\n",
" \"reanalysis-era5-single-levels\",\n",
" {\n",
Expand Down Expand Up @@ -602,8 +604,21 @@
"metadata": {},
"outputs": [],
"source": [
"# Mask\n",
"lsm = download.download_and_transform(*request_lsm)[\"lsm\"].squeeze(drop=True)\n",
"\n",
"# Cutout\n",
"regionalise_kwargs = {\n",
" \"lon_slice\": slice(area[1], area[3]),\n",
" \"lat_slice\": slice(area[0], area[2]),\n",
"}\n",
"lsm = utils.regionalise(lsm, **regionalise_kwargs)\n",
"ds_interpolated = utils.regionalise(ds_interpolated, **regionalise_kwargs)\n",
"model_datasets = {\n",
" model: utils.regionalise(ds, **regionalise_kwargs)\n",
" for model, ds in model_datasets.items()\n",
"}\n",
"\n",
"# Mask\n",
"ds_interpolated = ds_interpolated.where(\n",
" diagnostics.regrid(lsm, ds_interpolated, method=\"bilinear\")\n",
")\n",
Expand Down

0 comments on commit 996f169

Please sign in to comment.