From e787c36be8e1675d3cea9953800517adfee3295f Mon Sep 17 00:00:00 2001 From: Tina Odaka <46813815+tinaok@users.noreply.github.com> Date: Tue, 8 Oct 2024 16:08:30 +0200 Subject: [PATCH 01/17] Create readme.md --- visualisation/readme.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 visualisation/readme.md diff --git a/visualisation/readme.md b/visualisation/readme.md new file mode 100644 index 0000000..8d1c8b6 --- /dev/null +++ b/visualisation/readme.md @@ -0,0 +1 @@ + From e35b22353f9dc8beb6978376a584341a185a0f19 Mon Sep 17 00:00:00 2001 From: Tina Odaka <46813815+tinaok@users.noreply.github.com> Date: Tue, 8 Oct 2024 16:16:59 +0200 Subject: [PATCH 02/17] Add files via upload --- visualisation/xdggs-explore-demo.ipynb | 5932 ++++++++++++++++++++++++ 1 file changed, 5932 insertions(+) create mode 100644 visualisation/xdggs-explore-demo.ipynb diff --git a/visualisation/xdggs-explore-demo.ipynb b/visualisation/xdggs-explore-demo.ipynb new file mode 100644 index 0000000..682bd2d --- /dev/null +++ b/visualisation/xdggs-explore-demo.ipynb @@ -0,0 +1,5932 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "822fe868-4eca-4f7a-bf02-8badcb88ddb7", + "metadata": {}, + "source": [ + "# plotting healpix data with xdggs and lonboard" + ] + }, + { + "cell_type": "markdown", + "id": "d340a5ff-db29-4c13-8d7f-f02870e6ad17", + "metadata": {}, + "source": [ + "For this to work, we need:\n", + "- `xarray`\n", + "- `numpy`\n", + "- `xdggs`\n", + "- `lonboard`\n", + "- `arro3-core`\n", + "- `matplotlib`\n", + "\n", + "All of these can be installed using the `explore` extra:" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "id": "81daf142-11e0-486b-ac52-9234abf44ce2", + "metadata": { + "collapsed": true, + "jupyter": { + "outputs_hidden": true + } + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Collecting xdggs@ git+https://github.com/keewis/xdggs.git#branch=lonboard (from xdggs[explore]@ git+https://github.com/keewis/xdggs.git#branch=lonboard)\n", + " Cloning https://github.com/keewis/xdggs.git to /tmp/pip-install-ly7q_fzp/xdggs_298a07348ea54afd8df1bd6107f14d8e\n", + " Running command git clone --filter=blob:none --quiet https://github.com/keewis/xdggs.git /tmp/pip-install-ly7q_fzp/xdggs_298a07348ea54afd8df1bd6107f14d8e\n", + " Resolved https://github.com/keewis/xdggs.git to commit 775c76be55c661cc8ceb5914fedefda0db5edb89\n", + " Installing build dependencies ... \u001b[?25ldone\n", + "\u001b[?25h Getting requirements to build wheel ... \u001b[?25ldone\n", + "\u001b[?25h Preparing metadata (pyproject.toml) ... \u001b[?25ldone\n", + "\u001b[?25hRequirement already satisfied: xarray in /srv/conda/envs/notebook/lib/python3.12/site-packages (from xdggs@ git+https://github.com/keewis/xdggs.git#branch=lonboard->xdggs[explore]@ git+https://github.com/keewis/xdggs.git#branch=lonboard) (2024.7.0)\n", + "Collecting healpy (from xdggs@ git+https://github.com/keewis/xdggs.git#branch=lonboard->xdggs[explore]@ git+https://github.com/keewis/xdggs.git#branch=lonboard)\n", + " Downloading healpy-1.17.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (8.9 kB)\n", + "Collecting h3ronpy (from xdggs@ git+https://github.com/keewis/xdggs.git#branch=lonboard->xdggs[explore]@ git+https://github.com/keewis/xdggs.git#branch=lonboard)\n", + " Downloading h3ronpy-0.21.1-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (5.0 kB)\n", + "Requirement already satisfied: typing-extensions in /srv/conda/envs/notebook/lib/python3.12/site-packages (from xdggs@ git+https://github.com/keewis/xdggs.git#branch=lonboard->xdggs[explore]@ git+https://github.com/keewis/xdggs.git#branch=lonboard) (4.12.2)\n", + "\u001b[33mWARNING: xdggs 0.1.dev53+g775c76b does not provide the extra 'explore'\u001b[0m\u001b[33m\n", + "\u001b[0mRequirement already satisfied: numpy<2 in /srv/conda/envs/notebook/lib/python3.12/site-packages (from h3ronpy->xdggs@ git+https://github.com/keewis/xdggs.git#branch=lonboard->xdggs[explore]@ git+https://github.com/keewis/xdggs.git#branch=lonboard) (1.26.4)\n", + "Requirement already satisfied: pyarrow>=10.0 in /srv/conda/envs/notebook/lib/python3.12/site-packages (from h3ronpy->xdggs@ git+https://github.com/keewis/xdggs.git#branch=lonboard->xdggs[explore]@ git+https://github.com/keewis/xdggs.git#branch=lonboard) (17.0.0)\n", + "Requirement already satisfied: Shapely>=1.7 in /srv/conda/envs/notebook/lib/python3.12/site-packages (from h3ronpy->xdggs@ git+https://github.com/keewis/xdggs.git#branch=lonboard->xdggs[explore]@ git+https://github.com/keewis/xdggs.git#branch=lonboard) (2.0.5)\n", + "Requirement already satisfied: astropy in /srv/conda/envs/notebook/lib/python3.12/site-packages (from healpy->xdggs@ git+https://github.com/keewis/xdggs.git#branch=lonboard->xdggs[explore]@ git+https://github.com/keewis/xdggs.git#branch=lonboard) (6.1.2)\n", + "Requirement already satisfied: packaging>=23.1 in /srv/conda/envs/notebook/lib/python3.12/site-packages (from xarray->xdggs@ git+https://github.com/keewis/xdggs.git#branch=lonboard->xdggs[explore]@ git+https://github.com/keewis/xdggs.git#branch=lonboard) (24.1)\n", + "Requirement already satisfied: pandas>=2.0 in /srv/conda/envs/notebook/lib/python3.12/site-packages (from xarray->xdggs@ git+https://github.com/keewis/xdggs.git#branch=lonboard->xdggs[explore]@ git+https://github.com/keewis/xdggs.git#branch=lonboard) (2.2.2)\n", + "Requirement already satisfied: python-dateutil>=2.8.2 in /srv/conda/envs/notebook/lib/python3.12/site-packages (from pandas>=2.0->xarray->xdggs@ git+https://github.com/keewis/xdggs.git#branch=lonboard->xdggs[explore]@ git+https://github.com/keewis/xdggs.git#branch=lonboard) (2.8.2)\n", + "Requirement already satisfied: pytz>=2020.1 in /srv/conda/envs/notebook/lib/python3.12/site-packages (from pandas>=2.0->xarray->xdggs@ git+https://github.com/keewis/xdggs.git#branch=lonboard->xdggs[explore]@ git+https://github.com/keewis/xdggs.git#branch=lonboard) (2024.1)\n", + "Requirement already satisfied: tzdata>=2022.7 in /srv/conda/envs/notebook/lib/python3.12/site-packages (from pandas>=2.0->xarray->xdggs@ git+https://github.com/keewis/xdggs.git#branch=lonboard->xdggs[explore]@ git+https://github.com/keewis/xdggs.git#branch=lonboard) (2024.1)\n", + "Requirement already satisfied: pyerfa>=2.0.1.1 in /srv/conda/envs/notebook/lib/python3.12/site-packages (from astropy->healpy->xdggs@ git+https://github.com/keewis/xdggs.git#branch=lonboard->xdggs[explore]@ git+https://github.com/keewis/xdggs.git#branch=lonboard) (2.0.1.4)\n", + "Requirement already satisfied: astropy-iers-data>=0.2024.7.1.0.34.3 in /srv/conda/envs/notebook/lib/python3.12/site-packages (from astropy->healpy->xdggs@ git+https://github.com/keewis/xdggs.git#branch=lonboard->xdggs[explore]@ git+https://github.com/keewis/xdggs.git#branch=lonboard) (0.2024.8.5.0.32.23)\n", + "Requirement already satisfied: PyYAML>=3.13 in /srv/conda/envs/notebook/lib/python3.12/site-packages (from astropy->healpy->xdggs@ git+https://github.com/keewis/xdggs.git#branch=lonboard->xdggs[explore]@ git+https://github.com/keewis/xdggs.git#branch=lonboard) (6.0.2)\n", + "Requirement already satisfied: six>=1.5 in /srv/conda/envs/notebook/lib/python3.12/site-packages (from python-dateutil>=2.8.2->pandas>=2.0->xarray->xdggs@ git+https://github.com/keewis/xdggs.git#branch=lonboard->xdggs[explore]@ git+https://github.com/keewis/xdggs.git#branch=lonboard) (1.16.0)\n", + "Downloading h3ronpy-0.21.1-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.0 MB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m2.0/2.0 MB\u001b[0m \u001b[31m40.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hDownloading healpy-1.17.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (8.5 MB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m8.5/8.5 MB\u001b[0m \u001b[31m53.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hBuilding wheels for collected packages: xdggs\n", + " Building wheel for xdggs (pyproject.toml) ... \u001b[?25ldone\n", + "\u001b[?25h Created wheel for xdggs: filename=xdggs-0.1.dev53+g775c76b-py3-none-any.whl size=23214 sha256=21f98f3d1d2336b67f7713b979d5c33f63b274568277dc2298ebcace3c570431\n", + " Stored in directory: /tmp/pip-ephem-wheel-cache-pulnu04g/wheels/11/dd/6e/9fa09ae5bad1a9382b041ca100a1fcec2819ecccbd89598f51\n", + "Successfully built xdggs\n", + "Installing collected packages: h3ronpy, healpy, xdggs\n", + "Successfully installed h3ronpy-0.21.1 healpy-1.17.3 xdggs-0.1.dev53+g775c76b\n" + ] + } + ], + "source": [ + "#!pip install \"xdggs[explore] @ git+https://github.com/keewis/xdggs.git#branch=lonboard\"\n", + "\n", + "!pip install \"xdggs[explore] @ git+https://github.com/keewis/xdggs.git@lonboard\"" + ] + }, + { + "cell_type": "markdown", + "id": "4252ed44-5767-4f7f-a5f2-4724c96be7e4", + "metadata": {}, + "source": [ + "imports" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "id": "36cf9310-b950-4ff2-96ac-8b654b411947", + "metadata": {}, + "outputs": [], + "source": [ + "import numpy as np\n", + "import xarray as xr\n", + "\n", + "import xdggs" + ] + }, + { + "cell_type": "markdown", + "id": "68c364ab-3db3-42c9-9872-83b83b599ae5", + "metadata": {}, + "source": [ + "generate the test dataset" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "e9066875-192b-4993-90eb-b309a7512d37", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
<xarray.Dataset> Size: 25MB\n", + "Dimensions: (cells: 786432)\n", + "Coordinates:\n", + " * cell_ids (cells) int64 6MB 0 1 2 3 4 ... 786428 786429 786430 786431\n", + " latitude (cells) float64 6MB 0.1492 0.2984 0.2984 ... -0.2984 -0.1492\n", + " longitude (cells) float64 6MB 45.0 45.18 44.82 45.0 ... 315.2 314.8 315.0\n", + "Dimensions without coordinates: cells\n", + "Data variables:\n", + " data (cells) float64 6MB -0.9999 -0.9993 -0.9993 ... 0.9993 0.9999\n", + "Indexes:\n", + " cell_ids HealpixIndex(nside=8, indexing_scheme=nested, rotation=[0.0, 0.0])
<xarray.Dataset> Size: 383TB\n", + "Dimensions: (time: 262537, value: 3145728)\n", + "Coordinates:\n", + " lat (value) float64 25MB dask.array<chunksize=(3145728,), meta=np.ndarray>\n", + " lon (value) float64 25MB dask.array<chunksize=(3145728,), meta=np.ndarray>\n", + " * time (time) datetime64[ns] 2MB 2020-01-20 ... 2050-01-01\n", + "Dimensions without coordinates: value\n", + "Data variables: (12/58)\n", + " 10si (time, value) float64 7TB dask.array<chunksize=(3, 3145728), meta=np.ndarray>\n", + " 10u (time, value) float64 7TB dask.array<chunksize=(3, 3145728), meta=np.ndarray>\n", + " 10v (time, value) float64 7TB dask.array<chunksize=(3, 3145728), meta=np.ndarray>\n", + " 2d (time, value) float64 7TB dask.array<chunksize=(3, 3145728), meta=np.ndarray>\n", + " 2t (time, value) float64 7TB dask.array<chunksize=(3, 3145728), meta=np.ndarray>\n", + " blh (time, value) float64 7TB dask.array<chunksize=(3, 3145728), meta=np.ndarray>\n", + " ... ...\n", + " tp (time, value) float64 7TB dask.array<chunksize=(3, 3145728), meta=np.ndarray>\n", + " tprate (time, value) float64 7TB dask.array<chunksize=(3, 3145728), meta=np.ndarray>\n", + " tsr (time, value) float64 7TB dask.array<chunksize=(3, 3145728), meta=np.ndarray>\n", + " tsrc (time, value) float64 7TB dask.array<chunksize=(3, 3145728), meta=np.ndarray>\n", + " ttr (time, value) float64 7TB dask.array<chunksize=(3, 3145728), meta=np.ndarray>\n", + " ttrc (time, value) float64 7TB dask.array<chunksize=(3, 3145728), meta=np.ndarray>\n", + "Attributes: (12/13)\n", + " edition: 2\n", + " centre: ecmf\n", + " centreDescription: European Centre for Medium-Range Weather Forecasts\n", + " subCentre: 1003\n", + " history: 🪄🧙♂️🔮 magic dataset assembly provided by gribscan.IF...\n", + " title: nextgems.IFS_9-FESOM_5-production.2D_hourly_healpix512\n", + " ... ...\n", + " time_min: 2020-01-20T00:00:00.000000000\n", + " time_max: 2050-01-01T00:00:00.000000000\n", + " creation_date: 2024-10-08T06:15:02Z\n", + " authors: Wieners, Karl-Hermann (MPIMet), Aguridan, Razvan (ECM...\n", + " contact: Wieners, Karl-Hermann (MPIMet), Rackow, Thomas (ECMWF)\n", + " license: Creative Commons Attribution 4.0 International (CC BY..." + ], + "text/plain": [ + "
<xarray.DataArray 'msl' (value: 3145728)> Size: 25MB\n", + "array([100984.51660156, 100988.79394531, 100979.44824219, ...,\n", + " 101204.87207031, 101202.56152344, 101200.22753906])\n", + "Coordinates:\n", + " lat (value) float64 25MB 0.0746 0.1492 0.1492 ... -0.1492 -0.0746\n", + " lon (value) float64 25MB 45.0 45.09 44.91 45.0 ... 315.1 314.9 315.0\n", + " time datetime64[ns] 8B 2020-03-01T16:00:00\n", + " * cell_ids (value) int64 25MB 0 1 2 3 4 ... 3145724 3145725 3145726 3145727\n", + "Dimensions without coordinates: value\n", + "Indexes:\n", + " cell_ids HealpixIndex(nside=9, indexing_scheme=nested, rotation=[0.0, 0.0])\n", + "Attributes: (12/15)\n", + " paramId: 151\n", + " dataType: fc\n", + " numberOfPoints: 3145728\n", + " typeOfLevel: meanSea\n", + " stepUnits: 1\n", + " stepType: instant\n", + " ... ...\n", + " name: Mean sea level pressure\n", + " cfName: air_pressure_at_mean_sea_level\n", + " cfVarName: msl\n", + " missingValue: 9999\n", + " NV: 0\n", + " gridDefinitionDescription: 150
<xarray.Dataset> Size: 25MB\n", + "Dimensions: (cells: 786432)\n", + "Coordinates:\n", + " * cell_ids (cells) int64 6MB 0 1 2 3 4 ... 786428 786429 786430 786431\n", + " latitude (cells) float64 6MB 0.1492 0.2984 0.2984 ... -0.2984 -0.1492\n", + " longitude (cells) float64 6MB 45.0 45.18 44.82 45.0 ... 315.2 314.8 315.0\n", + "Dimensions without coordinates: cells\n", + "Data variables:\n", + " data (cells) float64 6MB -0.9999 -0.9993 -0.9993 ... 0.9993 0.9999\n", + "Indexes:\n", + " cell_ids HealpixIndex(nside=8, indexing_scheme=nested, rotation=[0.0, 0.0])
<xarray.Dataset> Size: 4GB\n", + "Dimensions: (oceanModelLayer: 75, cells: 12582912)\n", + "Coordinates:\n", + " cell_ids (cells) int64 101MB dask.array<chunksize=(100000,), meta=np.ndarray>\n", + " latitude (cells) float64 101MB dask.array<chunksize=(100000,), meta=np.ndarray>\n", + " longitude (cells) float64 101MB dask.array<chunksize=(100000,), meta=np.ndarray>\n", + " * oceanModelLayer (oceanModelLayer) float64 600B 1.0 2.0 3.0 ... 74.0 75.0\n", + " step timedelta64[ns] 8B ...\n", + " time datetime64[ns] 8B ...\n", + " valid_time datetime64[ns] 8B ...\n", + "Dimensions without coordinates: cells\n", + "Data variables:\n", + " avg_thetao (oceanModelLayer, cells) float32 4GB dask.array<chunksize=(10, 100000), meta=np.ndarray>\n", + "Attributes:\n", + " Conventions: CF-1.7\n", + " GRIB_centre: ecmf\n", + " GRIB_centreDescription: European Centre for Medium-Range Weather Forecasts\n", + " GRIB_edition: 2\n", + " GRIB_subCentre: 1003\n", + " history: 2024-06-03T13:52 GRIB to CDM+CF via cfgrib-0.9.1...\n", + " institution: European Centre for Medium-Range Weather Forecasts" + ], + "text/plain": [ + "
<xarray.DataArray 'avg_thetao' (cells: 12582912)> Size: 50MB\n", + "array([300.53537, 300.54025, 300.50998, ..., 301.4836 , 301.5012 ,\n", + " 301.49338], dtype=float32)\n", + "Coordinates:\n", + " * cell_ids (cells) int64 101MB 0 1 2 3 ... 12582909 12582910 12582911\n", + " latitude (cells) float64 101MB 0.0373 0.0746 ... -0.0746 -0.0373\n", + " longitude (cells) float64 101MB 45.0 45.04 44.96 ... 315.0 315.0\n", + " oceanModelLayer float64 8B 2.0\n", + " step timedelta64[ns] 8B 1 days\n", + " time datetime64[ns] 8B 2023-01-01\n", + " valid_time datetime64[ns] 8B 2023-01-02\n", + "Dimensions without coordinates: cells\n", + "Indexes:\n", + " cell_ids HealpixIndex(nside=10, indexing_scheme=nested, rotation=[0.0, 0.0])\n", + "Attributes: (12/18)\n", + " GRIB_NV: 0\n", + " GRIB_cfName: unknown\n", + " GRIB_cfVarName: avg_thetao\n", + " GRIB_dataType: fc\n", + " GRIB_gridDefinitionDescription: 150\n", + " GRIB_gridType: healpix\n", + " ... ...\n", + " GRIB_stepUnits: 1\n", + " GRIB_typeOfLevel: oceanModelLayer\n", + " GRIB_units: K\n", + " long_name: Time-mean sea water potential temperature\n", + " standard_name: unknown\n", + " units: K
<xarray.Dataset> Size: 25MB\n",
- "Dimensions: (cells: 786432)\n",
+ "<xarray.DataArray 'avg_thetao' (cells: 12582912)> Size: 50MB\n",
+ "array([27.385376, 27.390259, 27.359985, ..., 28.333618, 28.351196,\n",
+ " 28.343384], dtype=float32)\n",
"Coordinates:\n",
- " * cell_ids (cells) int64 6MB 0 1 2 3 4 ... 786428 786429 786430 786431\n",
- " latitude (cells) float64 6MB 0.1492 0.2984 0.2984 ... -0.2984 -0.1492\n",
- " longitude (cells) float64 6MB 45.0 45.18 44.82 45.0 ... 315.2 314.8 315.0\n",
+ " cell_ids (cells) int64 101MB 0 1 2 3 ... 12582909 12582910 12582911\n",
+ " latitude (cells) float64 101MB 0.0373 0.0746 ... -0.0746 -0.0373\n",
+ " longitude (cells) float64 101MB 45.0 45.04 44.96 ... 315.0 315.0\n",
+ " oceanModelLayer float64 8B 2.0\n",
+ " step timedelta64[ns] 8B 1 days\n",
+ " time datetime64[ns] 8B 2023-01-01\n",
+ " valid_time datetime64[ns] 8B 2023-01-02\n",
"Dimensions without coordinates: cells\n",
- "Data variables:\n",
- " data (cells) float64 6MB -0.9999 -0.9993 -0.9993 ... 0.9993 0.9999\n",
- "Indexes:\n",
- " cell_ids HealpixIndex(nside=8, indexing_scheme=nested, rotation=[0.0, 0.0])"
+ "Attributes: (12/18)\n",
+ " GRIB_NV: 0\n",
+ " GRIB_cfName: unknown\n",
+ " GRIB_cfVarName: avg_thetao\n",
+ " GRIB_dataType: fc\n",
+ " GRIB_gridDefinitionDescription: 150\n",
+ " GRIB_gridType: healpix\n",
+ " ... ...\n",
+ " GRIB_stepUnits: 1\n",
+ " GRIB_typeOfLevel: oceanModelLayer\n",
+ " GRIB_units: K\n",
+ " long_name: Time-mean sea water potential temperature\n",
+ " standard_name: unknown\n",
+ " units: degree_Celsius"
],
"text/plain": [
- "