{ "cells": [ { "cell_type": "markdown", "metadata": { "cell_style": "center", "slideshow": { "slide_type": "slide" } }, "source": [ "
With thanks to Peter Gleckler, Paul Durack, Karl Taylor, and Chris Golaz
\n", "\n", "---\n", "\n", "_This work is performed under the auspices of the U. S. DOE by Lawrence Livermore National Laboratory under contract No. DE-AC52-07NA27344._\n" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "notes" } }, "source": [ "## Notebook Setup\n", "\n", "Create an Anaconda environment for this notebook using the command below, then select the\n", "kernel in Jupyter.\n", "\n", "```bash\n", "conda create -n xcdat_notebook -c conda-forge python xarray netcdf4 xcdat xesmf matplotlib nc-time-axis jupyter\n", "```\n", "\n", "- `xesmf` is required for horizontal regridding with xESMF\n", "- `matplotlib` is an optional dependency required for plotting with xarray\n", "- `nc-time-axis` is an optional dependency required for `matplotlib` to plot `cftime` coordinates\n" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "## Presentation Overview\n", "\n", "Intended audience: Some or no familiarity with `xarray` and/or `xcdat`\n", "\n", "1. **Driving force** behind xCDAT\n", "2. **Goals and milestones** of CDAT's successor\n", "3. Introducing xCDAT\n", "4. Understanding the **basics of Xarray**\n", "5. How **xCDAT extends Xarray** for climate data analysis\n", "6. Technical design philosophy and APIs\n", "7. **Demo** of capabilities\n", "8. How to **get involved**\n" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "## The Driving Force Behind xCDAT\n", "\n", "- The **CDAT (Community Data Analysis Tools)** library has provided a suite of robust and comprehensive open-source climate data analysis and visualization packages for over **20 years**\n", "- A driving **need** for a **modern successor**\n", " - Focus on a maintainable and extensible library\n", " - Serve the needs of the climate community in the long-term\n", "\n", "<xarray.Dataset>\n", "Dimensions: (time: 1980, bnds: 2, lat: 145, lon: 192)\n", "Coordinates:\n", " * time (time) datetime64[ns] 1850-01-16T12:00:00 ... 2014-12-16T12:00:00\n", " * lat (lat) float64 -90.0 -88.75 -87.5 -86.25 ... 86.25 87.5 88.75 90.0\n", " * lon (lon) float64 0.0 1.875 3.75 5.625 ... 352.5 354.4 356.2 358.1\n", " height float64 ...\n", "Dimensions without coordinates: bnds\n", "Data variables:\n", " time_bnds (time, bnds) datetime64[ns] ...\n", " lat_bnds (lat, bnds) float64 ...\n", " lon_bnds (lon, bnds) float64 ...\n", " tas (time, lat, lon) float32 ...\n", "Attributes: (12/48)\n", " Conventions: CF-1.7 CMIP-6.2\n", " activity_id: CMIP\n", " branch_method: standard\n", " branch_time_in_child: 0.0\n", " branch_time_in_parent: 87658.0\n", " creation_date: 2020-06-05T04:06:11Z\n", " ... ...\n", " variant_label: r10i1p1f1\n", " version: v20200605\n", " license: CMIP6 model data produced by CSIRO is li...\n", " cmor_version: 3.4.0\n", " tracking_id: hdl:21.14100/af78ae5e-f3a6-4e99-8cfe-5f2...\n", " DODS_EXTRA.Unlimited_Dimension: time
<xarray.DataArray 'tas' (time: 1980, lat: 145, lon: 192)>\n", "[55123200 values with dtype=float32]\n", "Coordinates:\n", " * time (time) datetime64[ns] 1850-01-16T12:00:00 ... 2014-12-16T12:00:00\n", " * lat (lat) float64 -90.0 -88.75 -87.5 -86.25 ... 86.25 87.5 88.75 90.0\n", " * lon (lon) float64 0.0 1.875 3.75 5.625 7.5 ... 352.5 354.4 356.2 358.1\n", " height float64 ...\n", "Attributes:\n", " standard_name: air_temperature\n", " long_name: Near-Surface Air Temperature\n", " comment: near-surface (usually, 2 meter) air temperature\n", " units: K\n", " cell_methods: area: time: mean\n", " cell_measures: area: areacella\n", " history: 2020-06-05T04:06:10Z altered by CMOR: Treated scalar dime...\n", " _ChunkSizes: [ 1 145 192]
Feature | \n", "API | \n", "Description | \n", "
Extend `xr.open_dataset()` and `xr.open_mfdataset()` | \n", "\n",
"
| \n",
" \n",
"
| \n",
"
Temporal averaging | \n", "\n",
"
| \n",
"
| \n",
"
Geospatial averaging | \n", "`ds.spatial.average()` | \n", "\n",
"
| \n",
"
Horizontal regridding | \n", "`ds.regridder.horizontal()` | \n", "\n",
"
| \n",
"
Vertical regridding | \n", "`ds.regridder.vertical()` | \n", "\n",
"
| \n",
"
<xarray.Dataset>\n", "Dimensions: (time: 1980, bnds: 2, lat: 145, lon: 192)\n", "Coordinates:\n", " * time (time) object 1850-01-16 12:00:00 ... 2014-12-16 12:00:00\n", " * lat (lat) float64 -90.0 -88.75 -87.5 -86.25 ... 86.25 87.5 88.75 90.0\n", " * lon (lon) float64 0.0 1.875 3.75 5.625 ... 352.5 354.4 356.2 358.1\n", " height float64 2.0\n", "Dimensions without coordinates: bnds\n", "Data variables:\n", " time_bnds (time, bnds) object ...\n", " lat_bnds (lat, bnds) float64 ...\n", " lon_bnds (lon, bnds) float64 ...\n", " tas (time, lat, lon) float32 -27.19 -27.19 -27.19 ... -25.29 -25.29\n", "Attributes: (12/48)\n", " Conventions: CF-1.7 CMIP-6.2\n", " activity_id: CMIP\n", " branch_method: standard\n", " branch_time_in_child: 0.0\n", " branch_time_in_parent: 87658.0\n", " creation_date: 2020-06-05T04:06:11Z\n", " ... ...\n", " variant_label: r10i1p1f1\n", " version: v20200605\n", " license: CMIP6 model data produced by CSIRO is li...\n", " cmor_version: 3.4.0\n", " tracking_id: hdl:21.14100/af78ae5e-f3a6-4e99-8cfe-5f2...\n", " DODS_EXTRA.Unlimited_Dimension: time
<xarray.DataArray 'tas' (time: 1980)>\n", "array([25.24722608, 25.61795924, 25.96516235, ..., 26.79536823,\n", " 26.67771602, 26.27182383])\n", "Coordinates:\n", " * time (time) object 1850-01-16 12:00:00 ... 2014-12-16 12:00:00\n", " height float64 2.0
<xarray.DataArray 'tas' (lat: 145, lon: 192)>\n", "array([[-48.01481628, -48.01481628, -48.01481628, ..., -48.01481628,\n", " -48.01481628, -48.01481628],\n", " [-44.94085363, -44.97948214, -45.01815398, ..., -44.82408252,\n", " -44.86273067, -44.9009281 ],\n", " [-44.11875274, -44.23060624, -44.33960158, ..., -43.76766492,\n", " -43.88593717, -44.00303006],\n", " ...,\n", " [-18.21076615, -18.17513373, -18.13957458, ..., -18.32720478,\n", " -18.28428828, -18.2486193 ],\n", " [-18.50778243, -18.49301854, -18.47902819, ..., -18.55410851,\n", " -18.5406963 , -18.52413098],\n", " [-19.07366375, -19.07366375, -19.07366375, ..., -19.07366375,\n", " -19.07366375, -19.07366375]])\n", "Coordinates:\n", " * lat (lat) float64 -90.0 -88.75 -87.5 -86.25 ... 86.25 87.5 88.75 90.0\n", " * lon (lon) float64 0.0 1.875 3.75 5.625 7.5 ... 352.5 354.4 356.2 358.1\n", " height float64 2.0\n", "Attributes:\n", " operation: temporal_avg\n", " mode: average\n", " freq: month\n", " weighted: True
<xarray.Dataset>\n", "Dimensions: (lat: 32, bnds: 2, lon: 65)\n", "Coordinates:\n", " * lat (lat) float64 85.76 80.27 74.74 69.21 ... -74.74 -80.27 -85.76\n", " * lon (lon) float64 0.0 5.625 11.25 16.88 ... 343.1 348.8 354.4 360.0\n", "Dimensions without coordinates: bnds\n", "Data variables:\n", " lat_bnds (lat, bnds) float64 90.0 83.21 83.21 77.61 ... -83.21 -83.21 -90.0\n", " lon_bnds (lon, bnds) float64 -2.812 2.812 2.812 8.438 ... 357.2 357.2 362.8
<xarray.Dataset>\n", "Dimensions: (time: 1980, bnds: 2, lat: 145, lon: 192)\n", "Coordinates:\n", " * time (time) object 1850-01-16 12:00:00 ... 2014-12-16 12:00:00\n", " * lat (lat) float64 -90.0 -88.75 -87.5 -86.25 ... 86.25 87.5 88.75 90.0\n", " * lon (lon) float64 0.0 1.875 3.75 5.625 ... 352.5 354.4 356.2 358.1\n", " height float64 ...\n", "Dimensions without coordinates: bnds\n", "Data variables:\n", " time_bnds (time, bnds) object dask.array<chunksize=(1980, 2), meta=np.ndarray>\n", " lat_bnds (lat, bnds) float64 dask.array<chunksize=(145, 2), meta=np.ndarray>\n", " lon_bnds (lon, bnds) float64 dask.array<chunksize=(192, 2), meta=np.ndarray>\n", " tas (time, lat, lon) float32 dask.array<chunksize=(1205, 145, 192), meta=np.ndarray>\n", "Attributes: (12/49)\n", " Conventions: CF-1.7 CMIP-6.2\n", " activity_id: CMIP\n", " branch_method: standard\n", " branch_time_in_child: 0.0\n", " branch_time_in_parent: 87658.0\n", " creation_date: 2020-06-05T04:06:11Z\n", " ... ...\n", " version: v20200605\n", " license: CMIP6 model data produced by CSIRO is li...\n", " cmor_version: 3.4.0\n", " _NCProperties: version=2,netcdf=4.6.2,hdf5=1.10.5\n", " tracking_id: hdl:21.14100/af78ae5e-f3a6-4e99-8cfe-5f2...\n", " DODS_EXTRA.Unlimited_Dimension: time
<xarray.DataArray 'tas' (time: 1980)>\n", "dask.array<truediv, shape=(1980,), dtype=float64, chunksize=(1205,), chunktype=numpy.ndarray>\n", "Coordinates:\n", " * time (time) object 1850-01-16 12:00:00 ... 2014-12-16 12:00:00\n", " height float64 ...\n", "Attributes:\n", " standard_name: air_temperature\n", " long_name: Near-Surface Air Temperature\n", " comment: near-surface (usually, 2 meter) air temperature\n", " units: K\n", " cell_methods: area: time: mean\n", " cell_measures: area: areacella\n", " history: 2020-06-05T04:06:10Z altered by CMOR: Treated scalar dime...\n", " _ChunkSizes: [ 1 145 192]