{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Example II: Tracking already loaded data\n", "\n", "Sometimes data needs to be processed first. For example if derived variables like density potential temperature are applied to the tracking, or data needs to be remapped first. In this scenario you would create the dataset yourself, rather then letting the code load the data, and apply the tracking on the dataset. In this example we are going to process satellite based rainfall estimates from the [CMORPH product](https://www.cpc.ncep.noaa.gov/products/janowiak/cmorph_description.html) over the Indonesian archipelago.\n", "\n", "Before we get started we import all modules that are needed to apply the tracking:" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "from IPython.display import HTML\n", "from tintx import RunDirectory, config\n", "import xarray as xr\n", "import pandas as pd\n", "from pathlib import Path\n", "import os\n", "%matplotlib inline" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "os.environ[\"DATA_FILES\"] = \"_static/data\"" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Cmorph is globally available from 60°S - 60°N. In this example we are going to open the dataset and select the sub-region that suits the Indonesian archipelago." ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "names0: [['time', 'time_bounds', 'lat', 'lat_bounds', 'lon', 'lon_bounds', 'cmorph'], ['time', 'time_bounds', 'lat', 'lat_bounds', 'lon', 'lon_bounds', 'cmorph'], ['time', 'time_bounds', 'lat', 'lat_bounds', 'lon', 'lon_bounds', 'cmorph'], ['time', 'time_bounds', 'lat', 'lat_bounds', 'lon', 'lon_bounds', 'cmorph'], ['time', 'time_bounds', 'lat', 'lat_bounds', 'lon', 'lon_bounds', 'cmorph'], ['time', 'time_bounds', 'lat', 'lat_bounds', 'lon', 'lon_bounds', 'cmorph'], ['time', 'time_bounds', 'lat', 'lat_bounds', 'lon', 'lon_bounds', 'cmorph'], ['time', 'time_bounds', 'lat', 'lat_bounds', 'lon', 'lon_bounds', 'cmorph'], ['time', 'time_bounds', 'lat', 'lat_bounds', 'lon', 'lon_bounds', 'cmorph'], ['time', 'time_bounds', 'lat', 'lat_bounds', 'lon', 'lon_bounds', 'cmorph'], ['time', 'time_bounds', 'lat', 'lat_bounds', 'lon', 'lon_bounds', 'cmorph'], ['time', 'time_bounds', 'lat', 'lat_bounds', 'lon', 'lon_bounds', 'cmorph'], ['time', 'time_bounds', 'lat', 'lat_bounds', 'lon', 'lon_bounds', 'cmorph'], ['time', 'time_bounds', 'lat', 'lat_bounds', 'lon', 'lon_bounds', 'cmorph'], ['time', 'time_bounds', 'lat', 'lat_bounds', 'lon', 'lon_bounds', 'cmorph'], ['time', 'time_bounds', 'lat', 'lat_bounds', 'lon', 'lon_bounds', 'cmorph'], ['time', 'time_bounds', 'lat', 'lat_bounds', 'lon', 'lon_bounds', 'cmorph'], ['time', 'time_bounds', 'lat', 'lat_bounds', 'lon', 'lon_bounds', 'cmorph'], ['time', 'time_bounds', 'lat', 'lat_bounds', 'lon', 'lon_bounds', 'cmorph'], ['time', 'time_bounds', 'lat', 'lat_bounds', 'lon', 'lon_bounds', 'cmorph'], ['time', 'time_bounds', 'lat', 'lat_bounds', 'lon', 'lon_bounds', 'cmorph'], ['time', 'time_bounds', 'lat', 'lat_bounds', 'lon', 'lon_bounds', 'cmorph'], ['time', 'time_bounds', 'lat', 'lat_bounds', 'lon', 'lon_bounds', 'cmorph'], ['time', 'time_bounds', 'lat', 'lat_bounds', 'lon', 'lon_bounds', 'cmorph']]\n", "CO: {'time_bounds', 'lat_bounds', 'cmorph', 'lon_bounds', 'time'}\n", "KEYS: ['time', 'time_bounds', 'lat', 'lat_bounds', 'lon', 'lon_bounds', 'cmorph']\n", "names: {'lon_bounds', 'lon', 'time', 'time_bounds', 'lat_bounds', 'cmorph', 'lat'}\n" ] }, { "data": { "text/html": [ "
<xarray.Dataset>\n",
"Dimensions: (time: 48, lon: 825, nv: 2, lat: 357)\n",
"Coordinates:\n",
" * lon (lon) float64 100.0 100.1 100.1 100.2 ... 159.8 159.9 160.0\n",
" * time (time) datetime64[ns] 2020-01-25 ... 2020-01-25T23:30:00\n",
" * lat (lat) float64 -12.95 -12.88 -12.81 -12.73 ... 12.81 12.88 12.95\n",
"Dimensions without coordinates: nv\n",
"Data variables:\n",
" lon_bounds (time, lon, nv) float64 dask.array<chunksize=(2, 825, 2), meta=np.ndarray>\n",
" time_bounds (time, nv) datetime64[ns] dask.array<chunksize=(2, 2), meta=np.ndarray>\n",
" lat_bounds (time, lat, nv) float64 dask.array<chunksize=(2, 357, 2), meta=np.ndarray>\n",
" cmorph (time, lat, lon) float32 dask.array<chunksize=(2, 357, 825), meta=np.ndarray>\n",
"Attributes: (12/57)\n",
" ncei_template_version: NCEI_NetCDF_Grid_template_V2.0\n",
" title: NOAA Climate Data Record (CDR) of CPC Morphin...\n",
" keywords: Precipitation, Satellite, High-Resolution, Gl...\n",
" summary: The CMORPH CDR is a reprocessed and bias-corr...\n",
" references: Xie, P., et al. (2017), Reprocessed, Bias-Cor...\n",
" Conventions: CF-1.6, ACDD-1.3\n",
" ... ...\n",
" geospatial_lat_resolution: 0.072771376\n",
" geospatial_lat_units: degrees_north\n",
" geospatial_lon_min: 0.0\n",
" geospatial_lon_max: 360.0\n",
" geospatial_lon_resolution: 0.072756669\n",
" geospatial_lon_units: degrees_east<xarray.Dataset>\n",
"Dimensions: (time: 48, lon: 825, nv: 2, lat: 357)\n",
"Coordinates:\n",
" * lon (lon) float64 100.0 100.1 100.1 100.2 ... 159.8 159.9 160.0\n",
" * time (time) datetime64[ns] 2020-01-25 ... 2020-01-25T23:30:00\n",
" * lat (lat) float64 -12.95 -12.88 -12.81 -12.73 ... 12.81 12.88 12.95\n",
"Dimensions without coordinates: nv\n",
"Data variables:\n",
" lon_bounds (time, lon, nv) float64 dask.array<chunksize=(2, 825, 2), meta=np.ndarray>\n",
" time_bounds (time, nv) datetime64[ns] dask.array<chunksize=(2, 2), meta=np.ndarray>\n",
" lat_bounds (time, lat, nv) float64 dask.array<chunksize=(2, 357, 2), meta=np.ndarray>\n",
" precip (time, lat, lon) float32 dask.array<chunksize=(2, 357, 825), meta=np.ndarray>\n",
"Attributes: (12/57)\n",
" ncei_template_version: NCEI_NetCDF_Grid_template_V2.0\n",
" title: NOAA Climate Data Record (CDR) of CPC Morphin...\n",
" keywords: Precipitation, Satellite, High-Resolution, Gl...\n",
" summary: The CMORPH CDR is a reprocessed and bias-corr...\n",
" references: Xie, P., et al. (2017), Reprocessed, Bias-Cor...\n",
" Conventions: CF-1.6, ACDD-1.3\n",
" ... ...\n",
" geospatial_lat_resolution: 0.072771376\n",
" geospatial_lat_units: degrees_north\n",
" geospatial_lon_min: 0.0\n",
" geospatial_lon_max: 360.0\n",
" geospatial_lon_resolution: 0.072756669\n",
" geospatial_lon_units: degrees_east| \n", " | \n", " | time | \n", "grid_x | \n", "grid_y | \n", "lon | \n", "lat | \n", "area | \n", "max | \n", "mean | \n", "isolated | \n", "
|---|---|---|---|---|---|---|---|---|---|---|
| scan | \n", "uid | \n", "\n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " |
| 0 | \n", "0 | \n", "2020-01-25 00:00:00 | \n", "623.304 | \n", "2.087 | \n", "145.3314 | \n", "-12.8078 | \n", "23 | \n", "5.07 | \n", "4.811738 | \n", "True | \n", "
| 1 | \n", "2020-01-25 00:00:00 | \n", "819.826 | \n", "13.765 | \n", "159.6645 | \n", "-11.9345 | \n", "115 | \n", "6.40 | \n", "4.352870 | \n", "True | \n", "|
| 2 | \n", "2020-01-25 00:00:00 | \n", "620.889 | \n", "22.111 | \n", "145.1859 | \n", "-11.3523 | \n", "9 | \n", "3.41 | \n", "3.383333 | \n", "True | \n", "|
| 3 | \n", "2020-01-25 00:00:00 | \n", "617.827 | \n", "29.442 | \n", "144.9677 | \n", "-10.8429 | \n", "52 | \n", "5.61 | \n", "4.107116 | \n", "True | \n", "|
| 4 | \n", "2020-01-25 00:00:00 | \n", "594.500 | \n", "48.400 | \n", "143.2215 | \n", "-9.4603 | \n", "10 | \n", "3.68 | \n", "3.420000 | \n", "True | \n", "|
| ... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
| 47 | \n", "322 | \n", "2020-01-25 23:30:00 | \n", "463.125 | \n", "257.875 | \n", "133.6904 | \n", "5.8217 | \n", "8 | \n", "5.97 | \n", "5.950000 | \n", "True | \n", "
| 323 | \n", "2020-01-25 23:30:00 | \n", "363.900 | \n", "271.100 | \n", "126.4875 | \n", "6.7677 | \n", "10 | \n", "14.00 | \n", "6.623000 | \n", "True | \n", "|
| 272 | \n", "2020-01-25 23:30:00 | \n", "364.314 | \n", "279.451 | \n", "126.4875 | \n", "7.3499 | \n", "51 | \n", "91.00 | \n", "21.292744 | \n", "True | \n", "|
| 324 | \n", "2020-01-25 23:30:00 | \n", "375.667 | \n", "292.216 | \n", "127.3605 | \n", "8.2959 | \n", "51 | \n", "9.54 | \n", "4.426471 | \n", "True | \n", "|
| 325 | \n", "2020-01-25 23:30:00 | \n", "363.475 | \n", "294.220 | \n", "126.4147 | \n", "8.4415 | \n", "59 | \n", "16.90 | \n", "6.375593 | \n", "True | \n", "
2732 rows × 9 columns
\n", "<xarray.Dataset>\n",
"Dimensions: (time: 48, nv: 2, lat: 357, lon: 825)\n",
"Coordinates:\n",
" * time (time) datetime64[ns] 2020-01-25 ... 2020-01-25T23:30:00\n",
" * lat (lat) float64 -12.95 -12.88 -12.81 -12.73 ... 12.81 12.88 12.95\n",
" * lon (lon) float64 100.0 100.1 100.1 100.2 ... 159.8 159.9 160.0\n",
"Dimensions without coordinates: nv\n",
"Data variables:\n",
" time_bounds (time, nv) datetime64[ns] dask.array<chunksize=(2, 2), meta=np.ndarray>\n",
" lat_bounds (time, lat, nv) float64 dask.array<chunksize=(2, 357, 2), meta=np.ndarray>\n",
" lon_bounds (time, lon, nv) float64 dask.array<chunksize=(2, 825, 2), meta=np.ndarray>\n",
" precip (time, lat, lon) float32 dask.array<chunksize=(2, 357, 825), meta=np.ndarray>\n",
"Attributes: (12/57)\n",
" ncei_template_version: NCEI_NetCDF_Grid_template_V2.0\n",
" title: NOAA Climate Data Record (CDR) of CPC Morphin...\n",
" keywords: Precipitation, Satellite, High-Resolution, Gl...\n",
" summary: The CMORPH CDR is a reprocessed and bias-corr...\n",
" references: Xie, P., et al. (2017), Reprocessed, Bias-Cor...\n",
" Conventions: CF-1.6, ACDD-1.3\n",
" ... ...\n",
" geospatial_lat_resolution: 0.072771376\n",
" geospatial_lat_units: degrees_north\n",
" geospatial_lon_min: 0.0\n",
" geospatial_lon_max: 360.0\n",
" geospatial_lon_resolution: 0.072756669\n",
" geospatial_lon_units: degrees_east| \n", " | \n", " | time | \n", "grid_x | \n", "grid_y | \n", "lon | \n", "lat | \n", "area | \n", "max | \n", "mean | \n", "isolated | \n", "
|---|---|---|---|---|---|---|---|---|---|---|
| scan | \n", "uid | \n", "\n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " |
| 0 | \n", "0 | \n", "2020-01-25 00:00:00 | \n", "623.304 | \n", "2.087 | \n", "145.3314 | \n", "-12.8078 | \n", "23 | \n", "5.07 | \n", "4.811738 | \n", "True | \n", "
| 1 | \n", "2020-01-25 00:00:00 | \n", "819.826 | \n", "13.765 | \n", "159.6645 | \n", "-11.9345 | \n", "115 | \n", "6.40 | \n", "4.352870 | \n", "True | \n", "|
| 2 | \n", "2020-01-25 00:00:00 | \n", "620.889 | \n", "22.111 | \n", "145.1859 | \n", "-11.3523 | \n", "9 | \n", "3.41 | \n", "3.383333 | \n", "True | \n", "|
| 3 | \n", "2020-01-25 00:00:00 | \n", "617.827 | \n", "29.442 | \n", "144.9677 | \n", "-10.8429 | \n", "52 | \n", "5.61 | \n", "4.107116 | \n", "True | \n", "|
| 4 | \n", "2020-01-25 00:00:00 | \n", "594.500 | \n", "48.400 | \n", "143.2215 | \n", "-9.4603 | \n", "10 | \n", "3.68 | \n", "3.420000 | \n", "True | \n", "|
| ... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
| 47 | \n", "322 | \n", "2020-01-25 23:30:00 | \n", "463.125 | \n", "257.875 | \n", "133.6904 | \n", "5.8217 | \n", "8 | \n", "5.97 | \n", "5.950000 | \n", "True | \n", "
| 323 | \n", "2020-01-25 23:30:00 | \n", "363.900 | \n", "271.100 | \n", "126.4875 | \n", "6.7677 | \n", "10 | \n", "14.00 | \n", "6.623000 | \n", "True | \n", "|
| 272 | \n", "2020-01-25 23:30:00 | \n", "364.314 | \n", "279.451 | \n", "126.4875 | \n", "7.3499 | \n", "51 | \n", "91.00 | \n", "21.292744 | \n", "True | \n", "|
| 324 | \n", "2020-01-25 23:30:00 | \n", "375.667 | \n", "292.216 | \n", "127.3605 | \n", "8.2959 | \n", "51 | \n", "9.54 | \n", "4.426471 | \n", "True | \n", "|
| 325 | \n", "2020-01-25 23:30:00 | \n", "363.475 | \n", "294.220 | \n", "126.4147 | \n", "8.4415 | \n", "59 | \n", "16.90 | \n", "6.375593 | \n", "True | \n", "
2732 rows × 9 columns
\n", "