Skip to content

Commit

Permalink
fix figures
Browse files Browse the repository at this point in the history
  • Loading branch information
malmans2 committed Apr 5, 2024
1 parent 91a9c32 commit 78398d5
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions notebooks/wp4/extreme_indices_future.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -619,9 +619,9 @@
"# Edit attributes\n",
"for ds in (ds_interpolated, *model_datasets.values()):\n",
" ds[\"trend\"] *= 10\n",
" ds[\"trend\"].attrs = {\"long_name\": \"trend\", \"units\": \"days / decade\"}\n",
" ds[\"trend\"].attrs = {\"long_name\": \"trend\"}\n",
" for index in index_names:\n",
" ds[index].attrs = {\"long_name\": \"\", \"units\": \"days\"}"
" ds[index].attrs = {\"long_name\": \"\", \"units\": ds[index].attrs[\"units\"]}"
]
},
{
Expand Down Expand Up @@ -685,6 +685,7 @@
" figsize=None,\n",
" layout=\"constrained\",\n",
" area=area,\n",
" flip_cmaps=False,\n",
" **kwargs,\n",
"):\n",
" if isinstance(data, dict):\n",
Expand Down Expand Up @@ -741,6 +742,7 @@
" layout=\"constrained\",\n",
" cbar_kwargs=None,\n",
" area=area,\n",
" flip_cmaps=False,\n",
" **kwargs,\n",
"):\n",
" # Get kwargs\n",
Expand Down Expand Up @@ -845,13 +847,16 @@
"source": [
"for index in index_names:\n",
" # Index\n",
" fig = plot_ensemble(da_models=ds_interpolated[index])\n",
" da = ds_interpolated[index]\n",
" fig = plot_ensemble(da_models=da)\n",
" fig.suptitle(f\"{index}\\n{common_title}\", y=0.8)\n",
" plt.show()\n",
"\n",
" # Trend\n",
" da_trend = ds_interpolated[\"trend\"].sel(index=index)\n",
" da_trend.attrs[\"units\"] = f\"{da.attrs['units']} / decade\"\n",
" fig = plot_ensemble(\n",
" da_models=ds_interpolated[\"trend\"].sel(index=index),\n",
" da_models=da_trend,\n",
" p_value_models=ds_interpolated[\"p\"].sel(index=index),\n",
" center=0,\n",
" )\n",
Expand All @@ -874,19 +879,22 @@
"source": [
"for index in index_names:\n",
" # Index\n",
" da_for_kwargs = ds_interpolated[index]\n",
" fig = plot_models(\n",
" data={model: ds[index] for model, ds in model_datasets.items()},\n",
" da_for_kwargs=ds_interpolated[index],\n",
" da_for_kwargs=da_for_kwargs,\n",
" )\n",
" fig.suptitle(f\"{index}\\n{common_title}\")\n",
" plt.show()\n",
"\n",
" # Trend\n",
" da_for_kwargs_trends = ds_interpolated[\"trend\"].sel(index=index)\n",
" da_for_kwargs_trends.attrs[\"units\"] = f\"{da_for_kwargs.attrs['units']} / decade\"\n",
" fig = plot_models(\n",
" data={\n",
" model: ds[\"trend\"].sel(index=index) for model, ds in model_datasets.items()\n",
" },\n",
" da_for_kwargs=ds_interpolated[\"trend\"].sel(index=index),\n",
" da_for_kwargs=da_for_kwargs_trends,\n",
" p_values={\n",
" model: ds[\"p\"].sel(index=index) for model, ds in model_datasets.items()\n",
" },\n",
Expand Down Expand Up @@ -936,7 +944,7 @@
"\n",
" labels = [f\"{collection_id} Ensemble\"]\n",
" ax.set_xticks(range(1, len(labels) + 1), labels)\n",
" ax.set_ylabel(da.attrs[\"units\"])\n",
" ax.set_ylabel(f\"{ds[index].attrs['units']} / decade\")\n",
" plt.suptitle(f\"Trend of {index}\")\n",
" plt.legend()\n",
" plt.show()"
Expand Down

0 comments on commit 78398d5

Please sign in to comment.