Skip to content

Commit

Permalink
Merge pull request #81 from mgrover1/fix-intake-esgf-notebook
Browse files Browse the repository at this point in the history
FIX: Fix api changes in intake-esgf
  • Loading branch information
mgrover1 authored May 14, 2024
2 parents 376edaf + 1a6d893 commit 5b53440
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
1 change: 1 addition & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ dependencies:
- jupyterlab
- jupyter_server
- globus-compute-sdk
- ipywidgets
- pip
- sphinx-pythia-theme
- ipywidgets
Expand Down
26 changes: 18 additions & 8 deletions notebooks/example-workflows/enso-esgf.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
" source_id=\"CESM2\",\n",
" variable_id=[\"tos\"],\n",
" member_id='r11i1p1f1',\n",
" grid_label=\"gn\",\n",
" table_id=\"Omon\",\n",
" )"
]
Expand All @@ -129,18 +130,30 @@
},
"outputs": [],
"source": [
"tos_tree = cat.to_datatree()\n",
"tos_tree = cat.to_dataset_dict()\n",
"tos_tree"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "3694d7de-3b75-4e25-8001-1fa5c7877f53",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"tos_tree[]"
]
},
{
"cell_type": "markdown",
"id": "5395c611-afda-405e-9b1c-35b7566c557f",
"metadata": {
"tags": []
},
"source": [
"The nodes in the tree represent two different, grids. We would like to stay on the native model grid, using the `gn` node of the datatree, which represents the model native grid data."
"There is only one variable in this dictionary of datasets, `tos`, which is the \"Sea Surface Temperature\". We can extract this dataset by passing in that key:"
]
},
{
Expand All @@ -152,7 +165,7 @@
},
"outputs": [],
"source": [
"ds = tos_tree[\"gn\"].to_dataset()\n",
"ds = tos_tree[\"tos\"]\n",
"ds"
]
},
Expand Down Expand Up @@ -373,16 +386,13 @@
" activity_id=\"CMIP\",\n",
" experiment_id=\"historical\",\n",
" institution_id=institution_id,\n",
" grid_label=grid,\n",
" variable_id=[\"tos\"],\n",
" member_id='r11i1p1f1',\n",
" table_id=\"Omon\",\n",
" )\n",
" try:\n",
" tos_ds = cat.to_datatree()[grid].to_dataset()\n",
" except KeyError:\n",
" tos_ds = cat.to_dataset_dict()[\"tos\"]\n",
"\n",
" return tos_ds"
" return cat.to_dataset_dict()[\"tos\"]"
]
},
{
Expand Down

0 comments on commit 5b53440

Please sign in to comment.