Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
malmans2 committed Apr 15, 2024
1 parent 670707a commit 8a61fe0
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions notebooks/wp4/cmip6_energy_indices.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"id": "2",
"metadata": {},
"outputs": [],
Expand All @@ -45,7 +45,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 3,
"id": "4",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -96,7 +96,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 4,
"id": "6",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -140,7 +140,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 5,
"id": "8",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -176,7 +176,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 8,
"id": "10",
"metadata": {},
"outputs": [],
Expand All @@ -200,7 +200,7 @@
" chunks = {dim: -1 if dim == \"time\" else \"auto\" for dim in ds.dims}\n",
" ds.chunk(chunks).to_zarr(in_files)\n",
"\n",
" datasets = []\n",
" dataarrays = []\n",
" for index_name, timeseries in index_timeseries.items():\n",
" kwargs = {\n",
" \"in_files\": in_files,\n",
Expand All @@ -221,20 +221,17 @@
" else:\n",
" raise NotImplementedError(f\"{index_name=}\")\n",
"\n",
" ds_index = ds_index.drop_dims(\"bounds\")\n",
" (da,) = ds_index.drop_dims(\"bounds\").data_vars.values()\n",
" num_days = {\"DJF\": 90, \"MAM\": 92, \"JJA\": 92, \"SON\": 91}\n",
" with xr.set_options(keep_attrs=True):\n",
" ds_index /= (\n",
" da /= (\n",
" num_days[timeseries]\n",
" if timeseries != \"annual\"\n",
" else sum(num_days.values())\n",
" )\n",
" datasets.append(ds_index)\n",
"\n",
" ds = xr.merge(datasets)\n",
" for da in ds.data_vars.values():\n",
" da.attrs[\"units\"] = da.attrs[\"units\"].replace(\" d\", \"\")\n",
" return ds\n",
" dataarrays.append(da)\n",
" return xr.merge(dataarrays)\n",
"\n",
"\n",
"def compute_trends(ds):\n",
Expand Down Expand Up @@ -339,7 +336,15 @@
"execution_count": null,
"id": "12",
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"100%|██████████| 6/6 [00:11<00:00, 1.86s/it]\n"
]
}
],
"source": [
"transform_func_kwargs = {\n",
" \"index_timeseries\": dict(sorted(index_timeseries.items())),\n",
Expand Down

0 comments on commit 8a61fe0

Please sign in to comment.