Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
138 changes: 138 additions & 0 deletions datasets/met-office/met-office-global-deterministic-height.ipynb
Original file line number Diff line number Diff line change
@@ -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
}
138 changes: 138 additions & 0 deletions datasets/met-office/met-office-global-deterministic-near-surface.ipynb
Original file line number Diff line number Diff line change
@@ -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
}
Loading