Skip to content

Commit 27ee039

Browse files
committed
update notebooks based on review feedback
1 parent e16b6db commit 27ee039

8 files changed

Lines changed: 4258 additions & 183 deletions

datasets/met-office/met-office-global-deterministic-height.ipynb

Lines changed: 598 additions & 25 deletions
Large diffs are not rendered by default.

datasets/met-office/met-office-global-deterministic-near-surface.ipynb

Lines changed: 591 additions & 26 deletions
Large diffs are not rendered by default.

datasets/met-office/met-office-global-deterministic-pressure.ipynb

Lines changed: 599 additions & 24 deletions
Large diffs are not rendered by default.

datasets/met-office/met-office-global-deterministic-whole-atmosphere.ipynb

Lines changed: 592 additions & 26 deletions
Large diffs are not rendered by default.

datasets/met-office/met-office-uk-deterministic-height.ipynb

Lines changed: 603 additions & 25 deletions
Large diffs are not rendered by default.

datasets/met-office/met-office-uk-deterministic-near-surface.ipynb

Lines changed: 38 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
"id": "941120d0",
1414
"metadata": {},
1515
"source": [
16-
"Set-up the pystac client to access the Microsoft Planetary Computer catalog"
16+
"This example notebook provides a walkthrough accessing the [Met Office UK Near Surface collection](https://planetarycomputer.microsoft.com/dataset/met-office-uk-deterministic-near-surface) on Microsoft Planetary Computer. This notebook outputs an image of UK surface temperatures across a forecast period.\n",
17+
"\n",
18+
"First, import required libraries and set-up the pystac client to access the Planetary Computer STAC API."
1719
]
1820
},
1921
{
@@ -23,8 +25,11 @@
2325
"metadata": {},
2426
"outputs": [],
2527
"source": [
28+
"import fsspec\n",
29+
"import matplotlib.pyplot as plt\n",
2630
"from pystac_client import Client\n",
2731
"import planetary_computer\n",
32+
"import xarray as xr\n",
2833
"\n",
2934
"catalog = Client.open(\n",
3035
" \"https://planetarycomputer.microsoft.com/api/stac/v1\",\n",
@@ -42,7 +47,7 @@
4247
},
4348
{
4449
"cell_type": "code",
45-
"execution_count": null,
50+
"execution_count": 6,
4651
"id": "8f95ecac",
4752
"metadata": {},
4853
"outputs": [],
@@ -56,10 +61,11 @@
5661
" \"op\": \"=\",\n",
5762
" \"args\": [\n",
5863
" {\"property\": \"forecast:reference_datetime\"},\n",
59-
" \"2026-01-21T09:00:00Z\",\n",
64+
" \"2026-01-30T09:00:00Z\",\n",
6065
" ],\n",
6166
" },\n",
6267
" {\"op\": \"=\", \"args\": [{\"property\": \"forecast:horizon\"}, \"PT0054H00M\"]},\n",
68+
" {\"op\": \"=\", \"args\": [{\"property\": \"forecast:variable\"}, \"surface_temperature\"]},\n",
6369
" ],\n",
6470
"}"
6571
]
@@ -77,35 +83,25 @@
7783
"execution_count": null,
7884
"id": "edb71afa",
7985
"metadata": {},
80-
"outputs": [
81-
{
82-
"ename": "StopIteration",
83-
"evalue": "",
84-
"output_type": "error",
85-
"traceback": [
86-
"\u001b[31m---------------------------------------------------------------------------\u001b[39m",
87-
"\u001b[31mStopIteration\u001b[39m Traceback (most recent call last)",
88-
"\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[19]\u001b[39m\u001b[32m, line 6\u001b[39m\n\u001b[32m 1\u001b[39m search = catalog.search(\n\u001b[32m 2\u001b[39m collections=collections,\n\u001b[32m 3\u001b[39m datetime=\u001b[33m\"\u001b[39m\u001b[33m2026-01-21T09:00:00Z\u001b[39m\u001b[33m\"\u001b[39m,\n\u001b[32m 4\u001b[39m )\n\u001b[32m----> \u001b[39m\u001b[32m6\u001b[39m asset_url = \u001b[38;5;28;43mnext\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43mitem\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43;01mfor\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mitem\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;129;43;01min\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43msearch\u001b[49m\u001b[43m.\u001b[49m\u001b[43mitems\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43;01mif\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mitem\u001b[49m\u001b[43m.\u001b[49m\u001b[43mproperties\u001b[49m\u001b[43m[\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mforecast:horizon\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m]\u001b[49m\u001b[43m \u001b[49m\u001b[43m==\u001b[49m\u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mPT0054H00M\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m)\u001b[49m.assets[asset_id].href\n",
89-
"\u001b[31mStopIteration\u001b[39m: "
90-
]
91-
}
92-
],
86+
"outputs": [],
9387
"source": [
9488
"search = catalog.search(\n",
95-
" collections=collections,\n",
96-
" filter_lang=\"cql2-json\",\n",
97-
" filter=forecast_extension_filters,\n",
89+
" collections=collections, filter_lang=\"cql2-json\", filter=forecast_extension_filters\n",
9890
")\n",
9991
"\n",
100-
"asset_url = next(search.items()).assets[asset_id].href"
92+
"items = search.item_collection()\n",
93+
"print (f\"Item Dictionary - {items.items[0].assets}\")\n",
94+
"\n",
95+
"asset_url = items.items[0].assets[asset_id].href\n",
96+
"print(f\"URL for specific NetCDF - {asset_url}\")"
10197
]
10298
},
10399
{
104100
"cell_type": "markdown",
105101
"id": "56d27e19",
106102
"metadata": {},
107103
"source": [
108-
"Example usage: Plot NetCDF data on a map"
104+
"Example usage: Open and inspect NetCDF data"
109105
]
110106
},
111107
{
@@ -115,19 +111,33 @@
115111
"metadata": {},
116112
"outputs": [],
117113
"source": [
118-
"import fsspec\n",
119-
"import xarray as xr\n",
120-
"import matplotlib.pyplot as plt\n",
121-
"\n",
122-
"example_netcdf = xr.open_dataset(fsspec.open(asset_url, expand=True).open())\n",
114+
"example_netcdf = xr.open_dataset(fsspec.open(asset_url, expand=True).open(), decode_timedelta=True)\n",
115+
"example_netcdf"
116+
]
117+
},
118+
{
119+
"cell_type": "markdown",
120+
"id": "ffa6be66",
121+
"metadata": {},
122+
"source": [
123+
"Plot surface temperatures on a map"
124+
]
125+
},
126+
{
127+
"cell_type": "code",
128+
"execution_count": null,
129+
"id": "820f3c35",
130+
"metadata": {},
131+
"outputs": [],
132+
"source": [
123133
"plt.figure(figsize=(10, 5))\n",
124134
"example_netcdf[\"surface_temperature\"].plot()"
125135
]
126136
}
127137
],
128138
"metadata": {
129139
"kernelspec": {
130-
"display_name": "PlanetaryComputerExamples",
140+
"display_name": ".venv",
131141
"language": "python",
132142
"name": "python3"
133143
},
@@ -141,7 +151,7 @@
141151
"name": "python",
142152
"nbconvert_exporter": "python",
143153
"pygments_lexer": "ipython3",
144-
"version": "3.13.2"
154+
"version": "3.13.11"
145155
}
146156
},
147157
"nbformat": 4,

0 commit comments

Comments
 (0)