diff --git a/.circleci/config.yml b/.circleci/config.yml index 59e3675..e357842 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -26,7 +26,8 @@ commands: name: Install the conda environment command: | which conda || source $HOME/miniconda3/bin/activate base - conda env create -f .circleci/environment.yml -n docs + conda install mamba -n base -c conda-forge + mamba env create -f .circleci/environment.yml -n docs - run: name: Build the docs command: | diff --git a/.circleci/environment.yml b/.circleci/environment.yml index 42bca46..3b31ac6 100644 --- a/.circleci/environment.yml +++ b/.circleci/environment.yml @@ -12,3 +12,11 @@ dependencies: - ipython - ipykernel - seaborn +- matplotlib<3.4 +- cartopy>=0.18 +- pyinterp +- scikit-learn +- ipympl +- pip +- pip: + - git+https://github.com/psyplot/psy-transect.git diff --git a/binder/environment.yml b/binder/environment.yml index d031cb8..b6f16ba 100644 --- a/binder/environment.yml +++ b/binder/environment.yml @@ -3,6 +3,7 @@ channels: - psyplot - manics # Used by jupyter-desktop-server - conda-forge +- nodefaults dependencies: - psy-view - psy-reg @@ -10,10 +11,15 @@ dependencies: - pip - ncview - seaborn -- matplotlib>=3.3 +- matplotlib<3.4 - cartopy>=0.18 +- pyinterp +- scikit-learn +- ipympl # Required for jupyter-desktop-server - websockify - pip: - jupyter-desktop-server + - sphinx_rtd_theme + - git+https://github.com/psyplot/psy-transect diff --git a/binder/start b/binder/start index 42a99c5..2200677 100644 --- a/binder/start +++ b/binder/start @@ -7,7 +7,7 @@ PACKAGES="" mkdir .psyplot-packages -for PKG in psyplot psy-simple psy-maps psy-reg psyplot-gui psy-view; do +for PKG in psyplot psy-simple psy-maps psy-reg psyplot-gui psy-view psy-transect; do git clone https://github.com/psyplot/${PKG}.git .psyplot-packages/${PKG} PACKAGES="${PACKAGES} .psyplot-packages/${PKG}/" diff --git a/transects/data/icon_clm_demo.nc b/transects/data/icon_clm_demo.nc new file mode 100644 index 0000000..965e3a4 Binary files /dev/null and b/transects/data/icon_clm_demo.nc differ diff --git a/transects/data/icon_clm_orography.nc b/transects/data/icon_clm_orography.nc new file mode 100644 index 0000000..2619c7a Binary files /dev/null and b/transects/data/icon_clm_orography.nc differ diff --git a/transects/example_icon_clm.ipynb b/transects/example_icon_clm.ipynb new file mode 100644 index 0000000..1d69a64 --- /dev/null +++ b/transects/example_icon_clm.ipynb @@ -0,0 +1,2085 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "fc81684b", + "metadata": {}, + "source": [ + "# Transect example for ICON CLM\n", + "\n", + "This example uses a regional ICON model output for transect visualization.\n", + "\n", + "We show you how to use the power of psyplot in visualizing unstructured grids to display vertically and horizontally unstructured data on its native grid for an interactive analysis.\n", + "\n", + "**Notes:** \n", + "\n", + "- psy-transect is still under development. So please be cautios and let us know at https://github.com/psyplot/psy-transect/issues if you encounter any issues.\n", + "- you should run this notebook interactively. You can either do this on mybinder.org using the following button, or install the examples yourself from the [psy-transect branch of the psyplot examples](https://github.com/psyplot/examples/tree/psy-transect).\n", + "- if you run this example on mybinder or locally, you can also use the psyplot GUI. On mybinder, click [here](/desktop) and open the `Psyplot` desktop application. Then execute the following commands from the console in the GUI:\n", + "\n", + " ```\n", + " cd ../transects\n", + " run example_icon_clm.ipynb\n", + " ```" + ] + }, + { + "cell_type": "markdown", + "id": "32466da6", + "metadata": {}, + "source": [ + "**If you are running this example in a jupyter notebook, you should uncomment the following line to make it interactive.**" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "id": "063be98d", + "metadata": {}, + "outputs": [], + "source": [ + "# uncomment the following line when running a jupyter notebook\n", + "# %matplotlib widget" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "2fd25aad", + "metadata": {}, + "outputs": [], + "source": [ + "import cartopy.crs as ccrs\n", + "import psyplot.project as psy\n", + "import matplotlib.pyplot as plt\n", + "import numpy as np\n", + "from psy_transect import utils" + ] + }, + { + "cell_type": "markdown", + "id": "0cf41ec6", + "metadata": {}, + "source": [ + "The first file contains a 4D-temperature for a region model on the ICON grid (triangular bounds for longitude and latitude). " + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "f31f8bdf", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
<xarray.DataArray 'temp' (time: 1, height_2: 60, ncells: 17108)>\n", + "[1026480 values with dtype=float32]\n", + "Coordinates:\n", + " * time (time) datetime64[ns] 1979-01-01\n", + " clon (ncells) float32 -0.6416 -0.6749 -0.6503 ... 0.6867 0.6921 0.7017\n", + " clat (ncells) float32 1.256 1.25 1.251 1.217 ... 0.4118 0.4222 0.4435\n", + " * height_2 (height_2) float64 1.0 2.0 3.0 4.0 5.0 ... 57.0 58.0 59.0 60.0\n", + "Dimensions without coordinates: ncells\n", + "Attributes:\n", + " standard_name: air_temperature\n", + " long_name: Temperature\n", + " units: K\n", + " param: 0.0.0\n", + " CDI_grid_type: unstructured\n", + " number_of_grid_in_reference: 1\n", + " institution: MPIMET
[1026480 values with dtype=float32]
array(['1979-01-01T00:00:00.000000000'], dtype='datetime64[ns]')
array([-0.641613, -0.674926, -0.650324, ..., 0.686725, 0.692111, 0.701713],\n", + " dtype=float32)
array([1.256085, 1.250423, 1.250658, ..., 0.411836, 0.422157, 0.443509],\n", + " dtype=float32)
array([ 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14.,\n", + " 15., 16., 17., 18., 19., 20., 21., 22., 23., 24., 25., 26., 27., 28.,\n", + " 29., 30., 31., 32., 33., 34., 35., 36., 37., 38., 39., 40., 41., 42.,\n", + " 43., 44., 45., 46., 47., 48., 49., 50., 51., 52., 53., 54., 55., 56.,\n", + " 57., 58., 59., 60.])
<xarray.DataArray 'height_2' (height_2: 60)>\n", + "array([ 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14.,\n", + " 15., 16., 17., 18., 19., 20., 21., 22., 23., 24., 25., 26., 27., 28.,\n", + " 29., 30., 31., 32., 33., 34., 35., 36., 37., 38., 39., 40., 41., 42.,\n", + " 43., 44., 45., 46., 47., 48., 49., 50., 51., 52., 53., 54., 55., 56.,\n", + " 57., 58., 59., 60.])\n", + "Coordinates:\n", + " * height_2 (height_2) float64 1.0 2.0 3.0 4.0 5.0 ... 57.0 58.0 59.0 60.0\n", + "Attributes:\n", + " standard_name: height\n", + " long_name: generalized_height\n", + " axis: Z\n", + " bounds: height_2_bnds
array([ 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14.,\n", + " 15., 16., 17., 18., 19., 20., 21., 22., 23., 24., 25., 26., 27., 28.,\n", + " 29., 30., 31., 32., 33., 34., 35., 36., 37., 38., 39., 40., 41., 42.,\n", + " 43., 44., 45., 46., 47., 48., 49., 50., 51., 52., 53., 54., 55., 56.,\n", + " 57., 58., 59., 60.])
array([ 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14.,\n", + " 15., 16., 17., 18., 19., 20., 21., 22., 23., 24., 25., 26., 27., 28.,\n", + " 29., 30., 31., 32., 33., 34., 35., 36., 37., 38., 39., 40., 41., 42.,\n", + " 43., 44., 45., 46., 47., 48., 49., 50., 51., 52., 53., 54., 55., 56.,\n", + " 57., 58., 59., 60.])
<xarray.DataArray 'HHL' (height: 61, ncells: 17108)>\n", + "[1043588 values with dtype=float32]\n", + "Coordinates:\n", + " clon (ncells) float32 -0.6416 -0.6749 -0.6503 ... 0.6867 0.6921 0.7017\n", + " clat (ncells) float32 1.256 1.25 1.251 1.217 ... 0.4118 0.4222 0.4435\n", + " * height (height) float64 1.0 2.0 3.0 4.0 5.0 ... 57.0 58.0 59.0 60.0 61.0\n", + "Dimensions without coordinates: ncells\n", + "Attributes:\n", + " standard_name: altitude\n", + " long_name: geometric height at half level center\n", + " units: m\n", + " CDI_grid_type: unstructured\n", + " number_of_grid_in_reference: 1\n", + " cell_methods: time: point
[1043588 values with dtype=float32]
array([-0.641613, -0.674926, -0.650324, ..., 0.686725, 0.692111, 0.701713],\n", + " dtype=float32)
array([1.256085, 1.250423, 1.250658, ..., 0.411836, 0.422157, 0.443509],\n", + " dtype=float32)
array([ 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14.,\n", + " 15., 16., 17., 18., 19., 20., 21., 22., 23., 24., 25., 26., 27., 28.,\n", + " 29., 30., 31., 32., 33., 34., 35., 36., 37., 38., 39., 40., 41., 42.,\n", + " 43., 44., 45., 46., 47., 48., 49., 50., 51., 52., 53., 54., 55., 56.,\n", + " 57., 58., 59., 60., 61.])
<xarray.Dataset>\n", + "Dimensions: (bnds: 2, height_2: 60, ncells: 17108, time: 1, vertices: 3)\n", + "Coordinates:\n", + " * time (time) datetime64[ns] 1979-01-01\n", + " clon (ncells) float32 -0.6416 -0.6749 -0.6503 ... 0.6921 0.7017\n", + " clon_bnds (ncells, vertices) float32 -0.629 -0.6632 ... 0.7064 0.6952\n", + " clat (ncells) float32 1.256 1.25 1.251 ... 0.4118 0.4222 0.4435\n", + " clat_bnds (ncells, vertices) float32 1.262 1.256 ... 0.4482 0.4456\n", + " * height_2 (height_2) float64 1.0 2.0 3.0 4.0 ... 57.0 58.0 59.0 60.0\n", + " height_2_bnds (height_2, bnds) float64 1.0 2.0 2.0 3.0 ... 60.0 60.0 61.0\n", + " HHL_bnds (height_2, ncells, bnds) float32 nan nan ... 1.263e+03\n", + " HHL (height_2, ncells) float32 nan nan nan ... 831.8 1.273e+03\n", + "Dimensions without coordinates: bnds, ncells, vertices\n", + "Data variables:\n", + " temp (time, height_2, ncells) float32 ...\n", + "Attributes:\n", + " CDI: Climate Data Interface version 1.9.8 (https://mpime...\n", + " Conventions: CF-1.6\n", + " history: Tue Jun 08 11:00:07 2021: cdo selname,temp icon_197...\n", + " number_of_grid_used: 99\n", + " uuidOfHGrid: 0fd960b5-09da-c2a1-3b03-710a726125a0\n", + " uuidOfVGrid: 96fbc4ad-735b-2bb8-0ab9-982fffb12e60\n", + " source: git@gitlab.dkrz.de:icon/icon-nwp.git@5538446faa8884...\n", + " institution: Max Planck Institute for Meteorology\n", + " title: ICON simulation\n", + " references: see MPIM/DWD publications\n", + " comment: Burkhardt Rockel (g266006) on m11257 (Linux 2.6.32-...\n", + " CDO: Climate Data Operators version 1.9.8 (https://mpime...
array(['1979-01-01T00:00:00.000000000'], dtype='datetime64[ns]')
array([-0.641613, -0.674926, -0.650324, ..., 0.686725, 0.692111, 0.701713],\n", + " dtype=float32)
array([[-0.629043, -0.663165, -0.629089],\n", + " [-0.663165, -0.696116, -0.662118],\n", + " [-0.662118, -0.629089, -0.663165],\n", + " ...,\n", + " [ 0.686527, 0.692 , 0.680222],\n", + " [ 0.692 , 0.697153, 0.685594],\n", + " [ 0.701954, 0.706378, 0.695168]], dtype=float32)
array([1.256085, 1.250423, 1.250658, ..., 0.411836, 0.422157, 0.443509],\n", + " dtype=float32)
array([[1.261529, 1.256005, 1.250677],\n", + " [1.256005, 1.250149, 1.245121],\n", + " [1.245121, 1.250677, 1.256005],\n", + " ...,\n", + " [0.405545, 0.415871, 0.413869],\n", + " [0.415871, 0.426447, 0.42421 ],\n", + " [0.43723 , 0.448175, 0.445647]], dtype=float32)
array([ 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14.,\n", + " 15., 16., 17., 18., 19., 20., 21., 22., 23., 24., 25., 26., 27., 28.,\n", + " 29., 30., 31., 32., 33., 34., 35., 36., 37., 38., 39., 40., 41., 42.,\n", + " 43., 44., 45., 46., 47., 48., 49., 50., 51., 52., 53., 54., 55., 56.,\n", + " 57., 58., 59., 60.])
array([[ 1., 2.],\n", + " [ 2., 3.],\n", + " [ 3., 4.],\n", + " [ 4., 5.],\n", + " [ 5., 6.],\n", + " [ 6., 7.],\n", + " [ 7., 8.],\n", + " [ 8., 9.],\n", + " [ 9., 10.],\n", + " [10., 11.],\n", + " [11., 12.],\n", + " [12., 13.],\n", + " [13., 14.],\n", + " [14., 15.],\n", + " [15., 16.],\n", + " [16., 17.],\n", + " [17., 18.],\n", + " [18., 19.],\n", + " [19., 20.],\n", + " [20., 21.],\n", + " [21., 22.],\n", + " [22., 23.],\n", + " [23., 24.],\n", + " [24., 25.],\n", + " [25., 26.],\n", + " [26., 27.],\n", + " [27., 28.],\n", + " [28., 29.],\n", + " [29., 30.],\n", + " [30., 31.],\n", + " [31., 32.],\n", + " [32., 33.],\n", + " [33., 34.],\n", + " [34., 35.],\n", + " [35., 36.],\n", + " [36., 37.],\n", + " [37., 38.],\n", + " [38., 39.],\n", + " [39., 40.],\n", + " [40., 41.],\n", + " [41., 42.],\n", + " [42., 43.],\n", + " [43., 44.],\n", + " [44., 45.],\n", + " [45., 46.],\n", + " [46., 47.],\n", + " [47., 48.],\n", + " [48., 49.],\n", + " [49., 50.],\n", + " [50., 51.],\n", + " [51., 52.],\n", + " [52., 53.],\n", + " [53., 54.],\n", + " [54., 55.],\n", + " [55., 56.],\n", + " [56., 57.],\n", + " [57., 58.],\n", + " [58., 59.],\n", + " [59., 60.],\n", + " [60., 61.]])
array([[[ nan, nan],\n", + " [ nan, nan],\n", + " [ nan, nan],\n", + " ...,\n", + " [23500. , 21427.959 ],\n", + " [23500. , 21427.959 ],\n", + " [23500. , 21427.959 ]],\n", + "\n", + " [[ nan, nan],\n", + " [ nan, nan],\n", + " [ nan, nan],\n", + " ...,\n", + " [21427.959 , 19633.986 ],\n", + " [21427.959 , 19633.986 ],\n", + " [21427.959 , 19633.986 ]],\n", + "\n", + " [[ nan, nan],\n", + " [ nan, nan],\n", + " [ nan, nan],\n", + " ...,\n", + "...\n", + " ...,\n", + " [ 815.9946 , 765.69495],\n", + " [ 926.72565, 877.0364 ],\n", + " [ 1359.1073 , 1314.2291 ]],\n", + "\n", + " [[ nan, nan],\n", + " [ nan, nan],\n", + " [ nan, nan],\n", + " ...,\n", + " [ 765.69495, 729.9274 ],\n", + " [ 877.0364 , 841.77954],\n", + " [ 1314.2291 , 1283.0355 ]],\n", + "\n", + " [[ nan, nan],\n", + " [ nan, nan],\n", + " [ nan, nan],\n", + " ...,\n", + " [ 729.9274 , 709.9274 ],\n", + " [ 841.77954, 821.77954],\n", + " [ 1283.0355 , 1263.0355 ]]], dtype=float32)
array([[ nan, nan, nan, ..., 22463.98 ,\n", + " 22463.98 , 22463.98 ],\n", + " [ nan, nan, nan, ..., 20530.973 ,\n", + " 20530.973 , 20530.973 ],\n", + " [ nan, nan, nan, ..., 18871.367 ,\n", + " 18871.367 , 18871.367 ],\n", + " ...,\n", + " [ nan, nan, nan, ..., 790.8448 ,\n", + " 901.881 , 1336.6682 ],\n", + " [ nan, nan, nan, ..., 747.81116,\n", + " 859.40796, 1298.6323 ],\n", + " [ nan, nan, nan, ..., 719.9274 ,\n", + " 831.77954, 1273.0355 ]], dtype=float32)
[1026480 values with dtype=float32]