{ "cells": [ { "cell_type": "markdown", "id": "4af04318-6cd5-49f3-bd41-ca7f0a1b1fd7", "metadata": {}, "source": [ "# CESM2 LENS with Tracking + Measures #\n", "This tutorial demonstrates how to use Ocetrac for:\n", "* Identifying and tracking spatial-temporal objects in climate data (one ensemble member of CESM2 LENS)\n", "* Calculates characteristics of detected objects" ] }, { "cell_type": "markdown", "id": "11f25411", "metadata": {}, "source": [ "First import the necessary libraries and modules:" ] }, { "cell_type": "code", "execution_count": 1, "id": "2de0856b-3561-4148-a1f6-39c17d1ac864", "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "import xarray as xr\n", "\n", "import cmocean\n", "import cartopy\n", "import cartopy.crs as ccrs\n", "import cartopy.feature as cfeature\n", "from cartopy.mpl.ticker import LongitudeFormatter,LatitudeFormatter\n", "from cartopy.util import add_cyclic_point\n", "import matplotlib.pyplot as plt\n", "import matplotlib.patches as mpatches\n", "from matplotlib.patches import Rectangle\n", "import matplotlib.dates as mdates" ] }, { "cell_type": "code", "execution_count": 2, "id": "071f6802-3e42-497f-9a51-ee9f0b5ab146", "metadata": {}, "outputs": [], "source": [ "import ocetrac\n", "\n", "from utils import cesm2_lens_utils\n", "from utils import cesm_anomalies\n", "from measures.shape_measures import ShapeMeasures\n", "from measures.motion_measures import MotionMeasures\n", "from measures.temporal_measures import get_initial_detection_time, get_duration\n", "from measures.intensity_measures import calculate_intensity_metrics\n", "from measures.plotting import plot_displacement\n", "from measures.measures_utils import convert_lon, get_object_masks, run_shape_measures, run_motion_measures, run_temporal_measures, run_intensity_measures, process_objects_and_calculate_measures" ] }, { "cell_type": "markdown", "id": "790987b3-1512-4742-b3f1-3beda3cd0531", "metadata": {}, "source": [ "### Input specifications and preprocessing" ] }, { "cell_type": "code", "execution_count": 3, "id": "144f6512-b03a-4c02-aafb-37769e6c293c", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
<xarray.DataArray 'SST' (time: 1980, lat: 192, lon: 288)> Size: 438MB\n",
"dask.array<concatenate, shape=(1980, 192, 288), dtype=float32, chunksize=(1, 192, 288), chunktype=numpy.ndarray>\n",
"Coordinates:\n",
" * lat (lat) float64 2kB -90.0 -89.06 -88.12 -87.17 ... 88.12 89.06 90.0\n",
" * lon (lon) float64 2kB 0.0 1.25 2.5 3.75 5.0 ... 355.0 356.2 357.5 358.8\n",
" * time (time) object 16kB 1850-02-01 00:00:00 ... 2015-01-01 00:00:00\n",
"Attributes:\n",
" units: K\n",
" long_name: sea surface temperature\n",
" cell_methods: time: mean