diff --git a/datasets/met-office/met-office-global-deterministic-height.ipynb b/datasets/met-office/met-office-global-deterministic-height.ipynb new file mode 100644 index 0000000..d179b1c --- /dev/null +++ b/datasets/met-office/met-office-global-deterministic-height.ipynb @@ -0,0 +1,138 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "fbf471b1", + "metadata": {}, + "source": [ + "# Accessing Global Height data from Microsoft Planetary Computer" + ] + }, + { + "cell_type": "markdown", + "id": "941120d0", + "metadata": {}, + "source": [ + "Set-up the pystac client to access the Microsoft Planetary Computer catalog" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "4bafd899", + "metadata": {}, + "outputs": [], + "source": [ + "from pystac_client import Client\n", + "import planetary_computer\n", + "\n", + "catalog = Client.open(\n", + " \"https://planetarycomputer.microsoft.com/api/stac/v1\",\n", + " modifier=planetary_computer.sign_inplace,\n", + ")" + ] + }, + { + "cell_type": "markdown", + "id": "b5a6a858", + "metadata": {}, + "source": [ + "Define collection and assets to retrieve and construct [STAC API filters](https://github.com/stac-api-extensions/filter) for efficient query performance against Planetary Computer API" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "2132d393", + "metadata": {}, + "outputs": [], + "source": [ + "collections = [\"met-office-global-deterministic-height\"]\n", + "asset_id = \"cloud_amount_on_height_levels\"\n", + "datacube_extension_filters = {\n", + " \"op\": \"and\",\n", + " \"args\": [\n", + " {\n", + " \"op\": \"=\",\n", + " \"args\": [ { \"property\": \"forecast:reference_datetime\" }, \"2026-01-14T12:00:00Z\" ]\n", + " },\n", + " {\n", + " \"op\": \"=\",\n", + " \"args\": [ { \"property\": \"forecast:horizon\" }, \"PT0144H00M\" ]\n", + " }\n", + " ]\n", + "}" + ] + }, + { + "cell_type": "markdown", + "id": "dec7c74b", + "metadata": {}, + "source": [ + "Search Planetary Computer catalog for STAC items and retrieve STAC Asset URL" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "edb71afa", + "metadata": {}, + "outputs": [], + "source": [ + "search = catalog.search(\n", + " collections=collections,\n", + " filter_lang= \"cql2-json\",\n", + " filter=datacube_extension_filters\n", + ")\n", + "\n", + "items = search.item_collection()\n", + "asset_url = items.items[0].assets[asset_id].href" + ] + }, + { + "cell_type": "markdown", + "id": "ee73ba3d", + "metadata": {}, + "source": [ + "Example usage: Plot NetCDF data" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "fbc72d2a", + "metadata": {}, + "outputs": [], + "source": [ + "import fsspec\n", + "import xarray as xr\n", + "import matplotlib.pyplot as plt\n", + "\n", + "example_netcdf = xr.open_dataset(fsspec.open(asset_url, expand=True).open())\n", + "plt.figure(figsize=(10, 5))\n", + "example_netcdf[\"cloud_volume_fraction_in_atmosphere_layer\"].plot()" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": ".venv", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.13.11" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/datasets/met-office/met-office-global-deterministic-near-surface.ipynb b/datasets/met-office/met-office-global-deterministic-near-surface.ipynb new file mode 100644 index 0000000..b188188 --- /dev/null +++ b/datasets/met-office/met-office-global-deterministic-near-surface.ipynb @@ -0,0 +1,138 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "fbf471b1", + "metadata": {}, + "source": [ + "# Accessing Global Surface data from Microsoft Planetary Computer" + ] + }, + { + "cell_type": "markdown", + "id": "941120d0", + "metadata": {}, + "source": [ + "Set-up the pystac client to access the Microsoft Planetary Computer catalog" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "4bafd899", + "metadata": {}, + "outputs": [], + "source": [ + "from pystac_client import Client\n", + "import planetary_computer\n", + "\n", + "catalog = Client.open(\n", + " \"https://planetarycomputer.microsoft.com/api/stac/v1\",\n", + " modifier=planetary_computer.sign_inplace,\n", + ")" + ] + }, + { + "cell_type": "markdown", + "id": "b5a6a858", + "metadata": {}, + "source": [ + "Define collection and assets to retrieve and construct [STAC API filters](https://github.com/stac-api-extensions/filter) for efficient query performance against Planetary Computer API" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "2132d393", + "metadata": {}, + "outputs": [], + "source": [ + "collections = [\"met-office-global-deterministic-near-surface\"]\n", + "asset_id = \"temperature_at_surface\"\n", + "datacube_extension_filters = {\n", + " \"op\": \"and\",\n", + " \"args\": [\n", + " {\n", + " \"op\": \"=\",\n", + " \"args\": [ { \"property\": \"forecast:reference_datetime\" }, \"2025-12-05T12:00:00Z\" ]\n", + " },\n", + " {\n", + " \"op\": \"=\",\n", + " \"args\": [ { \"property\": \"forecast:horizon\" }, \"PT0120H00M\" ]\n", + " }\n", + " ]\n", + "}" + ] + }, + { + "cell_type": "markdown", + "id": "dec7c74b", + "metadata": {}, + "source": [ + "Search Planetary Computer catalog for STAC items and retrieve STAC Asset URL" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "edb71afa", + "metadata": {}, + "outputs": [], + "source": [ + "search = catalog.search(\n", + " collections=collections,\n", + " filter_lang= \"cql2-json\",\n", + " filter=datacube_extension_filters\n", + ")\n", + "\n", + "items = search.item_collection()\n", + "asset_url = items.items[0].assets[asset_id].href" + ] + }, + { + "cell_type": "markdown", + "id": "ee73ba3d", + "metadata": {}, + "source": [ + "Example usage: Plot NetCDF data on a map" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "fbc72d2a", + "metadata": {}, + "outputs": [], + "source": [ + "import fsspec\n", + "import xarray as xr\n", + "import matplotlib.pyplot as plt\n", + "\n", + "example_netcdf = xr.open_dataset(fsspec.open(asset_url, expand=True).open())\n", + "plt.figure(figsize=(10, 5))\n", + "example_netcdf[\"surface_temperature\"].plot()" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": ".venv", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.13.11" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/datasets/met-office/met-office-global-deterministic-pressure.ipynb b/datasets/met-office/met-office-global-deterministic-pressure.ipynb new file mode 100644 index 0000000..1b2abfe --- /dev/null +++ b/datasets/met-office/met-office-global-deterministic-pressure.ipynb @@ -0,0 +1,138 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "fbf471b1", + "metadata": {}, + "source": [ + "# Accessing Global Pressure data from Microsoft Planetary Computer" + ] + }, + { + "cell_type": "markdown", + "id": "941120d0", + "metadata": {}, + "source": [ + "Set-up the pystac client to access the Microsoft Planetary Computer catalog" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "4bafd899", + "metadata": {}, + "outputs": [], + "source": [ + "from pystac_client import Client\n", + "import planetary_computer\n", + "\n", + "catalog = Client.open(\n", + " \"https://planetarycomputer.microsoft.com/api/stac/v1\",\n", + " modifier=planetary_computer.sign_inplace,\n", + ")" + ] + }, + { + "cell_type": "markdown", + "id": "b5a6a858", + "metadata": {}, + "source": [ + "Define collection and assets to retrieve and construct [STAC API filters](https://github.com/stac-api-extensions/filter) for efficient query performance against Planetary Computer API" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "2132d393", + "metadata": {}, + "outputs": [], + "source": [ + "collections = [\"met-office-global-deterministic-pressure\"]\n", + "asset_id = \"wind_speed_on_pressure_levels\"\n", + "datacube_extension_filters = {\n", + " \"op\": \"and\",\n", + " \"args\": [\n", + " {\n", + " \"op\": \"=\",\n", + " \"args\": [ { \"property\": \"forecast:reference_datetime\" }, \"2025-12-05T12:00:00Z\" ]\n", + " },\n", + " {\n", + " \"op\": \"=\",\n", + " \"args\": [ { \"property\": \"forecast:horizon\" }, \"PT0135H00M\" ]\n", + " }\n", + " ]\n", + "}" + ] + }, + { + "cell_type": "markdown", + "id": "dec7c74b", + "metadata": {}, + "source": [ + "Search Planetary Computer catalog for STAC items and retrieve STAC Asset URL" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "edb71afa", + "metadata": {}, + "outputs": [], + "source": [ + "search = catalog.search(\n", + " collections=collections,\n", + " filter_lang= \"cql2-json\",\n", + " filter=datacube_extension_filters\n", + ")\n", + "\n", + "items = search.item_collection()\n", + "asset_url = items.items[0].assets[asset_id].href" + ] + }, + { + "cell_type": "markdown", + "id": "ee73ba3d", + "metadata": {}, + "source": [ + "Example usage: Plot NetCDF data" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "fbc72d2a", + "metadata": {}, + "outputs": [], + "source": [ + "import fsspec\n", + "import xarray as xr\n", + "import matplotlib.pyplot as plt\n", + "\n", + "example_netcdf = xr.open_dataset(fsspec.open(asset_url, expand=True).open())\n", + "plt.figure(figsize=(10, 5))\n", + "example_netcdf[\"cloud_volume_fraction_in_atmosphere_layer\"].plot()" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": ".venv", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.13.11" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/datasets/met-office/met-office-global-deterministic-whole-atmosphere.ipynb b/datasets/met-office/met-office-global-deterministic-whole-atmosphere.ipynb new file mode 100644 index 0000000..812ea10 --- /dev/null +++ b/datasets/met-office/met-office-global-deterministic-whole-atmosphere.ipynb @@ -0,0 +1,139 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "fbf471b1", + "metadata": {}, + "source": [ + "# Accessing Global Whole Atmosphere data from Microsoft Planetary Computer" + ] + }, + { + "cell_type": "markdown", + "id": "941120d0", + "metadata": {}, + "source": [ + "Set-up the pystac client to access the Microsoft Planetary Computer catalog" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "4bafd899", + "metadata": {}, + "outputs": [], + "source": [ + "from pystac_client import Client\n", + "import planetary_computer\n", + "\n", + "catalog = Client.open(\n", + " \"https://planetarycomputer.microsoft.com/api/stac/v1\",\n", + " modifier=planetary_computer.sign_inplace,\n", + ")" + ] + }, + { + "cell_type": "markdown", + "id": "b5a6a858", + "metadata": {}, + "source": [ + "Define collection and assets to retrieve and construct [STAC API filters](https://github.com/stac-api-extensions/filter) for efficient query performance against Planetary Computer API" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "2132d393", + "metadata": {}, + "outputs": [], + "source": [ + "collections = [\"met-office-global-deterministic-whole-atmosphere\"]\n", + "asset_id = \"CAPE_most_unstable_below_500hPa\"\n", + "datacube_extension_filters = {\n", + " \"op\": \"and\",\n", + " \"args\": [\n", + " {\n", + " \"op\": \"=\",\n", + " \"args\": [ { \"property\": \"forecast:reference_datetime\" }, \"2025-12-05T12:00:00Z\" ]\n", + " },\n", + " {\n", + " \"op\": \"=\",\n", + " \"args\": [ { \"property\": \"forecast:horizon\" }, \"PT0081H00M\" ]\n", + " }\n", + " ]\n", + "}" + ] + }, + { + "cell_type": "markdown", + "id": "dec7c74b", + "metadata": {}, + "source": [ + "Search Planetary Computer catalog for STAC items and retrieve STAC Asset URL" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "edb71afa", + "metadata": {}, + "outputs": [], + "source": [ + "search = catalog.search(\n", + " collections=collections,\n", + " filter_lang= \"cql2-json\",\n", + " filter=datacube_extension_filters\n", + ")\n", + "\n", + "items = search.item_collection()\n", + "asset_url = items.items[0].assets[asset_id].href" + ] + }, + { + "cell_type": "markdown", + "id": "ee73ba3d", + "metadata": {}, + "source": [ + "Example usage: Plot NetCDF data" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "fbc72d2a", + "metadata": {}, + "outputs": [], + "source": [ + "import fsspec\n", + "import xarray as xr\n", + "import matplotlib.pyplot as plt\n", + "\n", + "example_netcdf = xr.open_dataset(fsspec.open(asset_url, expand=True).open())\n", + "\n", + "plt.figure(figsize=(10, 5))\n", + "example_netcdf[\"atmosphere_convective_available_potential_energy\"].plot()" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": ".venv", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.13.11" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/datasets/met-office/met-office-uk-deterministic-height.ipynb b/datasets/met-office/met-office-uk-deterministic-height.ipynb new file mode 100644 index 0000000..f248922 --- /dev/null +++ b/datasets/met-office/met-office-uk-deterministic-height.ipynb @@ -0,0 +1,138 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "fbf471b1", + "metadata": {}, + "source": [ + "# Accessing UK Model Height data from Microsoft Planetary Computer" + ] + }, + { + "cell_type": "markdown", + "id": "941120d0", + "metadata": {}, + "source": [ + "Set-up the pystac client to access the Microsoft Planetary Computer catalog" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "4bafd899", + "metadata": {}, + "outputs": [], + "source": [ + "from pystac_client import Client\n", + "import planetary_computer\n", + "\n", + "catalog = Client.open(\n", + " \"https://planetarycomputer.microsoft.com/api/stac/v1\",\n", + " modifier=planetary_computer.sign_inplace,\n", + ")" + ] + }, + { + "cell_type": "markdown", + "id": "2cab8be1", + "metadata": {}, + "source": [ + "Define collection and assets to retrieve and construct [STAC API filters](https://github.com/stac-api-extensions/filter) for efficient query performance against Planetary Computer API" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "8f95ecac", + "metadata": {}, + "outputs": [], + "source": [ + "collections = [\"met-office-uk-deterministic-height\"]\n", + "asset_id = \"wind_speed_on_height_levels\"\n", + "datacube_extension_filters = {\n", + " \"op\": \"and\",\n", + " \"args\": [\n", + " {\n", + " \"op\": \"=\",\n", + " \"args\": [ { \"property\": \"forecast:reference_datetime\" }, \"2025-12-05T18:00:00Z\" ]\n", + " },\n", + " {\n", + " \"op\": \"=\",\n", + " \"args\": [ { \"property\": \"forecast:horizon\" }, \"PT0032H00M\" ]\n", + " }\n", + " ]\n", + "}" + ] + }, + { + "cell_type": "markdown", + "id": "b5a6a858", + "metadata": {}, + "source": [ + "Search Planetary Computer catalog for STAC items and retrieve STAC Asset URL" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "edb71afa", + "metadata": {}, + "outputs": [], + "source": [ + "search = catalog.search(\n", + " collections=collections,\n", + " filter_lang= \"cql2-json\",\n", + " filter=datacube_extension_filters\n", + ")\n", + "\n", + "items = search.item_collection()\n", + "asset_url = items.items[0].assets[asset_id].href" + ] + }, + { + "cell_type": "markdown", + "id": "56d27e19", + "metadata": {}, + "source": [ + "Example usage: Plot NetCDF data on a map" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "45613dda", + "metadata": {}, + "outputs": [], + "source": [ + "import fsspec\n", + "import xarray as xr\n", + "import matplotlib.pyplot as plt\n", + "\n", + "example_netcdf = xr.open_dataset(fsspec.open(asset_url, expand=True).open())\n", + "plt.figure(figsize=(10, 5))\n", + "example_netcdf[\"wind_speed\"].plot()" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": ".venv", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.13.11" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/datasets/met-office/met-office-uk-deterministic-near-surface.ipynb b/datasets/met-office/met-office-uk-deterministic-near-surface.ipynb new file mode 100644 index 0000000..84fbcaa --- /dev/null +++ b/datasets/met-office/met-office-uk-deterministic-near-surface.ipynb @@ -0,0 +1,138 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "fbf471b1", + "metadata": {}, + "source": [ + "# Accessing UK Model Surface data from Microsoft Planetary Computer" + ] + }, + { + "cell_type": "markdown", + "id": "941120d0", + "metadata": {}, + "source": [ + "Set-up the pystac client to access the Microsoft Planetary Computer catalog" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "4bafd899", + "metadata": {}, + "outputs": [], + "source": [ + "from pystac_client import Client\n", + "import planetary_computer\n", + "\n", + "catalog = Client.open(\n", + " \"https://planetarycomputer.microsoft.com/api/stac/v1\",\n", + " modifier=planetary_computer.sign_inplace,\n", + ")" + ] + }, + { + "cell_type": "markdown", + "id": "2cab8be1", + "metadata": {}, + "source": [ + "Define collection and assets to retrieve and construct [STAC API filters](https://github.com/stac-api-extensions/filter) for efficient query performance against Planetary Computer API" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "8f95ecac", + "metadata": {}, + "outputs": [], + "source": [ + "collections = [\"met-office-uk-deterministic-near-surface\"]\n", + "asset_id = \"temperature_at_surface\"\n", + "datacube_extension_filters = {\n", + " \"op\": \"and\",\n", + " \"args\": [\n", + " {\n", + " \"op\": \"=\",\n", + " \"args\": [ { \"property\": \"forecast:reference_datetime\" }, \"2025-12-05T18:00:00Z\" ]\n", + " },\n", + " {\n", + " \"op\": \"=\",\n", + " \"args\": [ { \"property\": \"forecast:horizon\" }, \"PT0001H00M\" ]\n", + " }\n", + " ]\n", + "}" + ] + }, + { + "cell_type": "markdown", + "id": "b5a6a858", + "metadata": {}, + "source": [ + "Search Planetary Computer catalog for STAC items and retrieve STAC Asset URL" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "edb71afa", + "metadata": {}, + "outputs": [], + "source": [ + "search = catalog.search(\n", + " collections=collections,\n", + " filter_lang= \"cql2-json\",\n", + " filter=datacube_extension_filters\n", + ")\n", + "\n", + "items = search.item_collection()\n", + "asset_url = items.items[0].assets[asset_id].href" + ] + }, + { + "cell_type": "markdown", + "id": "56d27e19", + "metadata": {}, + "source": [ + "Example usage: Plot NetCDF data on a map" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "45613dda", + "metadata": {}, + "outputs": [], + "source": [ + "import fsspec\n", + "import xarray as xr\n", + "import matplotlib.pyplot as plt\n", + "\n", + "example_netcdf = xr.open_dataset(fsspec.open(asset_url, expand=True).open())\n", + "plt.figure(figsize=(10, 5))\n", + "example_netcdf[\"surface_temperature\"].plot()" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": ".venv", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.13.11" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/datasets/met-office/met-office-uk-deterministic-pressure.ipynb b/datasets/met-office/met-office-uk-deterministic-pressure.ipynb new file mode 100644 index 0000000..17d5ee7 --- /dev/null +++ b/datasets/met-office/met-office-uk-deterministic-pressure.ipynb @@ -0,0 +1,138 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "fbf471b1", + "metadata": {}, + "source": [ + "# Accessing UK Model Pressure Level data from Microsoft Planetary Computer" + ] + }, + { + "cell_type": "markdown", + "id": "941120d0", + "metadata": {}, + "source": [ + "Set-up the pystac client to access the Microsoft Planetary Computer catalog" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "4bafd899", + "metadata": {}, + "outputs": [], + "source": [ + "from pystac_client import Client\n", + "import planetary_computer\n", + "\n", + "catalog = Client.open(\n", + " \"https://planetarycomputer.microsoft.com/api/stac/v1\",\n", + " modifier=planetary_computer.sign_inplace,\n", + ")" + ] + }, + { + "cell_type": "markdown", + "id": "2cab8be1", + "metadata": {}, + "source": [ + "Define collection and assets to retrieve and construct [STAC API filters](https://github.com/stac-api-extensions/filter) for efficient query performance against Planetary Computer API" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "8f95ecac", + "metadata": {}, + "outputs": [], + "source": [ + "collections = [\"met-office-uk-deterministic-pressure\"]\n", + "asset_id = \"wet_bulb_potential_temperature_on_pressure_levels\"\n", + "datacube_extension_filters = {\n", + " \"op\": \"and\",\n", + " \"args\": [\n", + " {\n", + " \"op\": \"=\",\n", + " \"args\": [ { \"property\": \"forecast:reference_datetime\" }, \"2026-01-14T12:00:00Z\" ]\n", + " },\n", + " {\n", + " \"op\": \"=\",\n", + " \"args\": [ { \"property\": \"forecast:horizon\" }, \"PT0052H00M\" ]\n", + " }\n", + " ]\n", + "}" + ] + }, + { + "cell_type": "markdown", + "id": "b5a6a858", + "metadata": {}, + "source": [ + "Search Planetary Computer catalog for STAC items and retrieve STAC Asset URL" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "edb71afa", + "metadata": {}, + "outputs": [], + "source": [ + "search = catalog.search(\n", + " collections=collections,\n", + " filter_lang= \"cql2-json\",\n", + " filter=datacube_extension_filters\n", + ")\n", + "\n", + "items = search.item_collection()\n", + "asset_url = items.items[0].assets[asset_id].href" + ] + }, + { + "cell_type": "markdown", + "id": "56d27e19", + "metadata": {}, + "source": [ + "Example usage: Plot NetCDF data on a map" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "45613dda", + "metadata": {}, + "outputs": [], + "source": [ + "import fsspec\n", + "import xarray as xr\n", + "import matplotlib.pyplot as plt\n", + "\n", + "example_netcdf = xr.open_dataset(fsspec.open(asset_url, expand=True).open())\n", + "plt.figure(figsize=(10, 5))\n", + "example_netcdf[\"wet_bulb_potential_temperature\"].plot()" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": ".venv", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.13.11" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/datasets/met-office/met-office-uk-deterministic-whole-atmosphere.ipynb b/datasets/met-office/met-office-uk-deterministic-whole-atmosphere.ipynb new file mode 100644 index 0000000..f8bde1f --- /dev/null +++ b/datasets/met-office/met-office-uk-deterministic-whole-atmosphere.ipynb @@ -0,0 +1,139 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "fbf471b1", + "metadata": {}, + "source": [ + "# Accessing UK Model Whole Atmosphere data from Microsoft Planetary Computer" + ] + }, + { + "cell_type": "markdown", + "id": "941120d0", + "metadata": {}, + "source": [ + "Set-up the pystac client to access the Microsoft Planetary Computer catalog" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "4bafd899", + "metadata": {}, + "outputs": [], + "source": [ + "from pystac_client import Client\n", + "import planetary_computer\n", + "\n", + "catalog = Client.open(\n", + " \"https://planetarycomputer.microsoft.com/api/stac/v1\",\n", + " modifier=planetary_computer.sign_inplace,\n", + ")" + ] + }, + { + "cell_type": "markdown", + "id": "2cab8be1", + "metadata": {}, + "source": [ + "Define collection and assets to retrieve and construct [STAC API filters](https://github.com/stac-api-extensions/filter) for efficient query performance against Planetary Computer API" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "8f95ecac", + "metadata": {}, + "outputs": [], + "source": [ + "collections = [\"met-office-uk-deterministic-whole-atmosphere\"]\n", + "asset_id = \"lightning_flash_accumulation-PT01H\"\n", + "datacube_extension_filters = {\n", + " \"op\": \"and\",\n", + " \"args\": [\n", + " {\n", + " \"op\": \"=\",\n", + " \"args\": [ { \"property\": \"forecast:reference_datetime\" }, \"2025-12-05T18:00:00Z\" ]\n", + " },\n", + " {\n", + " \"op\": \"=\",\n", + " \"args\": [ { \"property\": \"forecast:horizon\" }, \"PT0037H00M\" ]\n", + " }\n", + " ]\n", + "}" + ] + }, + { + "cell_type": "markdown", + "id": "b5a6a858", + "metadata": {}, + "source": [ + "Search Planetary Computer catalog for STAC items and retrieve STAC Asset URL" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "edb71afa", + "metadata": {}, + "outputs": [], + "source": [ + "search = catalog.search(\n", + " collections=collections,\n", + " filter_lang= \"cql2-json\",\n", + " filter=datacube_extension_filters\n", + ")\n", + "\n", + "items = search.item_collection()\n", + "asset_url = items.items[0].assets[asset_id].href" + ] + }, + { + "cell_type": "markdown", + "id": "56d27e19", + "metadata": {}, + "source": [ + "Example usage: Plot NetCDF data on a map" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "45613dda", + "metadata": {}, + "outputs": [], + "source": [ + "import fsspec\n", + "import xarray as xr\n", + "import matplotlib.pyplot as plt\n", + "\n", + "example_netcdf = xr.open_dataset(fsspec.open(asset_url, expand=True).open())\n", + "\n", + "plt.figure(figsize=(10, 5))\n", + "example_netcdf[\"number_of_lightning_flashes_per_unit_area\"].plot()" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": ".venv", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.13.11" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +}