{ "cells": [ { "cell_type": "markdown", "id": "clean-ribbon", "metadata": {}, "source": [ "# CMIP6 #" ] }, { "cell_type": "markdown", "id": "synthetic-fraction", "metadata": {}, "source": [ "Here is a quick example of how to use `Tracker.track` to detect and track **marine heatwaves** from ocean temperature data available from CMIP6.\n", "\n", "First import numpy, xarray, matplotlib, intake, cmip6_preprocessing, ocetrac, and dask:" ] }, { "cell_type": "code", "execution_count": 1, "id": "turned-audit", "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "import xarray as xr\n", "import matplotlib.pyplot as plt\n", "from matplotlib.colors import ListedColormap\n", "import intake\n", "from cmip6_preprocessing.preprocessing import combined_preprocessing\n", "import ocetrac \n", "from dask_gateway import Gateway\n", "from dask.distributed import Client\n", "from dask import delayed\n", "import dask\n", "dask.config.set({\"array.slicing.split_large_chunks\": False});" ] }, { "cell_type": "markdown", "id": "friendly-generation", "metadata": {}, "source": [ "Start a dask kubernetes cluster:" ] }, { "cell_type": "code", "execution_count": 2, "id": "knowing-concern", "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "9aafbd3bae6a47708a814bb3f3801894", "version_major": 2, "version_minor": 0 }, "text/plain": [ "VBox(children=(HTML(value='
| \n", " | unique | \n", "
|---|---|
| activity_id | \n", "1 | \n", "
| institution_id | \n", "1 | \n", "
| source_id | \n", "1 | \n", "
| experiment_id | \n", "1 | \n", "
| member_id | \n", "1 | \n", "
| table_id | \n", "1 | \n", "
| variable_id | \n", "1 | \n", "
| grid_label | \n", "1 | \n", "
| zstore | \n", "1 | \n", "
| dcpp_init_year | \n", "0 | \n", "
| version | \n", "1 | \n", "
<xarray.DataArray 'tos' (time: 420, y: 180, x: 360)>\n",
"dask.array<getitem, shape=(420, 180, 360), dtype=float32, chunksize=(120, 180, 360), chunktype=numpy.ndarray>\n",
"Coordinates:\n",
" * y (y) float64 -89.5 -88.5 -87.5 -86.5 -85.5 ... 86.5 87.5 88.5 89.5\n",
" * x (x) float64 0.5 1.5 2.5 3.5 4.5 ... 355.5 356.5 357.5 358.5 359.5\n",
" * time (time) object 1980-01-16 12:00:00 ... 2014-12-16 12:00:00\n",
" lon (x, y) float64 0.5 0.5 0.5 0.5 0.5 ... 359.5 359.5 359.5 359.5\n",
" lat (x, y) float64 -89.5 -88.5 -87.5 -86.5 ... 86.5 87.5 88.5 89.5\n",
" member_id <U8 'r1i1p1f1'\n",
"Attributes:\n",
" cell_measures: area: areacello\n",
" cell_methods: area: mean where sea time: mean\n",
" comment: Model data on the 1x1 grid includes values in all cells f...\n",
" interp_method: conserve_order1\n",
" long_name: Sea Surface Temperature\n",
" original_name: tos\n",
" standard_name: sea_surface_temperature\n",
" units: degC\n",
"
| \n",
"\n", "\n", " | \n", "
array([-89.5, -88.5, -87.5, -86.5, -85.5, -84.5, -83.5, -82.5, -81.5, -80.5,\n",
" -79.5, -78.5, -77.5, -76.5, -75.5, -74.5, -73.5, -72.5, -71.5, -70.5,\n",
" -69.5, -68.5, -67.5, -66.5, -65.5, -64.5, -63.5, -62.5, -61.5, -60.5,\n",
" -59.5, -58.5, -57.5, -56.5, -55.5, -54.5, -53.5, -52.5, -51.5, -50.5,\n",
" -49.5, -48.5, -47.5, -46.5, -45.5, -44.5, -43.5, -42.5, -41.5, -40.5,\n",
" -39.5, -38.5, -37.5, -36.5, -35.5, -34.5, -33.5, -32.5, -31.5, -30.5,\n",
" -29.5, -28.5, -27.5, -26.5, -25.5, -24.5, -23.5, -22.5, -21.5, -20.5,\n",
" -19.5, -18.5, -17.5, -16.5, -15.5, -14.5, -13.5, -12.5, -11.5, -10.5,\n",
" -9.5, -8.5, -7.5, -6.5, -5.5, -4.5, -3.5, -2.5, -1.5, -0.5,\n",
" 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5,\n",
" 10.5, 11.5, 12.5, 13.5, 14.5, 15.5, 16.5, 17.5, 18.5, 19.5,\n",
" 20.5, 21.5, 22.5, 23.5, 24.5, 25.5, 26.5, 27.5, 28.5, 29.5,\n",
" 30.5, 31.5, 32.5, 33.5, 34.5, 35.5, 36.5, 37.5, 38.5, 39.5,\n",
" 40.5, 41.5, 42.5, 43.5, 44.5, 45.5, 46.5, 47.5, 48.5, 49.5,\n",
" 50.5, 51.5, 52.5, 53.5, 54.5, 55.5, 56.5, 57.5, 58.5, 59.5,\n",
" 60.5, 61.5, 62.5, 63.5, 64.5, 65.5, 66.5, 67.5, 68.5, 69.5,\n",
" 70.5, 71.5, 72.5, 73.5, 74.5, 75.5, 76.5, 77.5, 78.5, 79.5,\n",
" 80.5, 81.5, 82.5, 83.5, 84.5, 85.5, 86.5, 87.5, 88.5, 89.5])array([ 0.5, 1.5, 2.5, ..., 357.5, 358.5, 359.5])
array([cftime.DatetimeNoLeap(1980, 1, 16, 12, 0, 0, 0),\n",
" cftime.DatetimeNoLeap(1980, 2, 15, 0, 0, 0, 0),\n",
" cftime.DatetimeNoLeap(1980, 3, 16, 12, 0, 0, 0), ...,\n",
" cftime.DatetimeNoLeap(2014, 10, 16, 12, 0, 0, 0),\n",
" cftime.DatetimeNoLeap(2014, 11, 16, 0, 0, 0, 0),\n",
" cftime.DatetimeNoLeap(2014, 12, 16, 12, 0, 0, 0)], dtype=object)array([[ 0.5, 0.5, 0.5, ..., 0.5, 0.5, 0.5],\n",
" [ 1.5, 1.5, 1.5, ..., 1.5, 1.5, 1.5],\n",
" [ 2.5, 2.5, 2.5, ..., 2.5, 2.5, 2.5],\n",
" ...,\n",
" [357.5, 357.5, 357.5, ..., 357.5, 357.5, 357.5],\n",
" [358.5, 358.5, 358.5, ..., 358.5, 358.5, 358.5],\n",
" [359.5, 359.5, 359.5, ..., 359.5, 359.5, 359.5]])array([[-89.5, -88.5, -87.5, ..., 87.5, 88.5, 89.5],\n",
" [-89.5, -88.5, -87.5, ..., 87.5, 88.5, 89.5],\n",
" [-89.5, -88.5, -87.5, ..., 87.5, 88.5, 89.5],\n",
" ...,\n",
" [-89.5, -88.5, -87.5, ..., 87.5, 88.5, 89.5],\n",
" [-89.5, -88.5, -87.5, ..., 87.5, 88.5, 89.5],\n",
" [-89.5, -88.5, -87.5, ..., 87.5, 88.5, 89.5]])array('r1i1p1f1', dtype='<U8')