{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "39c7bead",
   "metadata": {},
   "source": [
    "# SA Figure 6: Multi-Field Climate Response to Volcanic Forcing\n",
    "\n",
    "## Scientific Context\n",
    "This notebook generates Figure 6, which analyzes the spatial patterns and temporal evolution of multiple climate fields following a 500 Tg equatorial volcanic eruption. The figure provides a comprehensive view of the coupled atmosphere-ocean-cryosphere response across three distinct time periods, revealing the mechanisms driving AMOC transitions.\n",
    "\n",
    "## Experimental Design\n",
    "- **Volcanic Simulation**: 500 Tg equatorial eruption at model year 7700\n",
    "- **Ensemble**: 50-member Monte Carlo ensemble (volcanic minus control anomalies)\n",
    "- **Model**: CESM1.3 iCESM with CAM5 atmosphere and POP2 ocean components\n",
    "- **Time Periods Analyzed**:\n",
    "  - Period 1: Years 7701-7705 (immediate post-eruption response, 0-5 years)\n",
    "  - Period 2: Years 7706-7715 (transition phase, 5-15 years)\n",
    "  - Period 3: Years 7716-7720 (recovery phase, 15-20 years)\n",
    "\n",
    "## Figure Structure\n",
    "**5 columns × 3 rows** showing temporal evolution of climate fields:\n",
    "\n",
    "### Column A: Surface Air Temperature + Mean Sea Level Pressure\n",
    "- Filled contours: Surface air temperature anomalies (TS, °C)\n",
    "- Contours: Sea level pressure anomalies (PSL, KPa)\n",
    "- Reveals atmospheric cooling and pressure pattern changes\n",
    "\n",
    "### Column B: Sea Surface Salinity + Mixed Layer Depth\n",
    "- Filled contours: Sea surface salinity anomalies (SSS, g/kg)\n",
    "- Contours: Ocean mixed layer depth anomalies (HMXL, m)\n",
    "- Shows haline forcing and upper ocean stratification changes\n",
    "\n",
    "### Column C: Precipitation - Evaporation + Runoff + Sea Ice Fraction\n",
    "- Filled contours: Net freshwater forcing (P-E+R, mm/day)\n",
    "- Contours: Sea ice fraction anomalies (ICEFRAC, %)\n",
    "- Captures freshwater budget and cryosphere response\n",
    "\n",
    "### Column D: Barotropic Stream Function + Surface Wind Stress\n",
    "- Filled contours: Barotropic stream function (BSF, Sv)\n",
    "- Vectors: Surface wind stress (TAUX, TAUY, N/m²)\n",
    "- Illustrates ocean circulation and wind-driven changes\n",
    "\n",
    "### Column E: Atlantic Meridional Overturning Circulation (AMOC)\n",
    "- Contours: AMOC strength (Sv) as function of depth and latitude\n",
    "- Depth range: 0-5000 m\n",
    "- Latitude range: 0-85°N\n",
    "- Shows overturning circulation changes in Atlantic basin\n",
    "\n",
    "## Data Processing Steps\n",
    "1. **Load ensemble mean anomalies** for atmospheric and oceanic variables\n",
    "2. **Regrid ocean variables** from POP2 tripole grid to regular lat-lon grid using xESMF\n",
    "3. **Calculate derived fields**:\n",
    "   - P-E+R from precipitation (PRECT), evaporation (QFLX), and runoff (ROFF_F)\n",
    "   - Unit conversions (kg/m²/s to mm/day, m/s to mm/day)\n",
    "4. **Temporal averaging** over three distinct periods\n",
    "5. **Extract AMOC** from meridional overturning stream function\n",
    "6. **Generate multi-panel figure** with geographic maps and depth-latitude sections\n",
    "\n",
    "## Key Scientific Questions\n",
    "- How do surface climate anomalies evolve across different time scales?\n",
    "- What are the spatial patterns of freshwater forcing that affect ocean stratification?\n",
    "- How do atmospheric pressure and wind stress changes drive ocean circulation response?\n",
    "- What is the relationship between surface forcing and AMOC strength changes?\n",
    "- How do sea ice anomalies contribute to salinity and buoyancy forcing?\n",
    "\n",
    "## Variables Analyzed\n",
    "- **TS**: Surface air temperature (K → °C)\n",
    "- **PSL**: Mean sea level pressure (Pa → KPa)\n",
    "- **SSS (SALT)**: Sea surface salinity (g/kg)\n",
    "- **HMXL**: Ocean mixed layer depth (cm → m)\n",
    "- **PRECT**: Precipitation rate (m/s → mm/day)\n",
    "- **QFLX**: Surface evaporation flux (kg/m²/s → mm/day)\n",
    "- **ROFF_F**: River runoff flux (kg/m²/s → mm/day)\n",
    "- **ICEFRAC**: Sea ice fraction (fraction → %)\n",
    "- **BSF**: Barotropic stream function (Sv)\n",
    "- **TAUX, TAUY**: Zonal and meridional wind stress (N/m²)\n",
    "- **MOC**: Meridional overturning circulation (Sv)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "c5e41d34-3330-4f9a-83a9-b564ee36a3c1",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Import libraries for multi-field climate analysis and visualization\n",
    "# This cell imports all necessary packages for:\n",
    "# - Data manipulation (numpy, xarray, pandas)\n",
    "# - Statistical analysis (scipy)\n",
    "# - Geographic plotting (cartopy)\n",
    "# - Grid regridding (xesmf)\n",
    "# - Color maps optimized for oceanography (cmocean)\n",
    "# - Interactive widgets for exploratory analysis\n",
    "\n",
    "# numpy/scipy stuff\n",
    "import numpy as np\n",
    "import numpy.ma as ma\n",
    "\n",
    "from scipy.signal import argrelextrema\n",
    "from scipy.stats import genextreme as gev\n",
    "\n",
    "from netCDF4 import Dataset \n",
    "\n",
    "# matplotlib stuff\n",
    "import matplotlib.pyplot as plt\n",
    "#plt.style.use('seaborn-talk')\n",
    "import matplotlib.cm as cm\n",
    "import matplotlib.ticker as ticker\n",
    "import matplotlib.patches as patches\n",
    "from matplotlib import colors\n",
    "import matplotlib.gridspec as gridspec\n",
    "from matplotlib.patches import FancyBboxPatch\n",
    "import matplotlib as mpl\n",
    "import matplotlib.lines as mlines\n",
    "import matplotlib.colors as mcolors\n",
    "\n",
    "# data sci stuff\n",
    "import xarray as xr\n",
    "import pandas as pd\n",
    "\n",
    "# system stuff\n",
    "import os\n",
    "import sys\n",
    "import glob\n",
    "import fnmatch\n",
    "\n",
    "# netcdf stuff\n",
    "from netCDF4 import Dataset\n",
    "import datetime\n",
    "import cftime\n",
    "import nc_time_axis\n",
    "\n",
    "# widgets stuff\n",
    "import ipywidgets as widgets\n",
    "from ipywidgets import interact,interactive\n",
    "\n",
    "import xlrd\n",
    "import cmocean as ocm\n",
    "\n",
    "import xesmf as xe\n",
    "from matplotlib import gridspec\n",
    "\n",
    "import cartopy.crs as ccrs\n",
    "import cmaps\n",
    "\n",
    "\n",
    "import cmocean as ocm"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "62dde8ac-1f17-47d5-864a-9f5e7b4d2e77",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<xarray.coding.times.CFDatetimeCoder at 0x79c86ba4f830>"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Initialize CF-compliant time decoder using cftime\n",
    "# This ensures proper handling of non-standard calendar dates in climate model output\n",
    "# Essential for CESM data which uses the \"noleap\" calendar (365 days/year, no leap years)\n",
    "\n",
    "time_coder = xr.coders.CFDatetimeCoder(use_cftime=True)\n",
    "time_coder"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "5d7dcaba-2598-4304-9adf-638587ead3f9",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<xarray.Dataset> Size: 73MB\n",
      "Dimensions:  (time: 3960, lat: 48, lon: 96, ilev: 27, lev: 26)\n",
      "Coordinates:\n",
      "  * time     (time) object 32kB 7676-02-01 00:00:00 ... 8006-01-01 00:00:00\n",
      "  * lat      (lat) float64 384B -87.16 -83.48 -79.78 ... 79.78 83.48 87.16\n",
      "  * lon      (lon) float64 768B 0.0 3.75 7.5 11.25 ... 345.0 348.8 352.5 356.2\n",
      "  * ilev     (ilev) float64 216B 2.194 4.895 9.882 18.05 ... 956.0 985.1 1e+03\n",
      "  * lev      (lev) float64 208B 3.545 7.389 13.97 23.94 ... 929.6 970.6 992.6\n",
      "Data variables: (12/17)\n",
      "    P0       float64 8B ...\n",
      "    PRECT    (time, lat, lon) float32 73MB ...\n",
      "    gw       (lat) float64 384B ...\n",
      "    hyai     (ilev) float64 216B ...\n",
      "    hyam     (lev) float64 208B ...\n",
      "    hybi     (ilev) float64 216B ...\n",
      "    ...       ...\n",
      "    nlon     (lat) int32 192B ...\n",
      "    nsbase   int32 4B ...\n",
      "    ntrk     int32 4B ...\n",
      "    ntrm     int32 4B ...\n",
      "    ntrn     int32 4B ...\n",
      "    wnummax  (lat) int32 192B ...\n",
      "Attributes:\n",
      "    Conventions:      CF-1.0\n",
      "    source:           CAM\n",
      "    case:             cesmi6gat31rblc230iveq500tg7701e000\n",
      "    title:            UNSET\n",
      "    logname:          guivet\n",
      "    host:             g-01-c0080\n",
      "    Version:          $Name$\n",
      "    revision_Id:      $Id$\n",
      "    initial_file:     /home/projects/ku_00112/scratch/guivet/cesm/inputdata_g...\n",
      "    topography_file:  /home/projects/ku_00112/scratch/guivet/cesm/inputdata_g...\n",
      "    history:          Sat Dec 14 11:48:56 2024: ncdiff cesmi6gat31rblc230iveq...\n",
      "    NCO:              netCDF Operators version 5.2.1 (Homepage = http://nco.s...\n",
      "<xarray.Dataset> Size: 73MB\n",
      "Dimensions:  (time: 3960, lat: 48, lon: 96, ilev: 27, lev: 26)\n",
      "Coordinates:\n",
      "  * time     (time) object 32kB 7676-02-01 00:00:00 ... 8006-01-01 00:00:00\n",
      "  * lat      (lat) float64 384B -87.16 -83.48 -79.78 ... 79.78 83.48 87.16\n",
      "  * lon      (lon) float64 768B 0.0 3.75 7.5 11.25 ... 345.0 348.8 352.5 356.2\n",
      "  * ilev     (ilev) float64 216B 2.194 4.895 9.882 18.05 ... 956.0 985.1 1e+03\n",
      "  * lev      (lev) float64 208B 3.545 7.389 13.97 23.94 ... 929.6 970.6 992.6\n",
      "Data variables: (12/17)\n",
      "    P0       float64 8B ...\n",
      "    QFLX     (time, lat, lon) float32 73MB ...\n",
      "    gw       (lat) float64 384B ...\n",
      "    hyai     (ilev) float64 216B ...\n",
      "    hyam     (lev) float64 208B ...\n",
      "    hybi     (ilev) float64 216B ...\n",
      "    ...       ...\n",
      "    nlon     (lat) int32 192B ...\n",
      "    nsbase   int32 4B ...\n",
      "    ntrk     int32 4B ...\n",
      "    ntrm     int32 4B ...\n",
      "    ntrn     int32 4B ...\n",
      "    wnummax  (lat) int32 192B ...\n",
      "Attributes:\n",
      "    Conventions:      CF-1.0\n",
      "    source:           CAM\n",
      "    case:             cesmi6gat31rblc230iveq500tg7701e000\n",
      "    title:            UNSET\n",
      "    logname:          guivet\n",
      "    host:             g-01-c0080\n",
      "    Version:          $Name$\n",
      "    revision_Id:      $Id$\n",
      "    initial_file:     /home/projects/ku_00112/scratch/guivet/cesm/inputdata_g...\n",
      "    topography_file:  /home/projects/ku_00112/scratch/guivet/cesm/inputdata_g...\n",
      "    history:          Sat Dec 14 11:50:53 2024: ncdiff cesmi6gat31rblc230iveq...\n",
      "    NCO:              netCDF Operators version 5.2.1 (Homepage = http://nco.s...\n",
      "<xarray.Dataset> Size: 186MB\n",
      "Dimensions:               (nlat: 116, nlon: 100, time: 3960, z_t: 60, z_w: 60,\n",
      "                           moc_comp: 3, transport_comp: 5, transport_reg: 2,\n",
      "                           lat_aux_grid: 105, moc_z: 61, z_t_150m: 15,\n",
      "                           z_w_bot: 60, z_w_top: 60)\n",
      "Coordinates:\n",
      "  * time                  (time) object 32kB 7676-02-01 00:00:00 ... 8006-01-...\n",
      "  * z_t                   (z_t) float32 240B 500.0 1.5e+03 ... 5.375e+05\n",
      "  * z_w                   (z_w) float32 240B 0.0 1e+03 2e+03 ... 5e+05 5.25e+05\n",
      "  * lat_aux_grid          (lat_aux_grid) float32 420B -80.26 -78.73 ... 90.0\n",
      "  * moc_z                 (moc_z) float32 244B 0.0 1e+03 ... 5.25e+05 5.5e+05\n",
      "  * z_t_150m              (z_t_150m) float32 60B 500.0 1.5e+03 ... 1.45e+04\n",
      "  * z_w_bot               (z_w_bot) float32 240B 1e+03 2e+03 ... 5.5e+05\n",
      "  * z_w_top               (z_w_top) float32 240B 0.0 1e+03 ... 5e+05 5.25e+05\n",
      "    TLAT                  (nlat, nlon) float64 93kB ...\n",
      "    TLONG                 (nlat, nlon) float64 93kB ...\n",
      "    ULAT                  (nlat, nlon) float64 93kB ...\n",
      "    ULONG                 (nlat, nlon) float64 93kB ...\n",
      "Dimensions without coordinates: nlat, nlon, moc_comp, transport_comp,\n",
      "                                transport_reg\n",
      "Data variables: (12/53)\n",
      "    ANGLE                 (nlat, nlon) float64 93kB ...\n",
      "    ANGLET                (nlat, nlon) float64 93kB ...\n",
      "    DXT                   (nlat, nlon) float64 93kB ...\n",
      "    DXU                   (nlat, nlon) float64 93kB ...\n",
      "    DYT                   (nlat, nlon) float64 93kB ...\n",
      "    DYU                   (nlat, nlon) float64 93kB ...\n",
      "    ...                    ...\n",
      "    sflux_factor          float64 8B ...\n",
      "    sound                 float64 8B ...\n",
      "    stefan_boltzmann      float64 8B ...\n",
      "    transport_components  (transport_comp) |S256 1kB ...\n",
      "    transport_regions     (transport_reg) |S256 512B ...\n",
      "    vonkar                float64 8B ...\n",
      "Attributes: (12/13)\n",
      "    title:           cesmi6gat31rblc230iveq500tg7701e000\n",
      "    history:         Sat Dec 14 11:37:02 2024: ncdiff cesmi6gat31rblc230iveq5...\n",
      "    Conventions:     CF-1.0; http://www.cgd.ucar.edu/cms/eaton/netcdf/CF-curr...\n",
      "    contents:        Diagnostic and Prognostic Variables\n",
      "    source:          CCSM POP2, the CCSM Ocean Component\n",
      "    revision:        $Id: tavg.F90 34115 2012-01-25 22:35:19Z njn01 $\n",
      "    ...              ...\n",
      "    start_time:      This dataset was created on 2024-01-09 at 20:42:22.0\n",
      "    cell_methods:    cell_methods = time: mean ==> the variable values are av...\n",
      "    nsteps_total:    26453765\n",
      "    tavg_sum:        2678400.0\n",
      "    tavg_sum_qflux:  2678400.0\n",
      "    NCO:             netCDF Operators version 5.2.1 (Homepage = http://nco.sf...\n"
     ]
    }
   ],
   "source": [
    "# Load freshwater budget components for P-E+R calculation\n",
    "# Three components needed to compute net freshwater forcing:\n",
    "# 1. PRECT: Total precipitation (atmospheric model output)\n",
    "# 2. QFLX: Surface evaporation flux (atmospheric model output)\n",
    "# 3. ROFF_F: River runoff flux (ocean model output, requires regridding)\n",
    "# File naming: cesmi6gat31rblc230iveq-noeq500tg7701 indicates volcanic minus control ensemble mean anomalies\n",
    "directory = '/scratch/pproc/eq500tg7701_ens/'\n",
    "files = [\n",
    "    'cesmi6gat31rblc230iveq-noeq500tg7701_atm_PRECT_ncea.nc',\n",
    "    'cesmi6gat31rblc230iveq-noeq500tg7701_atm_QFLX_ncea.nc',\n",
    "    'cesmi6gat31rblc230iveq-noeq500tg7701_ocn_ROFF_F_ncea.nc'\n",
    "]\n",
    "\n",
    "# Load the datasets into xarray\n",
    "\n",
    "datasets = [xr.open_dataset(os.path.join(directory, file), decode_times=time_coder, decode_timedelta=True) for file in files]\n",
    "\n",
    "for ds in datasets:\n",
    "    print(ds)\n",
    "# Print the datasets to verify"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "99cc862c",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Inspect the latitude coordinates of runoff data (ROFF_F)\n",
    "\n",
    "# Ocean model data uses POP2 displaced pole grid with 2D lat/lon coordinates (TLAT, TLONG)datasets[2].ROFF_F.TLAT\n",
    "# This grid requires regridding to match the regular lat/lon grid of atmospheric variables"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "572398a9",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Create regridder to transform ocean data from POP2 tripole grid to regular lat-lon grid\n",
    "# Ocean variables (ROFF_F) are on the POP2 displaced pole grid (384×320, curvilinear)\n",
    "# Atmospheric variables (PRECT, QFLX) are on regular lat-lon grid (288×192)\n",
    "# Method: 'nearest_s2d' uses nearest neighbor on a 2D spherical surface\n",
    "lon = datasets[0].PRECT.lon\n",
    "lat = datasets[0].PRECT.lat\n",
    "# regrider\n",
    "\n",
    "grid_in = {'lon': datasets[2].ROFF_F.TLONG, 'lat': datasets[2].ROFF_F.TLAT}\n",
    "grid_out = {'lon': lon, 'lat': lat}\n",
    "regridder = xe.Regridder(grid_in, grid_out, 'nearest_s2d', reuse_weights=False)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "id": "3e55ce96",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Calculate annual means of freshwater budget components\n",
    "# Resample from monthly data to yearly averages using 'YE' (year-end) frequency\n",
    "# Apply regridder to ROFF_F before temporal averaging to ensure consistent grid\n",
    "# This produces time series of annual-mean precipitation, evaporation, and runoff anomalies\n",
    "yearly_means = ds.resample(time='YE').mean()\n",
    "PRECT_timeseries = datasets[0].PRECT.resample(time='YE').mean()\n",
    "\n",
    "QFLX_timeseries = datasets[1].QFLX.resample(time='YE').mean()\n",
    "\n",
    "ROFF_timeseries = regridder(datasets[2].ROFF_F).resample(time='YE').mean()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "id": "d6975f95",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><svg style=\"position: absolute; width: 0; height: 0; overflow: hidden\">\n",
       "<defs>\n",
       "<symbol id=\"icon-database\" viewBox=\"0 0 32 32\">\n",
       "<path d=\"M16 0c-8.837 0-16 2.239-16 5v4c0 2.761 7.163 5 16 5s16-2.239 16-5v-4c0-2.761-7.163-5-16-5z\"></path>\n",
       "<path d=\"M16 17c-8.837 0-16-2.239-16-5v6c0 2.761 7.163 5 16 5s16-2.239 16-5v-6c0 2.761-7.163 5-16 5z\"></path>\n",
       "<path d=\"M16 26c-8.837 0-16-2.239-16-5v6c0 2.761 7.163 5 16 5s16-2.239 16-5v-6c0 2.761-7.163 5-16 5z\"></path>\n",
       "</symbol>\n",
       "<symbol id=\"icon-file-text2\" viewBox=\"0 0 32 32\">\n",
       "<path d=\"M28.681 7.159c-0.694-0.947-1.662-2.053-2.724-3.116s-2.169-2.030-3.116-2.724c-1.612-1.182-2.393-1.319-2.841-1.319h-15.5c-1.378 0-2.5 1.121-2.5 2.5v27c0 1.378 1.122 2.5 2.5 2.5h23c1.378 0 2.5-1.122 2.5-2.5v-19.5c0-0.448-0.137-1.23-1.319-2.841zM24.543 5.457c0.959 0.959 1.712 1.825 2.268 2.543h-4.811v-4.811c0.718 0.556 1.584 1.309 2.543 2.268zM28 29.5c0 0.271-0.229 0.5-0.5 0.5h-23c-0.271 0-0.5-0.229-0.5-0.5v-27c0-0.271 0.229-0.5 0.5-0.5 0 0 15.499-0 15.5 0v7c0 0.552 0.448 1 1 1h7v19.5z\"></path>\n",
       "<path d=\"M23 26h-14c-0.552 0-1-0.448-1-1s0.448-1 1-1h14c0.552 0 1 0.448 1 1s-0.448 1-1 1z\"></path>\n",
       "<path d=\"M23 22h-14c-0.552 0-1-0.448-1-1s0.448-1 1-1h14c0.552 0 1 0.448 1 1s-0.448 1-1 1z\"></path>\n",
       "<path d=\"M23 18h-14c-0.552 0-1-0.448-1-1s0.448-1 1-1h14c0.552 0 1 0.448 1 1s-0.448 1-1 1z\"></path>\n",
       "</symbol>\n",
       "</defs>\n",
       "</svg>\n",
       "<style>/* CSS stylesheet for displaying xarray objects in notebooks */\n",
       "\n",
       ":root {\n",
       "  --xr-font-color0: var(\n",
       "    --jp-content-font-color0,\n",
       "    var(--pst-color-text-base rgba(0, 0, 0, 1))\n",
       "  );\n",
       "  --xr-font-color2: var(\n",
       "    --jp-content-font-color2,\n",
       "    var(--pst-color-text-base, rgba(0, 0, 0, 0.54))\n",
       "  );\n",
       "  --xr-font-color3: var(\n",
       "    --jp-content-font-color3,\n",
       "    var(--pst-color-text-base, rgba(0, 0, 0, 0.38))\n",
       "  );\n",
       "  --xr-border-color: var(\n",
       "    --jp-border-color2,\n",
       "    hsl(from var(--pst-color-on-background, white) h s calc(l - 10))\n",
       "  );\n",
       "  --xr-disabled-color: var(\n",
       "    --jp-layout-color3,\n",
       "    hsl(from var(--pst-color-on-background, white) h s calc(l - 40))\n",
       "  );\n",
       "  --xr-background-color: var(\n",
       "    --jp-layout-color0,\n",
       "    var(--pst-color-on-background, white)\n",
       "  );\n",
       "  --xr-background-color-row-even: var(\n",
       "    --jp-layout-color1,\n",
       "    hsl(from var(--pst-color-on-background, white) h s calc(l - 5))\n",
       "  );\n",
       "  --xr-background-color-row-odd: var(\n",
       "    --jp-layout-color2,\n",
       "    hsl(from var(--pst-color-on-background, white) h s calc(l - 15))\n",
       "  );\n",
       "}\n",
       "\n",
       "html[theme=\"dark\"],\n",
       "html[data-theme=\"dark\"],\n",
       "body[data-theme=\"dark\"],\n",
       "body.vscode-dark {\n",
       "  --xr-font-color0: var(\n",
       "    --jp-content-font-color0,\n",
       "    var(--pst-color-text-base, rgba(255, 255, 255, 1))\n",
       "  );\n",
       "  --xr-font-color2: var(\n",
       "    --jp-content-font-color2,\n",
       "    var(--pst-color-text-base, rgba(255, 255, 255, 0.54))\n",
       "  );\n",
       "  --xr-font-color3: var(\n",
       "    --jp-content-font-color3,\n",
       "    var(--pst-color-text-base, rgba(255, 255, 255, 0.38))\n",
       "  );\n",
       "  --xr-border-color: var(\n",
       "    --jp-border-color2,\n",
       "    hsl(from var(--pst-color-on-background, #111111) h s calc(l + 10))\n",
       "  );\n",
       "  --xr-disabled-color: var(\n",
       "    --jp-layout-color3,\n",
       "    hsl(from var(--pst-color-on-background, #111111) h s calc(l + 40))\n",
       "  );\n",
       "  --xr-background-color: var(\n",
       "    --jp-layout-color0,\n",
       "    var(--pst-color-on-background, #111111)\n",
       "  );\n",
       "  --xr-background-color-row-even: var(\n",
       "    --jp-layout-color1,\n",
       "    hsl(from var(--pst-color-on-background, #111111) h s calc(l + 5))\n",
       "  );\n",
       "  --xr-background-color-row-odd: var(\n",
       "    --jp-layout-color2,\n",
       "    hsl(from var(--pst-color-on-background, #111111) h s calc(l + 15))\n",
       "  );\n",
       "}\n",
       "\n",
       ".xr-wrap {\n",
       "  display: block !important;\n",
       "  min-width: 300px;\n",
       "  max-width: 700px;\n",
       "  line-height: 1.6;\n",
       "}\n",
       "\n",
       ".xr-text-repr-fallback {\n",
       "  /* fallback to plain text repr when CSS is not injected (untrusted notebook) */\n",
       "  display: none;\n",
       "}\n",
       "\n",
       ".xr-header {\n",
       "  padding-top: 6px;\n",
       "  padding-bottom: 6px;\n",
       "  margin-bottom: 4px;\n",
       "  border-bottom: solid 1px var(--xr-border-color);\n",
       "}\n",
       "\n",
       ".xr-header > div,\n",
       ".xr-header > ul {\n",
       "  display: inline;\n",
       "  margin-top: 0;\n",
       "  margin-bottom: 0;\n",
       "}\n",
       "\n",
       ".xr-obj-type,\n",
       ".xr-obj-name,\n",
       ".xr-group-name {\n",
       "  margin-left: 2px;\n",
       "  margin-right: 10px;\n",
       "}\n",
       "\n",
       ".xr-group-name::before {\n",
       "  content: \"📁\";\n",
       "  padding-right: 0.3em;\n",
       "}\n",
       "\n",
       ".xr-group-name,\n",
       ".xr-obj-type {\n",
       "  color: var(--xr-font-color2);\n",
       "}\n",
       "\n",
       ".xr-sections {\n",
       "  padding-left: 0 !important;\n",
       "  display: grid;\n",
       "  grid-template-columns: 150px auto auto 1fr 0 20px 0 20px;\n",
       "  margin-block-start: 0;\n",
       "  margin-block-end: 0;\n",
       "}\n",
       "\n",
       ".xr-section-item {\n",
       "  display: contents;\n",
       "}\n",
       "\n",
       ".xr-section-item input {\n",
       "  display: inline-block;\n",
       "  opacity: 0;\n",
       "  height: 0;\n",
       "  margin: 0;\n",
       "}\n",
       "\n",
       ".xr-section-item input + label {\n",
       "  color: var(--xr-disabled-color);\n",
       "  border: 2px solid transparent !important;\n",
       "}\n",
       "\n",
       ".xr-section-item input:enabled + label {\n",
       "  cursor: pointer;\n",
       "  color: var(--xr-font-color2);\n",
       "}\n",
       "\n",
       ".xr-section-item input:focus + label {\n",
       "  border: 2px solid var(--xr-font-color0) !important;\n",
       "}\n",
       "\n",
       ".xr-section-item input:enabled + label:hover {\n",
       "  color: var(--xr-font-color0);\n",
       "}\n",
       "\n",
       ".xr-section-summary {\n",
       "  grid-column: 1;\n",
       "  color: var(--xr-font-color2);\n",
       "  font-weight: 500;\n",
       "}\n",
       "\n",
       ".xr-section-summary > span {\n",
       "  display: inline-block;\n",
       "  padding-left: 0.5em;\n",
       "}\n",
       "\n",
       ".xr-section-summary-in:disabled + label {\n",
       "  color: var(--xr-font-color2);\n",
       "}\n",
       "\n",
       ".xr-section-summary-in + label:before {\n",
       "  display: inline-block;\n",
       "  content: \"►\";\n",
       "  font-size: 11px;\n",
       "  width: 15px;\n",
       "  text-align: center;\n",
       "}\n",
       "\n",
       ".xr-section-summary-in:disabled + label:before {\n",
       "  color: var(--xr-disabled-color);\n",
       "}\n",
       "\n",
       ".xr-section-summary-in:checked + label:before {\n",
       "  content: \"▼\";\n",
       "}\n",
       "\n",
       ".xr-section-summary-in:checked + label > span {\n",
       "  display: none;\n",
       "}\n",
       "\n",
       ".xr-section-summary,\n",
       ".xr-section-inline-details {\n",
       "  padding-top: 4px;\n",
       "}\n",
       "\n",
       ".xr-section-inline-details {\n",
       "  grid-column: 2 / -1;\n",
       "}\n",
       "\n",
       ".xr-section-details {\n",
       "  display: none;\n",
       "  grid-column: 1 / -1;\n",
       "  margin-top: 4px;\n",
       "  margin-bottom: 5px;\n",
       "}\n",
       "\n",
       ".xr-section-summary-in:checked ~ .xr-section-details {\n",
       "  display: contents;\n",
       "}\n",
       "\n",
       ".xr-group-box {\n",
       "  display: inline-grid;\n",
       "  grid-template-columns: 0px 20px auto;\n",
       "  width: 100%;\n",
       "}\n",
       "\n",
       ".xr-group-box-vline {\n",
       "  grid-column-start: 1;\n",
       "  border-right: 0.2em solid;\n",
       "  border-color: var(--xr-border-color);\n",
       "  width: 0px;\n",
       "}\n",
       "\n",
       ".xr-group-box-hline {\n",
       "  grid-column-start: 2;\n",
       "  grid-row-start: 1;\n",
       "  height: 1em;\n",
       "  width: 20px;\n",
       "  border-bottom: 0.2em solid;\n",
       "  border-color: var(--xr-border-color);\n",
       "}\n",
       "\n",
       ".xr-group-box-contents {\n",
       "  grid-column-start: 3;\n",
       "}\n",
       "\n",
       ".xr-array-wrap {\n",
       "  grid-column: 1 / -1;\n",
       "  display: grid;\n",
       "  grid-template-columns: 20px auto;\n",
       "}\n",
       "\n",
       ".xr-array-wrap > label {\n",
       "  grid-column: 1;\n",
       "  vertical-align: top;\n",
       "}\n",
       "\n",
       ".xr-preview {\n",
       "  color: var(--xr-font-color3);\n",
       "}\n",
       "\n",
       ".xr-array-preview,\n",
       ".xr-array-data {\n",
       "  padding: 0 5px !important;\n",
       "  grid-column: 2;\n",
       "}\n",
       "\n",
       ".xr-array-data,\n",
       ".xr-array-in:checked ~ .xr-array-preview {\n",
       "  display: none;\n",
       "}\n",
       "\n",
       ".xr-array-in:checked ~ .xr-array-data,\n",
       ".xr-array-preview {\n",
       "  display: inline-block;\n",
       "}\n",
       "\n",
       ".xr-dim-list {\n",
       "  display: inline-block !important;\n",
       "  list-style: none;\n",
       "  padding: 0 !important;\n",
       "  margin: 0;\n",
       "}\n",
       "\n",
       ".xr-dim-list li {\n",
       "  display: inline-block;\n",
       "  padding: 0;\n",
       "  margin: 0;\n",
       "}\n",
       "\n",
       ".xr-dim-list:before {\n",
       "  content: \"(\";\n",
       "}\n",
       "\n",
       ".xr-dim-list:after {\n",
       "  content: \")\";\n",
       "}\n",
       "\n",
       ".xr-dim-list li:not(:last-child):after {\n",
       "  content: \",\";\n",
       "  padding-right: 5px;\n",
       "}\n",
       "\n",
       ".xr-has-index {\n",
       "  font-weight: bold;\n",
       "}\n",
       "\n",
       ".xr-var-list,\n",
       ".xr-var-item {\n",
       "  display: contents;\n",
       "}\n",
       "\n",
       ".xr-var-item > div,\n",
       ".xr-var-item label,\n",
       ".xr-var-item > .xr-var-name span {\n",
       "  background-color: var(--xr-background-color-row-even);\n",
       "  border-color: var(--xr-background-color-row-odd);\n",
       "  margin-bottom: 0;\n",
       "  padding-top: 2px;\n",
       "}\n",
       "\n",
       ".xr-var-item > .xr-var-name:hover span {\n",
       "  padding-right: 5px;\n",
       "}\n",
       "\n",
       ".xr-var-list > li:nth-child(odd) > div,\n",
       ".xr-var-list > li:nth-child(odd) > label,\n",
       ".xr-var-list > li:nth-child(odd) > .xr-var-name span {\n",
       "  background-color: var(--xr-background-color-row-odd);\n",
       "  border-color: var(--xr-background-color-row-even);\n",
       "}\n",
       "\n",
       ".xr-var-name {\n",
       "  grid-column: 1;\n",
       "}\n",
       "\n",
       ".xr-var-dims {\n",
       "  grid-column: 2;\n",
       "}\n",
       "\n",
       ".xr-var-dtype {\n",
       "  grid-column: 3;\n",
       "  text-align: right;\n",
       "  color: var(--xr-font-color2);\n",
       "}\n",
       "\n",
       ".xr-var-preview {\n",
       "  grid-column: 4;\n",
       "}\n",
       "\n",
       ".xr-index-preview {\n",
       "  grid-column: 2 / 5;\n",
       "  color: var(--xr-font-color2);\n",
       "}\n",
       "\n",
       ".xr-var-name,\n",
       ".xr-var-dims,\n",
       ".xr-var-dtype,\n",
       ".xr-preview,\n",
       ".xr-attrs dt {\n",
       "  white-space: nowrap;\n",
       "  overflow: hidden;\n",
       "  text-overflow: ellipsis;\n",
       "  padding-right: 10px;\n",
       "}\n",
       "\n",
       ".xr-var-name:hover,\n",
       ".xr-var-dims:hover,\n",
       ".xr-var-dtype:hover,\n",
       ".xr-attrs dt:hover {\n",
       "  overflow: visible;\n",
       "  width: auto;\n",
       "  z-index: 1;\n",
       "}\n",
       "\n",
       ".xr-var-attrs,\n",
       ".xr-var-data,\n",
       ".xr-index-data {\n",
       "  display: none;\n",
       "  border-top: 2px dotted var(--xr-background-color);\n",
       "  padding-bottom: 20px !important;\n",
       "  padding-top: 10px !important;\n",
       "}\n",
       "\n",
       ".xr-var-attrs-in + label,\n",
       ".xr-var-data-in + label,\n",
       ".xr-index-data-in + label {\n",
       "  padding: 0 1px;\n",
       "}\n",
       "\n",
       ".xr-var-attrs-in:checked ~ .xr-var-attrs,\n",
       ".xr-var-data-in:checked ~ .xr-var-data,\n",
       ".xr-index-data-in:checked ~ .xr-index-data {\n",
       "  display: block;\n",
       "}\n",
       "\n",
       ".xr-var-data > table {\n",
       "  float: right;\n",
       "}\n",
       "\n",
       ".xr-var-data > pre,\n",
       ".xr-index-data > pre,\n",
       ".xr-var-data > table > tbody > tr {\n",
       "  background-color: transparent !important;\n",
       "}\n",
       "\n",
       ".xr-var-name span,\n",
       ".xr-var-data,\n",
       ".xr-index-name div,\n",
       ".xr-index-data,\n",
       ".xr-attrs {\n",
       "  padding-left: 25px !important;\n",
       "}\n",
       "\n",
       ".xr-attrs,\n",
       ".xr-var-attrs,\n",
       ".xr-var-data,\n",
       ".xr-index-data {\n",
       "  grid-column: 1 / -1;\n",
       "}\n",
       "\n",
       "dl.xr-attrs {\n",
       "  padding: 0;\n",
       "  margin: 0;\n",
       "  display: grid;\n",
       "  grid-template-columns: 125px auto;\n",
       "}\n",
       "\n",
       ".xr-attrs dt,\n",
       ".xr-attrs dd {\n",
       "  padding: 0;\n",
       "  margin: 0;\n",
       "  float: left;\n",
       "  padding-right: 10px;\n",
       "  width: auto;\n",
       "}\n",
       "\n",
       ".xr-attrs dt {\n",
       "  font-weight: normal;\n",
       "  grid-column: 1;\n",
       "}\n",
       "\n",
       ".xr-attrs dt:hover span {\n",
       "  display: inline-block;\n",
       "  background: var(--xr-background-color);\n",
       "  padding-right: 10px;\n",
       "}\n",
       "\n",
       ".xr-attrs dd {\n",
       "  grid-column: 2;\n",
       "  white-space: pre-wrap;\n",
       "  word-break: break-all;\n",
       "}\n",
       "\n",
       ".xr-icon-database,\n",
       ".xr-icon-file-text2,\n",
       ".xr-no-icon {\n",
       "  display: inline-block;\n",
       "  vertical-align: middle;\n",
       "  width: 1em;\n",
       "  height: 1.5em !important;\n",
       "  stroke-width: 0;\n",
       "  stroke: currentColor;\n",
       "  fill: currentColor;\n",
       "}\n",
       "\n",
       ".xr-var-attrs-in:checked + label > .xr-icon-file-text2,\n",
       ".xr-var-data-in:checked + label > .xr-icon-database,\n",
       ".xr-index-data-in:checked + label > .xr-icon-database {\n",
       "  color: var(--xr-font-color0);\n",
       "  filter: drop-shadow(1px 1px 5px var(--xr-font-color2));\n",
       "  stroke-width: 0.8px;\n",
       "}\n",
       "</style><pre class='xr-text-repr-fallback'>&lt;xarray.DataArray &#x27;QFLX&#x27; (time: 331, lat: 48, lon: 96)&gt; Size: 6MB\n",
       "array([[[ 6.44013121e-10,  6.21638074e-10,  6.40030973e-10, ...,\n",
       "          5.96660887e-10,  6.03449957e-10,  5.64843616e-10],\n",
       "        [ 7.71391673e-10,  5.69016334e-10,  3.47854606e-10, ...,\n",
       "          6.55955290e-10,  9.14822662e-10,  8.03676292e-10],\n",
       "        [-1.00761388e-09, -1.66490655e-10, -6.92247204e-10, ...,\n",
       "         -6.00765826e-10, -8.93088770e-10, -3.42860118e-09],\n",
       "        ...,\n",
       "        [ 1.00380693e-09, -7.91388022e-09, -1.28697790e-08, ...,\n",
       "          1.81578041e-08,  1.24985657e-08,  6.13297679e-09],\n",
       "        [-1.60667764e-08, -2.19808776e-08, -3.06140215e-08, ...,\n",
       "         -1.49590129e-09, -3.72411990e-09, -8.86587248e-09],\n",
       "        [-7.60828378e-09, -7.44448414e-09, -7.28902894e-09, ...,\n",
       "         -7.28580263e-09, -7.60140662e-09, -7.75680054e-09]],\n",
       "\n",
       "       [[-1.01674302e-09, -9.33774391e-10, -7.75950137e-10, ...,\n",
       "         -2.36271869e-09, -2.23149965e-09, -1.60947466e-09],\n",
       "        [ 1.86080529e-09,  2.15827600e-09,  2.37648878e-09, ...,\n",
       "         -4.39451447e-10,  2.02616657e-09,  2.66893996e-09],\n",
       "        [ 7.26317495e-09,  6.37805231e-09,  4.13297707e-09, ...,\n",
       "          1.18570185e-08,  6.61712463e-09,  8.36255420e-09],\n",
       "...\n",
       "         -2.01105390e-08, -3.96021278e-08, -3.79668350e-08],\n",
       "        [-6.33320738e-08, -6.26593319e-08, -6.00145711e-08, ...,\n",
       "         -3.26400809e-08, -4.72319073e-08, -6.17681124e-08],\n",
       "        [-2.08267128e-08, -2.00751575e-08, -1.76386070e-08, ...,\n",
       "         -1.97486596e-08, -2.00479580e-08, -2.03743351e-08]],\n",
       "\n",
       "       [[-1.15289058e-08, -1.27475390e-08, -1.38356455e-08, ...,\n",
       "         -1.22633814e-08, -5.77794346e-09, -1.24256481e-08],\n",
       "        [-3.61067976e-09, -5.94890537e-09, -1.67665348e-09, ...,\n",
       "         -2.31557493e-08, -8.01385625e-09,  1.83388238e-09],\n",
       "        [ 4.35687753e-08,  4.50330617e-08,  1.92534912e-08, ...,\n",
       "         -8.35271976e-08, -1.29609248e-08,  1.37094389e-08],\n",
       "        ...,\n",
       "        [ 4.02837941e-09,  9.41111011e-09, -3.07309733e-09, ...,\n",
       "          1.39621790e-08,  1.39286414e-08,  9.81048487e-09],\n",
       "        [ 7.19651894e-09,  4.78206630e-09, -3.43964501e-09, ...,\n",
       "          1.30102755e-08,  1.27228361e-08,  7.41531636e-09],\n",
       "        [ 8.56950244e-09,  7.79440512e-09,  6.74854395e-09, ...,\n",
       "          1.10122480e-08,  1.08846274e-08,  9.37883105e-09]]],\n",
       "      shape=(331, 48, 96), dtype=float32)\n",
       "Coordinates:\n",
       "  * time     (time) object 3kB 7676-12-31 00:00:00 ... 8006-12-31 00:00:00\n",
       "  * lat      (lat) float64 384B -87.16 -83.48 -79.78 ... 79.78 83.48 87.16\n",
       "  * lon      (lon) float64 768B 0.0 3.75 7.5 11.25 ... 345.0 348.8 352.5 356.2\n",
       "Attributes:\n",
       "    units:         kg/m2/s\n",
       "    long_name:     Surface water flux\n",
       "    cell_methods:  time: mean</pre><div class='xr-wrap' style='display:none'><div class='xr-header'><div class='xr-obj-type'>xarray.DataArray</div><div class='xr-obj-name'>&#x27;QFLX&#x27;</div><ul class='xr-dim-list'><li><span class='xr-has-index'>time</span>: 331</li><li><span class='xr-has-index'>lat</span>: 48</li><li><span class='xr-has-index'>lon</span>: 96</li></ul></div><ul class='xr-sections'><li class='xr-section-item'><div class='xr-array-wrap'><input id='section-27568ffc-609b-475a-a4c0-c34b089e4fe0' class='xr-array-in' type='checkbox' checked><label for='section-27568ffc-609b-475a-a4c0-c34b089e4fe0' title='Show/hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-array-preview xr-preview'><span>6.44e-10 6.216e-10 6.4e-10 6.024e-10 ... 1.101e-08 1.088e-08 9.379e-09</span></div><div class='xr-array-data'><pre>array([[[ 6.44013121e-10,  6.21638074e-10,  6.40030973e-10, ...,\n",
       "          5.96660887e-10,  6.03449957e-10,  5.64843616e-10],\n",
       "        [ 7.71391673e-10,  5.69016334e-10,  3.47854606e-10, ...,\n",
       "          6.55955290e-10,  9.14822662e-10,  8.03676292e-10],\n",
       "        [-1.00761388e-09, -1.66490655e-10, -6.92247204e-10, ...,\n",
       "         -6.00765826e-10, -8.93088770e-10, -3.42860118e-09],\n",
       "        ...,\n",
       "        [ 1.00380693e-09, -7.91388022e-09, -1.28697790e-08, ...,\n",
       "          1.81578041e-08,  1.24985657e-08,  6.13297679e-09],\n",
       "        [-1.60667764e-08, -2.19808776e-08, -3.06140215e-08, ...,\n",
       "         -1.49590129e-09, -3.72411990e-09, -8.86587248e-09],\n",
       "        [-7.60828378e-09, -7.44448414e-09, -7.28902894e-09, ...,\n",
       "         -7.28580263e-09, -7.60140662e-09, -7.75680054e-09]],\n",
       "\n",
       "       [[-1.01674302e-09, -9.33774391e-10, -7.75950137e-10, ...,\n",
       "         -2.36271869e-09, -2.23149965e-09, -1.60947466e-09],\n",
       "        [ 1.86080529e-09,  2.15827600e-09,  2.37648878e-09, ...,\n",
       "         -4.39451447e-10,  2.02616657e-09,  2.66893996e-09],\n",
       "        [ 7.26317495e-09,  6.37805231e-09,  4.13297707e-09, ...,\n",
       "          1.18570185e-08,  6.61712463e-09,  8.36255420e-09],\n",
       "...\n",
       "         -2.01105390e-08, -3.96021278e-08, -3.79668350e-08],\n",
       "        [-6.33320738e-08, -6.26593319e-08, -6.00145711e-08, ...,\n",
       "         -3.26400809e-08, -4.72319073e-08, -6.17681124e-08],\n",
       "        [-2.08267128e-08, -2.00751575e-08, -1.76386070e-08, ...,\n",
       "         -1.97486596e-08, -2.00479580e-08, -2.03743351e-08]],\n",
       "\n",
       "       [[-1.15289058e-08, -1.27475390e-08, -1.38356455e-08, ...,\n",
       "         -1.22633814e-08, -5.77794346e-09, -1.24256481e-08],\n",
       "        [-3.61067976e-09, -5.94890537e-09, -1.67665348e-09, ...,\n",
       "         -2.31557493e-08, -8.01385625e-09,  1.83388238e-09],\n",
       "        [ 4.35687753e-08,  4.50330617e-08,  1.92534912e-08, ...,\n",
       "         -8.35271976e-08, -1.29609248e-08,  1.37094389e-08],\n",
       "        ...,\n",
       "        [ 4.02837941e-09,  9.41111011e-09, -3.07309733e-09, ...,\n",
       "          1.39621790e-08,  1.39286414e-08,  9.81048487e-09],\n",
       "        [ 7.19651894e-09,  4.78206630e-09, -3.43964501e-09, ...,\n",
       "          1.30102755e-08,  1.27228361e-08,  7.41531636e-09],\n",
       "        [ 8.56950244e-09,  7.79440512e-09,  6.74854395e-09, ...,\n",
       "          1.10122480e-08,  1.08846274e-08,  9.37883105e-09]]],\n",
       "      shape=(331, 48, 96), dtype=float32)</pre></div></div></li><li class='xr-section-item'><input id='section-58691198-461c-4788-b8c0-d1b57ea45586' class='xr-section-summary-in' type='checkbox'  checked><label for='section-58691198-461c-4788-b8c0-d1b57ea45586' class='xr-section-summary' >Coordinates: <span>(3)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><ul class='xr-var-list'><li class='xr-var-item'><div class='xr-var-name'><span class='xr-has-index'>time</span></div><div class='xr-var-dims'>(time)</div><div class='xr-var-dtype'>object</div><div class='xr-var-preview xr-preview'>7676-12-31 00:00:00 ... 8006-12-...</div><input id='attrs-a1a30506-b9a6-49c3-944f-e9bce83bc160' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-a1a30506-b9a6-49c3-944f-e9bce83bc160' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-9dbdcfbb-c271-41a4-aff5-ecf9614e7e51' class='xr-var-data-in' type='checkbox'><label for='data-9dbdcfbb-c271-41a4-aff5-ecf9614e7e51' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'><dt><span>long_name :</span></dt><dd>time</dd><dt><span>bounds :</span></dt><dd>time_bnds</dd></dl></div><div class='xr-var-data'><pre>array([cftime.DatetimeNoLeap(7676, 12, 31, 0, 0, 0, 0, has_year_zero=True),\n",
       "       cftime.DatetimeNoLeap(7677, 12, 31, 0, 0, 0, 0, has_year_zero=True),\n",
       "       cftime.DatetimeNoLeap(7678, 12, 31, 0, 0, 0, 0, has_year_zero=True),\n",
       "       ...,\n",
       "       cftime.DatetimeNoLeap(8004, 12, 31, 0, 0, 0, 0, has_year_zero=True),\n",
       "       cftime.DatetimeNoLeap(8005, 12, 31, 0, 0, 0, 0, has_year_zero=True),\n",
       "       cftime.DatetimeNoLeap(8006, 12, 31, 0, 0, 0, 0, has_year_zero=True)],\n",
       "      shape=(331,), dtype=object)</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span class='xr-has-index'>lat</span></div><div class='xr-var-dims'>(lat)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>-87.16 -83.48 ... 83.48 87.16</div><input id='attrs-0c673340-5902-415c-9673-80ee087122d3' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-0c673340-5902-415c-9673-80ee087122d3' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-69963896-f780-4d95-85f6-5a1cbb041264' class='xr-var-data-in' type='checkbox'><label for='data-69963896-f780-4d95-85f6-5a1cbb041264' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'><dt><span>long_name :</span></dt><dd>latitude</dd><dt><span>units :</span></dt><dd>degrees_north</dd></dl></div><div class='xr-var-data'><pre>array([-87.159095, -83.478937, -79.777046, -76.070244, -72.361581, -68.652017,\n",
       "       -64.941949, -61.231573, -57.520994, -53.810274, -50.099453, -46.388558,\n",
       "       -42.677606, -38.96661 , -35.25558 , -31.544523, -27.833444, -24.122348,\n",
       "       -20.411238, -16.700118, -12.988989,  -9.277853,  -5.566714,  -1.855571,\n",
       "         1.855571,   5.566714,   9.277853,  12.988989,  16.700118,  20.411238,\n",
       "        24.122348,  27.833444,  31.544523,  35.25558 ,  38.96661 ,  42.677606,\n",
       "        46.388558,  50.099453,  53.810274,  57.520994,  61.231573,  64.941949,\n",
       "        68.652017,  72.361581,  76.070244,  79.777046,  83.478937,  87.159095])</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span class='xr-has-index'>lon</span></div><div class='xr-var-dims'>(lon)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>0.0 3.75 7.5 ... 348.8 352.5 356.2</div><input id='attrs-be018cda-0bdf-46b7-baa6-20770c7ea95b' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-be018cda-0bdf-46b7-baa6-20770c7ea95b' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-ee1e43c5-a4d2-4ea3-b7fc-08460520cc5d' class='xr-var-data-in' type='checkbox'><label for='data-ee1e43c5-a4d2-4ea3-b7fc-08460520cc5d' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'><dt><span>long_name :</span></dt><dd>longitude</dd><dt><span>units :</span></dt><dd>degrees_east</dd></dl></div><div class='xr-var-data'><pre>array([  0.  ,   3.75,   7.5 ,  11.25,  15.  ,  18.75,  22.5 ,  26.25,  30.  ,\n",
       "        33.75,  37.5 ,  41.25,  45.  ,  48.75,  52.5 ,  56.25,  60.  ,  63.75,\n",
       "        67.5 ,  71.25,  75.  ,  78.75,  82.5 ,  86.25,  90.  ,  93.75,  97.5 ,\n",
       "       101.25, 105.  , 108.75, 112.5 , 116.25, 120.  , 123.75, 127.5 , 131.25,\n",
       "       135.  , 138.75, 142.5 , 146.25, 150.  , 153.75, 157.5 , 161.25, 165.  ,\n",
       "       168.75, 172.5 , 176.25, 180.  , 183.75, 187.5 , 191.25, 195.  , 198.75,\n",
       "       202.5 , 206.25, 210.  , 213.75, 217.5 , 221.25, 225.  , 228.75, 232.5 ,\n",
       "       236.25, 240.  , 243.75, 247.5 , 251.25, 255.  , 258.75, 262.5 , 266.25,\n",
       "       270.  , 273.75, 277.5 , 281.25, 285.  , 288.75, 292.5 , 296.25, 300.  ,\n",
       "       303.75, 307.5 , 311.25, 315.  , 318.75, 322.5 , 326.25, 330.  , 333.75,\n",
       "       337.5 , 341.25, 345.  , 348.75, 352.5 , 356.25])</pre></div></li></ul></div></li><li class='xr-section-item'><input id='section-0cec5186-b8d4-41eb-bd6d-6ad2cd50339a' class='xr-section-summary-in' type='checkbox'  checked><label for='section-0cec5186-b8d4-41eb-bd6d-6ad2cd50339a' class='xr-section-summary' >Attributes: <span>(3)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><dl class='xr-attrs'><dt><span>units :</span></dt><dd>kg/m2/s</dd><dt><span>long_name :</span></dt><dd>Surface water flux</dd><dt><span>cell_methods :</span></dt><dd>time: mean</dd></dl></div></li></ul></div></div>"
      ],
      "text/plain": [
       "<xarray.DataArray 'QFLX' (time: 331, lat: 48, lon: 96)> Size: 6MB\n",
       "array([[[ 6.44013121e-10,  6.21638074e-10,  6.40030973e-10, ...,\n",
       "          5.96660887e-10,  6.03449957e-10,  5.64843616e-10],\n",
       "        [ 7.71391673e-10,  5.69016334e-10,  3.47854606e-10, ...,\n",
       "          6.55955290e-10,  9.14822662e-10,  8.03676292e-10],\n",
       "        [-1.00761388e-09, -1.66490655e-10, -6.92247204e-10, ...,\n",
       "         -6.00765826e-10, -8.93088770e-10, -3.42860118e-09],\n",
       "        ...,\n",
       "        [ 1.00380693e-09, -7.91388022e-09, -1.28697790e-08, ...,\n",
       "          1.81578041e-08,  1.24985657e-08,  6.13297679e-09],\n",
       "        [-1.60667764e-08, -2.19808776e-08, -3.06140215e-08, ...,\n",
       "         -1.49590129e-09, -3.72411990e-09, -8.86587248e-09],\n",
       "        [-7.60828378e-09, -7.44448414e-09, -7.28902894e-09, ...,\n",
       "         -7.28580263e-09, -7.60140662e-09, -7.75680054e-09]],\n",
       "\n",
       "       [[-1.01674302e-09, -9.33774391e-10, -7.75950137e-10, ...,\n",
       "         -2.36271869e-09, -2.23149965e-09, -1.60947466e-09],\n",
       "        [ 1.86080529e-09,  2.15827600e-09,  2.37648878e-09, ...,\n",
       "         -4.39451447e-10,  2.02616657e-09,  2.66893996e-09],\n",
       "        [ 7.26317495e-09,  6.37805231e-09,  4.13297707e-09, ...,\n",
       "          1.18570185e-08,  6.61712463e-09,  8.36255420e-09],\n",
       "...\n",
       "         -2.01105390e-08, -3.96021278e-08, -3.79668350e-08],\n",
       "        [-6.33320738e-08, -6.26593319e-08, -6.00145711e-08, ...,\n",
       "         -3.26400809e-08, -4.72319073e-08, -6.17681124e-08],\n",
       "        [-2.08267128e-08, -2.00751575e-08, -1.76386070e-08, ...,\n",
       "         -1.97486596e-08, -2.00479580e-08, -2.03743351e-08]],\n",
       "\n",
       "       [[-1.15289058e-08, -1.27475390e-08, -1.38356455e-08, ...,\n",
       "         -1.22633814e-08, -5.77794346e-09, -1.24256481e-08],\n",
       "        [-3.61067976e-09, -5.94890537e-09, -1.67665348e-09, ...,\n",
       "         -2.31557493e-08, -8.01385625e-09,  1.83388238e-09],\n",
       "        [ 4.35687753e-08,  4.50330617e-08,  1.92534912e-08, ...,\n",
       "         -8.35271976e-08, -1.29609248e-08,  1.37094389e-08],\n",
       "        ...,\n",
       "        [ 4.02837941e-09,  9.41111011e-09, -3.07309733e-09, ...,\n",
       "          1.39621790e-08,  1.39286414e-08,  9.81048487e-09],\n",
       "        [ 7.19651894e-09,  4.78206630e-09, -3.43964501e-09, ...,\n",
       "          1.30102755e-08,  1.27228361e-08,  7.41531636e-09],\n",
       "        [ 8.56950244e-09,  7.79440512e-09,  6.74854395e-09, ...,\n",
       "          1.10122480e-08,  1.08846274e-08,  9.37883105e-09]]],\n",
       "      shape=(331, 48, 96), dtype=float32)\n",
       "Coordinates:\n",
       "  * time     (time) object 3kB 7676-12-31 00:00:00 ... 8006-12-31 00:00:00\n",
       "  * lat      (lat) float64 384B -87.16 -83.48 -79.78 ... 79.78 83.48 87.16\n",
       "  * lon      (lon) float64 768B 0.0 3.75 7.5 11.25 ... 345.0 348.8 352.5 356.2\n",
       "Attributes:\n",
       "    units:         kg/m2/s\n",
       "    long_name:     Surface water flux\n",
       "    cell_methods:  time: mean"
      ]
     },
     "execution_count": 46,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "QFLX_timeseries"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "id": "ac1085cb",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Convert freshwater flux units to mm/day for consistent analysis\n",
    "# Model output units vary by variable:\n",
    "# - QFLX (evaporation): kg/m²/s → multiply by 86400 s/day → mm/day\n",
    "# - ROFF_F (runoff): kg/m²/s → multiply by 86400 s/day → mm/day  \n",
    "# - PRECT (precipitation): m/s → multiply by 86400 s/day × 1000 mm/m → mm/day\n",
    "# Note: 1 kg/m² of water = 1 mm depth (density of water = 1000 kg/m³)\n",
    "# Now we need to convert Q flux from kilograms per meter squared per second to millimeters per day. \n",
    "# 1 kg/m^2/s = 86400 mm/day\n",
    "QFLX_timeseries = QFLX_timeseries * 86400\n",
    "# Now we need to convert runoff from kilograms per meter squared per second to millimeters per day.\n",
    "# 1 kg/m^2/s = 86400 mm/day\n",
    "ROFF_timeseries = ROFF_timeseries * 86400\n",
    "# Now we need to convert precipitation from meters per second to millimeters per day.\n",
    "# 1 m/s = 86400 * 1000 mm/day\n",
    "PRECT_timeseries = PRECT_timeseries * 86400 * 1000"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "id": "06828d94",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Calculate net freshwater forcing: P-E+R (Precipitation minus Evaporation plus Runoff)\n",
    "# This represents the total freshwater input to the ocean surface\n",
    "\n",
    "# Positive values: net freshening (increases ocean stratification)\n",
    "P_E_R_timeseries = PRECT_timeseries - QFLX_timeseries + ROFF_timeseries\n",
    "\n",
    "# Negative values: net salinification (decreases ocean stratification)# Now we need to create P minus E plus R. \n",
    "# Critical for understanding changes in ocean buoyancy forcing and AMOC response"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "id": "1b569df2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.collections.QuadMesh at 0x79c85ea4c7a0>"
      ]
     },
     "execution_count": 49,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 39444 characters]",
      "text/plain": [
       "<Figure size 640x480 with 2 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "P_E_R_timeseries[100,:,:].plot()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "id": "89e6f70b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<cartopy.mpl.feature_artist.FeatureArtist at 0x79c85e2a39b0>"
      ]
     },
     "execution_count": 50,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 176212 characters]",
      "text/plain": [
       "<Figure size 1000x1000 with 2 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "fig = plt.figure(figsize=(10, 10))\n",
    "ax = plt.axes(projection=ccrs.NorthPolarStereo())\n",
    "\n",
    "P_E_R_timeseries[100, :, :].plot(ax=ax, transform=ccrs.PlateCarree(), cmap='coolwarm')\n",
    "# Set the map extent (optional)\n",
    "# This will show the region from 0°N to 90°N\n",
    "ax.set_extent([-180, 180, 45, 90], crs=ccrs.PlateCarree())\n",
    "ax.coastlines()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "id": "5065ef0f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "99ba92c07234458ca20cb79c20a951c6",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "interactive(children=(IntSlider(value=165, description='time_index', max=330), Output()), _dom_classes=('widge…"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "@interact(time_index=(0, len(PRECT_timeseries.time) - 1))\n",
    "def plot_timeseries(time_index):\n",
    "    ax = plt.axes(projection=ccrs.NorthPolarStereo())\n",
    "    P_E_R_timeseries[time_index, :, :].plot.contourf(ax=ax, transform=ccrs.PlateCarree(), cmap='coolwarm', levels=np.linspace(-2, 2, 21), extend='both')\n",
    "    # Set the map extent (optional)\n",
    "    # This will show the region from 0°N to 90°N\n",
    "    ax.set_extent([-180, 180, 45, 90], crs=ccrs.PlateCarree())\n",
    "    ax.coastlines()\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "id": "12fb5601",
   "metadata": {},
   "outputs": [],
   "source": [
    "def plot_timeseries(time_index):\n",
    "    fig, axes = plt.subplots(nrows=1, ncols=10, figsize=(20, 10), subplot_kw={'projection': ccrs.NorthPolarStereo()})\n",
    "    iy = 0\n",
    "    for i, ax in enumerate(axes):\n",
    "        time_index = 24 + i\n",
    "        pvar = P_E_R_timeseries[time_index, :, :]\n",
    "        im = pvar.plot.contourf(ax=ax, transform=ccrs.PlateCarree(), cmap='coolwarm_r', levels=np.linspace(-1, 1, 21), extend='both', add_colorbar=False)\n",
    "        ax.set_extent([-180, 180, 45, 90], crs=ccrs.PlateCarree())\n",
    "        ax.coastlines()\n",
    "        year = 7700 + iy\n",
    "        ax.set_title(f'P-E+R Year: {year}')\n",
    "        iy += 1    \n",
    "    cbar = fig.colorbar(im, ax=axes.ravel().tolist(), orientation='vertical', pad=0.01, aspect=50)\n",
    "    plt.tight_layout()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "id": "30c129c9",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/tmp/ipykernel_288886/2140791304.py:14: UserWarning: This figure includes Axes that are not compatible with tight_layout, so results might be incorrect.\n",
      "  plt.tight_layout()\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 337196 characters]",
      "text/plain": [
       "<Figure size 2000x1000 with 11 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plot_timeseries(0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "id": "7545e394",
   "metadata": {},
   "outputs": [],
   "source": [
    "def plot_timeseries(time_index):\n",
    "    # Create figure with slightly more width to accommodate colorbar\n",
    "    fig = plt.figure(figsize=(22, 10))  # Increased width from 20 to 22\n",
    "\n",
    "    # Create GridSpec to have better control over subplot layout\n",
    "    gs = fig.add_gridspec(1, 11, width_ratios=[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.05])\n",
    "\n",
    "    # Create axes for the maps\n",
    "    axes = []\n",
    "    for i in range(10):\n",
    "        ax = fig.add_subplot(gs[0, i], projection=ccrs.NorthPolarStereo())\n",
    "        axes.append(ax)\n",
    "\n",
    "    # Create axis for colorbar\n",
    "    cax = fig.add_subplot(gs[0, -1])\n",
    "\n",
    "    iy = 0\n",
    "    for i, ax in enumerate(axes):\n",
    "        time_index = 24 + i\n",
    "        pvar = P_E_R_timeseries[time_index, :, :]\n",
    "        im = pvar.plot.contourf(ax=ax, transform=ccrs.PlateCarree(), \n",
    "                               cmap='coolwarm_r', levels=np.linspace(-1, 1, 21), \n",
    "                               extend='both', add_colorbar=False)\n",
    "        ax.set_extent([-180, 180, 45, 90], crs=ccrs.PlateCarree())\n",
    "        ax.coastlines()\n",
    "        year = 7700 + iy\n",
    "        ax.set_title(f'P-E+R Year: {year}')\n",
    "        iy += 1\n",
    "\n",
    "    # Add colorbar using the dedicated axis\n",
    "    cbar = fig.colorbar(im, cax=cax, orientation='vertical')\n",
    "\n",
    "    plt.tight_layout()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "id": "0093c767",
   "metadata": {},
   "outputs": [],
   "source": [
    "def plot_per_timeseries(time_index):\n",
    "    # Create figure with slightly more width to accommodate colorbar\n",
    "    fig = plt.figure(figsize=(22, 3))\n",
    "\n",
    "    # Create GridSpec to have better control over subplot layout\n",
    "    gs = fig.add_gridspec(1, 11, width_ratios=[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.05])\n",
    "\n",
    "    # Create axes for the maps\n",
    "    axes = []\n",
    "    for i in range(10):\n",
    "        ax = fig.add_subplot(gs[0, i], projection=ccrs.NorthPolarStereo())\n",
    "        axes.append(ax)\n",
    "\n",
    "    # Create axis for colorbar with the same position as the last plot\n",
    "    cax = fig.add_subplot(gs[0, -1])\n",
    "\n",
    "    iy = 0\n",
    "    for i, ax in enumerate(axes):\n",
    "        time_index = 24 +i\n",
    "        pvar = P_E_R_timeseries[time_index, :, :]\n",
    "        im = pvar.plot.contourf(ax=ax, transform=ccrs.PlateCarree(), \n",
    "                               cmap='coolwarm_r', levels=np.linspace(-1, 1, 21), \n",
    "                               extend='both', add_colorbar=False)\n",
    "        ax.set_extent([-180, 180, 45, 90], crs=ccrs.PlateCarree())\n",
    "        ax.coastlines()\n",
    "        year = 7700 + iy\n",
    "        ax.set_title(f'P-E+R Year: {year}')\n",
    "        iy += 1\n",
    "\n",
    "    # Get the position of the last plot\n",
    "    last_plot_pos = axes[-1].get_position()\n",
    "\n",
    "    # Set colorbar position to match the last plot's height\n",
    "    cax.set_position([cax.get_position().x0,\n",
    "                     last_plot_pos.y0,\n",
    "                     cax.get_position().width,\n",
    "                     last_plot_pos.height])\n",
    "\n",
    "    # Add colorbar using the adjusted cax\n",
    "    cbar = fig.colorbar(im, cax=cax, orientation='vertical')\n",
    "    # Units on colorbar are in mm/day\n",
    "    cbar.set_label('Prec - Evap + Runnoff (mm day$^{-1}$)')\n",
    "\n",
    "    plt.tight_layout()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "id": "24e751a2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 361404 characters]",
      "text/plain": [
       "<Figure size 2200x300 with 11 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plot_per_timeseries(0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "id": "a86a31dc",
   "metadata": {},
   "outputs": [],
   "source": [
    "taux_directory = '/scratch/pproc/eq500tg7701_ens/'\n",
    "# Load the datasets into xarray\n",
    "taux_dataset = xr.open_dataset(os.path.join(taux_directory, \"cesmi6gat31rblc230iveq-noeq500tg7701_atm_TAUX_ncea.nc\"), decode_times=time_coder, decode_timedelta=True).TAUX.resample(time='YE').mean()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "id": "fac4702a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><svg style=\"position: absolute; width: 0; height: 0; overflow: hidden\">\n",
       "<defs>\n",
       "<symbol id=\"icon-database\" viewBox=\"0 0 32 32\">\n",
       "<path d=\"M16 0c-8.837 0-16 2.239-16 5v4c0 2.761 7.163 5 16 5s16-2.239 16-5v-4c0-2.761-7.163-5-16-5z\"></path>\n",
       "<path d=\"M16 17c-8.837 0-16-2.239-16-5v6c0 2.761 7.163 5 16 5s16-2.239 16-5v-6c0 2.761-7.163 5-16 5z\"></path>\n",
       "<path d=\"M16 26c-8.837 0-16-2.239-16-5v6c0 2.761 7.163 5 16 5s16-2.239 16-5v-6c0 2.761-7.163 5-16 5z\"></path>\n",
       "</symbol>\n",
       "<symbol id=\"icon-file-text2\" viewBox=\"0 0 32 32\">\n",
       "<path d=\"M28.681 7.159c-0.694-0.947-1.662-2.053-2.724-3.116s-2.169-2.030-3.116-2.724c-1.612-1.182-2.393-1.319-2.841-1.319h-15.5c-1.378 0-2.5 1.121-2.5 2.5v27c0 1.378 1.122 2.5 2.5 2.5h23c1.378 0 2.5-1.122 2.5-2.5v-19.5c0-0.448-0.137-1.23-1.319-2.841zM24.543 5.457c0.959 0.959 1.712 1.825 2.268 2.543h-4.811v-4.811c0.718 0.556 1.584 1.309 2.543 2.268zM28 29.5c0 0.271-0.229 0.5-0.5 0.5h-23c-0.271 0-0.5-0.229-0.5-0.5v-27c0-0.271 0.229-0.5 0.5-0.5 0 0 15.499-0 15.5 0v7c0 0.552 0.448 1 1 1h7v19.5z\"></path>\n",
       "<path d=\"M23 26h-14c-0.552 0-1-0.448-1-1s0.448-1 1-1h14c0.552 0 1 0.448 1 1s-0.448 1-1 1z\"></path>\n",
       "<path d=\"M23 22h-14c-0.552 0-1-0.448-1-1s0.448-1 1-1h14c0.552 0 1 0.448 1 1s-0.448 1-1 1z\"></path>\n",
       "<path d=\"M23 18h-14c-0.552 0-1-0.448-1-1s0.448-1 1-1h14c0.552 0 1 0.448 1 1s-0.448 1-1 1z\"></path>\n",
       "</symbol>\n",
       "</defs>\n",
       "</svg>\n",
       "<style>/* CSS stylesheet for displaying xarray objects in notebooks */\n",
       "\n",
       ":root {\n",
       "  --xr-font-color0: var(\n",
       "    --jp-content-font-color0,\n",
       "    var(--pst-color-text-base rgba(0, 0, 0, 1))\n",
       "  );\n",
       "  --xr-font-color2: var(\n",
       "    --jp-content-font-color2,\n",
       "    var(--pst-color-text-base, rgba(0, 0, 0, 0.54))\n",
       "  );\n",
       "  --xr-font-color3: var(\n",
       "    --jp-content-font-color3,\n",
       "    var(--pst-color-text-base, rgba(0, 0, 0, 0.38))\n",
       "  );\n",
       "  --xr-border-color: var(\n",
       "    --jp-border-color2,\n",
       "    hsl(from var(--pst-color-on-background, white) h s calc(l - 10))\n",
       "  );\n",
       "  --xr-disabled-color: var(\n",
       "    --jp-layout-color3,\n",
       "    hsl(from var(--pst-color-on-background, white) h s calc(l - 40))\n",
       "  );\n",
       "  --xr-background-color: var(\n",
       "    --jp-layout-color0,\n",
       "    var(--pst-color-on-background, white)\n",
       "  );\n",
       "  --xr-background-color-row-even: var(\n",
       "    --jp-layout-color1,\n",
       "    hsl(from var(--pst-color-on-background, white) h s calc(l - 5))\n",
       "  );\n",
       "  --xr-background-color-row-odd: var(\n",
       "    --jp-layout-color2,\n",
       "    hsl(from var(--pst-color-on-background, white) h s calc(l - 15))\n",
       "  );\n",
       "}\n",
       "\n",
       "html[theme=\"dark\"],\n",
       "html[data-theme=\"dark\"],\n",
       "body[data-theme=\"dark\"],\n",
       "body.vscode-dark {\n",
       "  --xr-font-color0: var(\n",
       "    --jp-content-font-color0,\n",
       "    var(--pst-color-text-base, rgba(255, 255, 255, 1))\n",
       "  );\n",
       "  --xr-font-color2: var(\n",
       "    --jp-content-font-color2,\n",
       "    var(--pst-color-text-base, rgba(255, 255, 255, 0.54))\n",
       "  );\n",
       "  --xr-font-color3: var(\n",
       "    --jp-content-font-color3,\n",
       "    var(--pst-color-text-base, rgba(255, 255, 255, 0.38))\n",
       "  );\n",
       "  --xr-border-color: var(\n",
       "    --jp-border-color2,\n",
       "    hsl(from var(--pst-color-on-background, #111111) h s calc(l + 10))\n",
       "  );\n",
       "  --xr-disabled-color: var(\n",
       "    --jp-layout-color3,\n",
       "    hsl(from var(--pst-color-on-background, #111111) h s calc(l + 40))\n",
       "  );\n",
       "  --xr-background-color: var(\n",
       "    --jp-layout-color0,\n",
       "    var(--pst-color-on-background, #111111)\n",
       "  );\n",
       "  --xr-background-color-row-even: var(\n",
       "    --jp-layout-color1,\n",
       "    hsl(from var(--pst-color-on-background, #111111) h s calc(l + 5))\n",
       "  );\n",
       "  --xr-background-color-row-odd: var(\n",
       "    --jp-layout-color2,\n",
       "    hsl(from var(--pst-color-on-background, #111111) h s calc(l + 15))\n",
       "  );\n",
       "}\n",
       "\n",
       ".xr-wrap {\n",
       "  display: block !important;\n",
       "  min-width: 300px;\n",
       "  max-width: 700px;\n",
       "  line-height: 1.6;\n",
       "}\n",
       "\n",
       ".xr-text-repr-fallback {\n",
       "  /* fallback to plain text repr when CSS is not injected (untrusted notebook) */\n",
       "  display: none;\n",
       "}\n",
       "\n",
       ".xr-header {\n",
       "  padding-top: 6px;\n",
       "  padding-bottom: 6px;\n",
       "  margin-bottom: 4px;\n",
       "  border-bottom: solid 1px var(--xr-border-color);\n",
       "}\n",
       "\n",
       ".xr-header > div,\n",
       ".xr-header > ul {\n",
       "  display: inline;\n",
       "  margin-top: 0;\n",
       "  margin-bottom: 0;\n",
       "}\n",
       "\n",
       ".xr-obj-type,\n",
       ".xr-obj-name,\n",
       ".xr-group-name {\n",
       "  margin-left: 2px;\n",
       "  margin-right: 10px;\n",
       "}\n",
       "\n",
       ".xr-group-name::before {\n",
       "  content: \"📁\";\n",
       "  padding-right: 0.3em;\n",
       "}\n",
       "\n",
       ".xr-group-name,\n",
       ".xr-obj-type {\n",
       "  color: var(--xr-font-color2);\n",
       "}\n",
       "\n",
       ".xr-sections {\n",
       "  padding-left: 0 !important;\n",
       "  display: grid;\n",
       "  grid-template-columns: 150px auto auto 1fr 0 20px 0 20px;\n",
       "  margin-block-start: 0;\n",
       "  margin-block-end: 0;\n",
       "}\n",
       "\n",
       ".xr-section-item {\n",
       "  display: contents;\n",
       "}\n",
       "\n",
       ".xr-section-item input {\n",
       "  display: inline-block;\n",
       "  opacity: 0;\n",
       "  height: 0;\n",
       "  margin: 0;\n",
       "}\n",
       "\n",
       ".xr-section-item input + label {\n",
       "  color: var(--xr-disabled-color);\n",
       "  border: 2px solid transparent !important;\n",
       "}\n",
       "\n",
       ".xr-section-item input:enabled + label {\n",
       "  cursor: pointer;\n",
       "  color: var(--xr-font-color2);\n",
       "}\n",
       "\n",
       ".xr-section-item input:focus + label {\n",
       "  border: 2px solid var(--xr-font-color0) !important;\n",
       "}\n",
       "\n",
       ".xr-section-item input:enabled + label:hover {\n",
       "  color: var(--xr-font-color0);\n",
       "}\n",
       "\n",
       ".xr-section-summary {\n",
       "  grid-column: 1;\n",
       "  color: var(--xr-font-color2);\n",
       "  font-weight: 500;\n",
       "}\n",
       "\n",
       ".xr-section-summary > span {\n",
       "  display: inline-block;\n",
       "  padding-left: 0.5em;\n",
       "}\n",
       "\n",
       ".xr-section-summary-in:disabled + label {\n",
       "  color: var(--xr-font-color2);\n",
       "}\n",
       "\n",
       ".xr-section-summary-in + label:before {\n",
       "  display: inline-block;\n",
       "  content: \"►\";\n",
       "  font-size: 11px;\n",
       "  width: 15px;\n",
       "  text-align: center;\n",
       "}\n",
       "\n",
       ".xr-section-summary-in:disabled + label:before {\n",
       "  color: var(--xr-disabled-color);\n",
       "}\n",
       "\n",
       ".xr-section-summary-in:checked + label:before {\n",
       "  content: \"▼\";\n",
       "}\n",
       "\n",
       ".xr-section-summary-in:checked + label > span {\n",
       "  display: none;\n",
       "}\n",
       "\n",
       ".xr-section-summary,\n",
       ".xr-section-inline-details {\n",
       "  padding-top: 4px;\n",
       "}\n",
       "\n",
       ".xr-section-inline-details {\n",
       "  grid-column: 2 / -1;\n",
       "}\n",
       "\n",
       ".xr-section-details {\n",
       "  display: none;\n",
       "  grid-column: 1 / -1;\n",
       "  margin-top: 4px;\n",
       "  margin-bottom: 5px;\n",
       "}\n",
       "\n",
       ".xr-section-summary-in:checked ~ .xr-section-details {\n",
       "  display: contents;\n",
       "}\n",
       "\n",
       ".xr-group-box {\n",
       "  display: inline-grid;\n",
       "  grid-template-columns: 0px 20px auto;\n",
       "  width: 100%;\n",
       "}\n",
       "\n",
       ".xr-group-box-vline {\n",
       "  grid-column-start: 1;\n",
       "  border-right: 0.2em solid;\n",
       "  border-color: var(--xr-border-color);\n",
       "  width: 0px;\n",
       "}\n",
       "\n",
       ".xr-group-box-hline {\n",
       "  grid-column-start: 2;\n",
       "  grid-row-start: 1;\n",
       "  height: 1em;\n",
       "  width: 20px;\n",
       "  border-bottom: 0.2em solid;\n",
       "  border-color: var(--xr-border-color);\n",
       "}\n",
       "\n",
       ".xr-group-box-contents {\n",
       "  grid-column-start: 3;\n",
       "}\n",
       "\n",
       ".xr-array-wrap {\n",
       "  grid-column: 1 / -1;\n",
       "  display: grid;\n",
       "  grid-template-columns: 20px auto;\n",
       "}\n",
       "\n",
       ".xr-array-wrap > label {\n",
       "  grid-column: 1;\n",
       "  vertical-align: top;\n",
       "}\n",
       "\n",
       ".xr-preview {\n",
       "  color: var(--xr-font-color3);\n",
       "}\n",
       "\n",
       ".xr-array-preview,\n",
       ".xr-array-data {\n",
       "  padding: 0 5px !important;\n",
       "  grid-column: 2;\n",
       "}\n",
       "\n",
       ".xr-array-data,\n",
       ".xr-array-in:checked ~ .xr-array-preview {\n",
       "  display: none;\n",
       "}\n",
       "\n",
       ".xr-array-in:checked ~ .xr-array-data,\n",
       ".xr-array-preview {\n",
       "  display: inline-block;\n",
       "}\n",
       "\n",
       ".xr-dim-list {\n",
       "  display: inline-block !important;\n",
       "  list-style: none;\n",
       "  padding: 0 !important;\n",
       "  margin: 0;\n",
       "}\n",
       "\n",
       ".xr-dim-list li {\n",
       "  display: inline-block;\n",
       "  padding: 0;\n",
       "  margin: 0;\n",
       "}\n",
       "\n",
       ".xr-dim-list:before {\n",
       "  content: \"(\";\n",
       "}\n",
       "\n",
       ".xr-dim-list:after {\n",
       "  content: \")\";\n",
       "}\n",
       "\n",
       ".xr-dim-list li:not(:last-child):after {\n",
       "  content: \",\";\n",
       "  padding-right: 5px;\n",
       "}\n",
       "\n",
       ".xr-has-index {\n",
       "  font-weight: bold;\n",
       "}\n",
       "\n",
       ".xr-var-list,\n",
       ".xr-var-item {\n",
       "  display: contents;\n",
       "}\n",
       "\n",
       ".xr-var-item > div,\n",
       ".xr-var-item label,\n",
       ".xr-var-item > .xr-var-name span {\n",
       "  background-color: var(--xr-background-color-row-even);\n",
       "  border-color: var(--xr-background-color-row-odd);\n",
       "  margin-bottom: 0;\n",
       "  padding-top: 2px;\n",
       "}\n",
       "\n",
       ".xr-var-item > .xr-var-name:hover span {\n",
       "  padding-right: 5px;\n",
       "}\n",
       "\n",
       ".xr-var-list > li:nth-child(odd) > div,\n",
       ".xr-var-list > li:nth-child(odd) > label,\n",
       ".xr-var-list > li:nth-child(odd) > .xr-var-name span {\n",
       "  background-color: var(--xr-background-color-row-odd);\n",
       "  border-color: var(--xr-background-color-row-even);\n",
       "}\n",
       "\n",
       ".xr-var-name {\n",
       "  grid-column: 1;\n",
       "}\n",
       "\n",
       ".xr-var-dims {\n",
       "  grid-column: 2;\n",
       "}\n",
       "\n",
       ".xr-var-dtype {\n",
       "  grid-column: 3;\n",
       "  text-align: right;\n",
       "  color: var(--xr-font-color2);\n",
       "}\n",
       "\n",
       ".xr-var-preview {\n",
       "  grid-column: 4;\n",
       "}\n",
       "\n",
       ".xr-index-preview {\n",
       "  grid-column: 2 / 5;\n",
       "  color: var(--xr-font-color2);\n",
       "}\n",
       "\n",
       ".xr-var-name,\n",
       ".xr-var-dims,\n",
       ".xr-var-dtype,\n",
       ".xr-preview,\n",
       ".xr-attrs dt {\n",
       "  white-space: nowrap;\n",
       "  overflow: hidden;\n",
       "  text-overflow: ellipsis;\n",
       "  padding-right: 10px;\n",
       "}\n",
       "\n",
       ".xr-var-name:hover,\n",
       ".xr-var-dims:hover,\n",
       ".xr-var-dtype:hover,\n",
       ".xr-attrs dt:hover {\n",
       "  overflow: visible;\n",
       "  width: auto;\n",
       "  z-index: 1;\n",
       "}\n",
       "\n",
       ".xr-var-attrs,\n",
       ".xr-var-data,\n",
       ".xr-index-data {\n",
       "  display: none;\n",
       "  border-top: 2px dotted var(--xr-background-color);\n",
       "  padding-bottom: 20px !important;\n",
       "  padding-top: 10px !important;\n",
       "}\n",
       "\n",
       ".xr-var-attrs-in + label,\n",
       ".xr-var-data-in + label,\n",
       ".xr-index-data-in + label {\n",
       "  padding: 0 1px;\n",
       "}\n",
       "\n",
       ".xr-var-attrs-in:checked ~ .xr-var-attrs,\n",
       ".xr-var-data-in:checked ~ .xr-var-data,\n",
       ".xr-index-data-in:checked ~ .xr-index-data {\n",
       "  display: block;\n",
       "}\n",
       "\n",
       ".xr-var-data > table {\n",
       "  float: right;\n",
       "}\n",
       "\n",
       ".xr-var-data > pre,\n",
       ".xr-index-data > pre,\n",
       ".xr-var-data > table > tbody > tr {\n",
       "  background-color: transparent !important;\n",
       "}\n",
       "\n",
       ".xr-var-name span,\n",
       ".xr-var-data,\n",
       ".xr-index-name div,\n",
       ".xr-index-data,\n",
       ".xr-attrs {\n",
       "  padding-left: 25px !important;\n",
       "}\n",
       "\n",
       ".xr-attrs,\n",
       ".xr-var-attrs,\n",
       ".xr-var-data,\n",
       ".xr-index-data {\n",
       "  grid-column: 1 / -1;\n",
       "}\n",
       "\n",
       "dl.xr-attrs {\n",
       "  padding: 0;\n",
       "  margin: 0;\n",
       "  display: grid;\n",
       "  grid-template-columns: 125px auto;\n",
       "}\n",
       "\n",
       ".xr-attrs dt,\n",
       ".xr-attrs dd {\n",
       "  padding: 0;\n",
       "  margin: 0;\n",
       "  float: left;\n",
       "  padding-right: 10px;\n",
       "  width: auto;\n",
       "}\n",
       "\n",
       ".xr-attrs dt {\n",
       "  font-weight: normal;\n",
       "  grid-column: 1;\n",
       "}\n",
       "\n",
       ".xr-attrs dt:hover span {\n",
       "  display: inline-block;\n",
       "  background: var(--xr-background-color);\n",
       "  padding-right: 10px;\n",
       "}\n",
       "\n",
       ".xr-attrs dd {\n",
       "  grid-column: 2;\n",
       "  white-space: pre-wrap;\n",
       "  word-break: break-all;\n",
       "}\n",
       "\n",
       ".xr-icon-database,\n",
       ".xr-icon-file-text2,\n",
       ".xr-no-icon {\n",
       "  display: inline-block;\n",
       "  vertical-align: middle;\n",
       "  width: 1em;\n",
       "  height: 1.5em !important;\n",
       "  stroke-width: 0;\n",
       "  stroke: currentColor;\n",
       "  fill: currentColor;\n",
       "}\n",
       "\n",
       ".xr-var-attrs-in:checked + label > .xr-icon-file-text2,\n",
       ".xr-var-data-in:checked + label > .xr-icon-database,\n",
       ".xr-index-data-in:checked + label > .xr-icon-database {\n",
       "  color: var(--xr-font-color0);\n",
       "  filter: drop-shadow(1px 1px 5px var(--xr-font-color2));\n",
       "  stroke-width: 0.8px;\n",
       "}\n",
       "</style><pre class='xr-text-repr-fallback'>&lt;xarray.DataArray &#x27;TAUX&#x27; (time: 331, lat: 48, lon: 96)&gt; Size: 6MB\n",
       "array([[[ 5.10450591e-05,  5.18134948e-05,  5.99798077e-05, ...,\n",
       "          4.81087372e-05,  4.97101246e-05,  5.02332114e-05],\n",
       "        [ 2.14425003e-04,  1.95624903e-04,  2.08451165e-04, ...,\n",
       "          3.49386333e-04,  3.33110220e-04,  2.49810342e-04],\n",
       "        [-3.95152565e-05,  4.56098314e-05,  2.21791925e-05, ...,\n",
       "         -1.87366182e-04, -2.32328413e-04, -1.83355573e-04],\n",
       "        ...,\n",
       "        [ 3.67939938e-05,  6.16335747e-05,  1.45364960e-04, ...,\n",
       "          4.38142815e-05,  1.96355813e-05,  9.14590510e-06],\n",
       "        [-1.32776288e-04, -1.63569217e-04, -1.99475238e-04, ...,\n",
       "          1.11605674e-04, -1.54792160e-05, -9.17616926e-05],\n",
       "        [-3.57147801e-04, -4.04267106e-04, -4.57073300e-04, ...,\n",
       "         -1.74723944e-04, -2.38730107e-04, -3.07781971e-04]],\n",
       "\n",
       "       [[ 2.10329075e-04,  2.50062876e-04,  2.93804478e-04, ...,\n",
       "          1.08186250e-04,  1.51773056e-04,  1.85275640e-04],\n",
       "        [-6.66774940e-05, -4.81026946e-05,  2.30521735e-07, ...,\n",
       "          3.40682454e-05,  8.84647015e-05,  2.58643795e-05],\n",
       "        [-6.15855388e-04, -6.20767009e-04, -3.96133313e-04, ...,\n",
       "         -2.94935744e-04, -7.15513539e-04, -7.88269739e-04],\n",
       "...\n",
       "         -6.82737678e-04,  8.02739523e-05, -2.40611353e-05],\n",
       "        [ 1.15142774e-03,  9.59379657e-04,  7.72264320e-04, ...,\n",
       "          1.47467293e-03,  1.37762388e-03,  1.31950423e-03],\n",
       "        [ 1.28362037e-04, -1.37335155e-05, -2.19390960e-04, ...,\n",
       "          6.13911310e-04,  4.58224589e-04,  2.73599144e-04]],\n",
       "\n",
       "       [[ 1.92900677e-03,  2.05150456e-03,  2.22293055e-03, ...,\n",
       "          1.91230874e-03,  2.06965813e-03,  2.00040266e-03],\n",
       "        [-3.23335640e-04, -3.75525560e-04, -1.84311997e-04, ...,\n",
       "         -1.47142634e-03, -7.28897750e-04, -3.95065174e-04],\n",
       "        [-1.57261826e-03, -1.74162444e-03, -2.04971898e-03, ...,\n",
       "         -4.11399081e-03, -2.54853070e-03, -1.97193027e-03],\n",
       "        ...,\n",
       "        [ 2.74172984e-04,  5.30743971e-04,  5.41055575e-04, ...,\n",
       "         -9.31491144e-04, -3.21785454e-04, -4.92008403e-05],\n",
       "        [ 1.08909048e-03,  1.60624273e-03,  2.05437373e-03, ...,\n",
       "         -6.52819872e-05,  2.50115991e-04,  6.12974167e-04],\n",
       "        [ 1.33645814e-03,  1.47437770e-03,  1.65203959e-03, ...,\n",
       "          8.77983868e-04,  9.94058326e-04,  1.17220916e-03]]],\n",
       "      shape=(331, 48, 96), dtype=float32)\n",
       "Coordinates:\n",
       "  * time     (time) object 3kB 7676-12-31 00:00:00 ... 8006-12-31 00:00:00\n",
       "  * lat      (lat) float64 384B -87.16 -83.48 -79.78 ... 79.78 83.48 87.16\n",
       "  * lon      (lon) float64 768B 0.0 3.75 7.5 11.25 ... 345.0 348.8 352.5 356.2\n",
       "Attributes:\n",
       "    units:         N/m2\n",
       "    long_name:     Zonal surface stress\n",
       "    cell_methods:  time: mean</pre><div class='xr-wrap' style='display:none'><div class='xr-header'><div class='xr-obj-type'>xarray.DataArray</div><div class='xr-obj-name'>&#x27;TAUX&#x27;</div><ul class='xr-dim-list'><li><span class='xr-has-index'>time</span>: 331</li><li><span class='xr-has-index'>lat</span>: 48</li><li><span class='xr-has-index'>lon</span>: 96</li></ul></div><ul class='xr-sections'><li class='xr-section-item'><div class='xr-array-wrap'><input id='section-eb9aaee0-aaaa-489c-87bf-32a59d2ea1b4' class='xr-array-in' type='checkbox' checked><label for='section-eb9aaee0-aaaa-489c-87bf-32a59d2ea1b4' title='Show/hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-array-preview xr-preview'><span>5.105e-05 5.181e-05 5.998e-05 5.38e-05 ... 0.000878 0.0009941 0.001172</span></div><div class='xr-array-data'><pre>array([[[ 5.10450591e-05,  5.18134948e-05,  5.99798077e-05, ...,\n",
       "          4.81087372e-05,  4.97101246e-05,  5.02332114e-05],\n",
       "        [ 2.14425003e-04,  1.95624903e-04,  2.08451165e-04, ...,\n",
       "          3.49386333e-04,  3.33110220e-04,  2.49810342e-04],\n",
       "        [-3.95152565e-05,  4.56098314e-05,  2.21791925e-05, ...,\n",
       "         -1.87366182e-04, -2.32328413e-04, -1.83355573e-04],\n",
       "        ...,\n",
       "        [ 3.67939938e-05,  6.16335747e-05,  1.45364960e-04, ...,\n",
       "          4.38142815e-05,  1.96355813e-05,  9.14590510e-06],\n",
       "        [-1.32776288e-04, -1.63569217e-04, -1.99475238e-04, ...,\n",
       "          1.11605674e-04, -1.54792160e-05, -9.17616926e-05],\n",
       "        [-3.57147801e-04, -4.04267106e-04, -4.57073300e-04, ...,\n",
       "         -1.74723944e-04, -2.38730107e-04, -3.07781971e-04]],\n",
       "\n",
       "       [[ 2.10329075e-04,  2.50062876e-04,  2.93804478e-04, ...,\n",
       "          1.08186250e-04,  1.51773056e-04,  1.85275640e-04],\n",
       "        [-6.66774940e-05, -4.81026946e-05,  2.30521735e-07, ...,\n",
       "          3.40682454e-05,  8.84647015e-05,  2.58643795e-05],\n",
       "        [-6.15855388e-04, -6.20767009e-04, -3.96133313e-04, ...,\n",
       "         -2.94935744e-04, -7.15513539e-04, -7.88269739e-04],\n",
       "...\n",
       "         -6.82737678e-04,  8.02739523e-05, -2.40611353e-05],\n",
       "        [ 1.15142774e-03,  9.59379657e-04,  7.72264320e-04, ...,\n",
       "          1.47467293e-03,  1.37762388e-03,  1.31950423e-03],\n",
       "        [ 1.28362037e-04, -1.37335155e-05, -2.19390960e-04, ...,\n",
       "          6.13911310e-04,  4.58224589e-04,  2.73599144e-04]],\n",
       "\n",
       "       [[ 1.92900677e-03,  2.05150456e-03,  2.22293055e-03, ...,\n",
       "          1.91230874e-03,  2.06965813e-03,  2.00040266e-03],\n",
       "        [-3.23335640e-04, -3.75525560e-04, -1.84311997e-04, ...,\n",
       "         -1.47142634e-03, -7.28897750e-04, -3.95065174e-04],\n",
       "        [-1.57261826e-03, -1.74162444e-03, -2.04971898e-03, ...,\n",
       "         -4.11399081e-03, -2.54853070e-03, -1.97193027e-03],\n",
       "        ...,\n",
       "        [ 2.74172984e-04,  5.30743971e-04,  5.41055575e-04, ...,\n",
       "         -9.31491144e-04, -3.21785454e-04, -4.92008403e-05],\n",
       "        [ 1.08909048e-03,  1.60624273e-03,  2.05437373e-03, ...,\n",
       "         -6.52819872e-05,  2.50115991e-04,  6.12974167e-04],\n",
       "        [ 1.33645814e-03,  1.47437770e-03,  1.65203959e-03, ...,\n",
       "          8.77983868e-04,  9.94058326e-04,  1.17220916e-03]]],\n",
       "      shape=(331, 48, 96), dtype=float32)</pre></div></div></li><li class='xr-section-item'><input id='section-2a635bc7-5fd4-4b6b-8021-a3bac7ec516b' class='xr-section-summary-in' type='checkbox'  checked><label for='section-2a635bc7-5fd4-4b6b-8021-a3bac7ec516b' class='xr-section-summary' >Coordinates: <span>(3)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><ul class='xr-var-list'><li class='xr-var-item'><div class='xr-var-name'><span class='xr-has-index'>time</span></div><div class='xr-var-dims'>(time)</div><div class='xr-var-dtype'>object</div><div class='xr-var-preview xr-preview'>7676-12-31 00:00:00 ... 8006-12-...</div><input id='attrs-142b3ffe-a813-4fbc-a9b9-8693e032db02' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-142b3ffe-a813-4fbc-a9b9-8693e032db02' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-b850144f-6081-4958-abea-575cc394ad4d' class='xr-var-data-in' type='checkbox'><label for='data-b850144f-6081-4958-abea-575cc394ad4d' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'><dt><span>long_name :</span></dt><dd>time</dd><dt><span>bounds :</span></dt><dd>time_bnds</dd></dl></div><div class='xr-var-data'><pre>array([cftime.DatetimeNoLeap(7676, 12, 31, 0, 0, 0, 0, has_year_zero=True),\n",
       "       cftime.DatetimeNoLeap(7677, 12, 31, 0, 0, 0, 0, has_year_zero=True),\n",
       "       cftime.DatetimeNoLeap(7678, 12, 31, 0, 0, 0, 0, has_year_zero=True),\n",
       "       ...,\n",
       "       cftime.DatetimeNoLeap(8004, 12, 31, 0, 0, 0, 0, has_year_zero=True),\n",
       "       cftime.DatetimeNoLeap(8005, 12, 31, 0, 0, 0, 0, has_year_zero=True),\n",
       "       cftime.DatetimeNoLeap(8006, 12, 31, 0, 0, 0, 0, has_year_zero=True)],\n",
       "      shape=(331,), dtype=object)</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span class='xr-has-index'>lat</span></div><div class='xr-var-dims'>(lat)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>-87.16 -83.48 ... 83.48 87.16</div><input id='attrs-3baa08ce-2ecd-4a0b-be4e-063a14b7d8bf' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-3baa08ce-2ecd-4a0b-be4e-063a14b7d8bf' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-2da575e7-96bf-4e5c-b8ea-db42b794a43b' class='xr-var-data-in' type='checkbox'><label for='data-2da575e7-96bf-4e5c-b8ea-db42b794a43b' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'><dt><span>long_name :</span></dt><dd>latitude</dd><dt><span>units :</span></dt><dd>degrees_north</dd></dl></div><div class='xr-var-data'><pre>array([-87.159095, -83.478937, -79.777046, -76.070244, -72.361581, -68.652017,\n",
       "       -64.941949, -61.231573, -57.520994, -53.810274, -50.099453, -46.388558,\n",
       "       -42.677606, -38.96661 , -35.25558 , -31.544523, -27.833444, -24.122348,\n",
       "       -20.411238, -16.700118, -12.988989,  -9.277853,  -5.566714,  -1.855571,\n",
       "         1.855571,   5.566714,   9.277853,  12.988989,  16.700118,  20.411238,\n",
       "        24.122348,  27.833444,  31.544523,  35.25558 ,  38.96661 ,  42.677606,\n",
       "        46.388558,  50.099453,  53.810274,  57.520994,  61.231573,  64.941949,\n",
       "        68.652017,  72.361581,  76.070244,  79.777046,  83.478937,  87.159095])</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span class='xr-has-index'>lon</span></div><div class='xr-var-dims'>(lon)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>0.0 3.75 7.5 ... 348.8 352.5 356.2</div><input id='attrs-30d68cc2-5c1f-467c-89c4-994d93dd0cc7' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-30d68cc2-5c1f-467c-89c4-994d93dd0cc7' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-ecb01029-f5ae-4122-b637-123a01f7616d' class='xr-var-data-in' type='checkbox'><label for='data-ecb01029-f5ae-4122-b637-123a01f7616d' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'><dt><span>long_name :</span></dt><dd>longitude</dd><dt><span>units :</span></dt><dd>degrees_east</dd></dl></div><div class='xr-var-data'><pre>array([  0.  ,   3.75,   7.5 ,  11.25,  15.  ,  18.75,  22.5 ,  26.25,  30.  ,\n",
       "        33.75,  37.5 ,  41.25,  45.  ,  48.75,  52.5 ,  56.25,  60.  ,  63.75,\n",
       "        67.5 ,  71.25,  75.  ,  78.75,  82.5 ,  86.25,  90.  ,  93.75,  97.5 ,\n",
       "       101.25, 105.  , 108.75, 112.5 , 116.25, 120.  , 123.75, 127.5 , 131.25,\n",
       "       135.  , 138.75, 142.5 , 146.25, 150.  , 153.75, 157.5 , 161.25, 165.  ,\n",
       "       168.75, 172.5 , 176.25, 180.  , 183.75, 187.5 , 191.25, 195.  , 198.75,\n",
       "       202.5 , 206.25, 210.  , 213.75, 217.5 , 221.25, 225.  , 228.75, 232.5 ,\n",
       "       236.25, 240.  , 243.75, 247.5 , 251.25, 255.  , 258.75, 262.5 , 266.25,\n",
       "       270.  , 273.75, 277.5 , 281.25, 285.  , 288.75, 292.5 , 296.25, 300.  ,\n",
       "       303.75, 307.5 , 311.25, 315.  , 318.75, 322.5 , 326.25, 330.  , 333.75,\n",
       "       337.5 , 341.25, 345.  , 348.75, 352.5 , 356.25])</pre></div></li></ul></div></li><li class='xr-section-item'><input id='section-dac9cb2c-9456-444d-966b-f6406c2d8853' class='xr-section-summary-in' type='checkbox'  checked><label for='section-dac9cb2c-9456-444d-966b-f6406c2d8853' class='xr-section-summary' >Attributes: <span>(3)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><dl class='xr-attrs'><dt><span>units :</span></dt><dd>N/m2</dd><dt><span>long_name :</span></dt><dd>Zonal surface stress</dd><dt><span>cell_methods :</span></dt><dd>time: mean</dd></dl></div></li></ul></div></div>"
      ],
      "text/plain": [
       "<xarray.DataArray 'TAUX' (time: 331, lat: 48, lon: 96)> Size: 6MB\n",
       "array([[[ 5.10450591e-05,  5.18134948e-05,  5.99798077e-05, ...,\n",
       "          4.81087372e-05,  4.97101246e-05,  5.02332114e-05],\n",
       "        [ 2.14425003e-04,  1.95624903e-04,  2.08451165e-04, ...,\n",
       "          3.49386333e-04,  3.33110220e-04,  2.49810342e-04],\n",
       "        [-3.95152565e-05,  4.56098314e-05,  2.21791925e-05, ...,\n",
       "         -1.87366182e-04, -2.32328413e-04, -1.83355573e-04],\n",
       "        ...,\n",
       "        [ 3.67939938e-05,  6.16335747e-05,  1.45364960e-04, ...,\n",
       "          4.38142815e-05,  1.96355813e-05,  9.14590510e-06],\n",
       "        [-1.32776288e-04, -1.63569217e-04, -1.99475238e-04, ...,\n",
       "          1.11605674e-04, -1.54792160e-05, -9.17616926e-05],\n",
       "        [-3.57147801e-04, -4.04267106e-04, -4.57073300e-04, ...,\n",
       "         -1.74723944e-04, -2.38730107e-04, -3.07781971e-04]],\n",
       "\n",
       "       [[ 2.10329075e-04,  2.50062876e-04,  2.93804478e-04, ...,\n",
       "          1.08186250e-04,  1.51773056e-04,  1.85275640e-04],\n",
       "        [-6.66774940e-05, -4.81026946e-05,  2.30521735e-07, ...,\n",
       "          3.40682454e-05,  8.84647015e-05,  2.58643795e-05],\n",
       "        [-6.15855388e-04, -6.20767009e-04, -3.96133313e-04, ...,\n",
       "         -2.94935744e-04, -7.15513539e-04, -7.88269739e-04],\n",
       "...\n",
       "         -6.82737678e-04,  8.02739523e-05, -2.40611353e-05],\n",
       "        [ 1.15142774e-03,  9.59379657e-04,  7.72264320e-04, ...,\n",
       "          1.47467293e-03,  1.37762388e-03,  1.31950423e-03],\n",
       "        [ 1.28362037e-04, -1.37335155e-05, -2.19390960e-04, ...,\n",
       "          6.13911310e-04,  4.58224589e-04,  2.73599144e-04]],\n",
       "\n",
       "       [[ 1.92900677e-03,  2.05150456e-03,  2.22293055e-03, ...,\n",
       "          1.91230874e-03,  2.06965813e-03,  2.00040266e-03],\n",
       "        [-3.23335640e-04, -3.75525560e-04, -1.84311997e-04, ...,\n",
       "         -1.47142634e-03, -7.28897750e-04, -3.95065174e-04],\n",
       "        [-1.57261826e-03, -1.74162444e-03, -2.04971898e-03, ...,\n",
       "         -4.11399081e-03, -2.54853070e-03, -1.97193027e-03],\n",
       "        ...,\n",
       "        [ 2.74172984e-04,  5.30743971e-04,  5.41055575e-04, ...,\n",
       "         -9.31491144e-04, -3.21785454e-04, -4.92008403e-05],\n",
       "        [ 1.08909048e-03,  1.60624273e-03,  2.05437373e-03, ...,\n",
       "         -6.52819872e-05,  2.50115991e-04,  6.12974167e-04],\n",
       "        [ 1.33645814e-03,  1.47437770e-03,  1.65203959e-03, ...,\n",
       "          8.77983868e-04,  9.94058326e-04,  1.17220916e-03]]],\n",
       "      shape=(331, 48, 96), dtype=float32)\n",
       "Coordinates:\n",
       "  * time     (time) object 3kB 7676-12-31 00:00:00 ... 8006-12-31 00:00:00\n",
       "  * lat      (lat) float64 384B -87.16 -83.48 -79.78 ... 79.78 83.48 87.16\n",
       "  * lon      (lon) float64 768B 0.0 3.75 7.5 11.25 ... 345.0 348.8 352.5 356.2\n",
       "Attributes:\n",
       "    units:         N/m2\n",
       "    long_name:     Zonal surface stress\n",
       "    cell_methods:  time: mean"
      ]
     },
     "execution_count": 58,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "taux_dataset"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "id": "a3d3abc9",
   "metadata": {},
   "outputs": [],
   "source": [
    "def plot_taux_timeseries(time_index):\n",
    "    # Create figure with slightly more width to accommodate colorbar\n",
    "    fig = plt.figure(figsize=(22, 3))\n",
    "\n",
    "    # Create GridSpec to have better control over subplot layout\n",
    "    gs = fig.add_gridspec(1, 11, width_ratios=[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.05])\n",
    "\n",
    "    # Create axes for the maps\n",
    "    axes = []\n",
    "    for i in range(10):\n",
    "        ax = fig.add_subplot(gs[0, i], projection=ccrs.NorthPolarStereo())\n",
    "        axes.append(ax)\n",
    "\n",
    "    # Create axis for colorbar with the same position as the last plot\n",
    "    cax = fig.add_subplot(gs[0, -1])\n",
    "\n",
    "    iy = 0\n",
    "    for i, ax in enumerate(axes):\n",
    "        time_index = 24 + i\n",
    "        pvar = taux_dataset[time_index, :, :]\n",
    "        im = pvar.plot.contourf(ax=ax, transform=ccrs.PlateCarree(), \n",
    "                               cmap=ocm.cm.balance, levels=np.linspace(-1e-1, 1e-1, 21), \n",
    "                               extend='both', add_colorbar=False)\n",
    "        ax.set_extent([-180, 180, 45, 90], crs=ccrs.PlateCarree())\n",
    "        ax.coastlines()\n",
    "        year = 7700 + iy\n",
    "        ax.set_title(f'TAUX Year: {year}')\n",
    "        iy += 1\n",
    "\n",
    "    # Get the position of the last plot\n",
    "    last_plot_pos = axes[-1].get_position()\n",
    "\n",
    "    # Set colorbar position to match the last plot's height\n",
    "    cax.set_position([cax.get_position().x0,\n",
    "                     last_plot_pos.y0,\n",
    "                     cax.get_position().width,\n",
    "                     last_plot_pos.height])\n",
    "\n",
    "    # Add colorbar using the adjusted cax\n",
    "    cbar = fig.colorbar(im, cax=cax, orientation='vertical')\n",
    "    # Units on colorbar are in N/m^2\n",
    "    cbar.set_label('Zonal Windstress (N m$^{-2}$)')\n",
    "    plt.tight_layout()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 60,
   "id": "4ad91806",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 369752 characters]",
      "text/plain": [
       "<Figure size 2200x300 with 11 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plot_taux_timeseries(0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "id": "ea3e5bd2",
   "metadata": {},
   "outputs": [],
   "source": [
    "ts_directory = '/scratch/pproc/eq500tg7701_ens/'\n",
    "# Load the datasets into xarray\n",
    "ts_dataset = xr.open_dataset(os.path.join(ts_directory, \"cesmi6gat31rblc230iveq-noeq500tg7701_atm_TS_ncea.nc\"), decode_times=time_coder, decode_timedelta=True).TS.resample(time='YE').mean()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "id": "3f523913",
   "metadata": {},
   "outputs": [],
   "source": [
    "def plot_ts_timeseries(time_index):\n",
    "    # Create figure with slightly more width to accommodate colorbar\n",
    "    fig = plt.figure(figsize=(22, 3))\n",
    "\n",
    "    # Create GridSpec to have better control over subplot layout\n",
    "    gs = fig.add_gridspec(1, 11, width_ratios=[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.05])\n",
    "\n",
    "    # Create axes for the maps\n",
    "    axes = []\n",
    "    for i in range(10):\n",
    "        ax = fig.add_subplot(gs[0, i], projection=ccrs.NorthPolarStereo())\n",
    "        axes.append(ax)\n",
    "\n",
    "    # Create axis for colorbar with the same position as the last plot\n",
    "    cax = fig.add_subplot(gs[0, -1])\n",
    "\n",
    "    iy = 0\n",
    "    for i, ax in enumerate(axes):\n",
    "        time_index = 24 + i\n",
    "        pvar = ts_dataset[time_index, :, :]\n",
    "        im = pvar.plot.contourf(ax=ax, transform=ccrs.PlateCarree(), \n",
    "                               cmap=ocm.cm.balance, levels=np.linspace(-10, 10, 21), \n",
    "                               extend='both', add_colorbar=False)\n",
    "        ax.set_extent([-180, 180, 45, 90], crs=ccrs.PlateCarree())\n",
    "        ax.coastlines()\n",
    "        year = 7700 + iy\n",
    "        ax.set_title(f'TS Year: {year}')\n",
    "        iy += 1\n",
    "\n",
    "    # Get the position of the last plot\n",
    "    last_plot_pos = axes[-1].get_position()\n",
    "\n",
    "    # Set colorbar position to match the last plot's height\n",
    "    cax.set_position([cax.get_position().x0,\n",
    "                     last_plot_pos.y0,\n",
    "                     cax.get_position().width,\n",
    "                     last_plot_pos.height])\n",
    "\n",
    "    # Add colorbar using the adjusted cax\n",
    "    cbar = fig.colorbar(im, cax=cax, orientation='vertical')\n",
    "    # Units on colorbar are in N/m^2\n",
    "    cbar.set_label('Surface Air Temperature (K)')\n",
    "    plt.tight_layout()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "id": "1c455d79",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 376620 characters]",
      "text/plain": [
       "<Figure size 2200x300 with 11 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plot_ts_timeseries(0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "id": "4473a026",
   "metadata": {},
   "outputs": [],
   "source": [
    "psl_directory = '/scratch/pproc/eq500tg7701_ens/'\n",
    "# Load the datasets into xarray\n",
    "psl_dataset = xr.open_dataset(os.path.join(psl_directory, \"cesmi6gat31rblc230iveq-noeq500tg7701_atm_PSL_ncea.nc\"), decode_times=time_coder, decode_timedelta=True).PSL.resample(time='YE').mean()\n",
    "def plot_psl_timeseries(time_index):\n",
    "    # Create figure with slightly more width to accommodate colorbar\n",
    "    fig = plt.figure(figsize=(22, 3))\n",
    "\n",
    "    # Create GridSpec to have better control over subplot layout\n",
    "    gs = fig.add_gridspec(1, 11, width_ratios=[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.05])\n",
    "\n",
    "    # Create axes for the maps\n",
    "    axes = []\n",
    "    for i in range(10):\n",
    "        ax = fig.add_subplot(gs[0, i], projection=ccrs.NorthPolarStereo())\n",
    "        axes.append(ax)\n",
    "\n",
    "    # Create axis for colorbar with the same position as the last plot\n",
    "    cax = fig.add_subplot(gs[0, -1])\n",
    "\n",
    "    iy = 0\n",
    "    for i, ax in enumerate(axes):\n",
    "        time_index = 24 + i\n",
    "        pvar = ts_dataset[time_index, :, :]\n",
    "        im = pvar.plot.contourf(ax=ax, transform=ccrs.PlateCarree(), \n",
    "                               cmap=ocm.cm.curl, levels=np.linspace(-10, 10, 21), \n",
    "                               extend='both', add_colorbar=False)\n",
    "        ax.set_extent([-180, 180, 45, 90], crs=ccrs.PlateCarree())\n",
    "        ax.coastlines()\n",
    "        year = 7700 + iy\n",
    "        ax.set_title(f'PSL Year: {year}')\n",
    "        iy += 1\n",
    "\n",
    "    # Get the position of the last plot\n",
    "    last_plot_pos = axes[-1].get_position()\n",
    "\n",
    "    # Set colorbar position to match the last plot's height\n",
    "    cax.set_position([cax.get_position().x0,\n",
    "                     last_plot_pos.y0,\n",
    "                     cax.get_position().width,\n",
    "                     last_plot_pos.height])\n",
    "\n",
    "    # Add colorbar using the adjusted cax\n",
    "    cbar = fig.colorbar(im, cax=cax, orientation='vertical')\n",
    "    # Units on colorbar are in N/m^2\n",
    "    cbar.set_label('Mean Sea Level Pressure (Pa)')\n",
    "    plt.tight_layout()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "id": "b9fcf1ee",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 377720 characters]",
      "text/plain": [
       "<Figure size 2200x300 with 11 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plot_psl_timeseries(0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "id": "5237e3c6",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Define helper functions to load and process various atmospheric and oceanic variables\n",
    "# These functions standardize the loading process for multiple climate fields\n",
    "# All functions return annual-mean time series of ensemble-mean anomalies (volcanic - control)\n",
    "def load_atm_average_variable(directory, variable_name):\n",
    "    # Construct the file path\n",
    "    file_path = os.path.join(directory, f\"cesmi6gat31rblc230iveq-noeq500tg7701_atm_{variable_name}_ncea.nc\")\n",
    "    \n",
    "    # Load the dataset into xarray\n",
    "    dataset = xr.open_dataset(file_path, decode_times=time_coder, decode_timedelta=True)\n",
    "    \n",
    "    # Extract the variable and perform yearly averaging\n",
    "    variable_timeseries = dataset[variable_name].resample(time='YE').mean()\n",
    "    \n",
    "    return variable_timeseries\n",
    "def load_ocn_average_variable(directory, variable_name):\n",
    "    # Construct the file path\n",
    "    file_path = os.path.join(directory, f\"cesmi6gat31rblc230iveq-noeq500tg7701_ocn_{variable_name}_ncea.nc\")\n",
    "    \n",
    "    # Load the dataset into xarray\n",
    "    dataset = xr.open_dataset(file_path, decode_times=time_coder, decode_timedelta=True)\n",
    "    \n",
    "    # Extract the variable and perform yearly averaging\n",
    "    variable_timeseries = regridder(dataset[variable_name]).resample(time='YE').mean()\n",
    "    \n",
    "    return variable_timeseries\n",
    "def load_atm_average_volcvariable(directory, variable_name):\n",
    "    # Construct the file path\n",
    "    file_path = os.path.join(directory, f\"cesmi6gat31rblc230iveq500tg7701_ocn_{variable_name}_ncea.nc\")\n",
    "    \n",
    "    # Load the dataset into xarray\n",
    "    dataset = xr.open_dataset(file_path, decode_times=time_coder, decode_timedelta=True)\n",
    "    \n",
    "    # Extract the variable and perform yearly averaging\n",
    "    variable_timeseries = regridder(dataset[variable_name]).resample(time='YE').mean()\n",
    "    \n",
    "    return variable_timeseries\n",
    "def load_ocn_SSS_average(directory, variable_name):\n",
    "    # Construct the file path\n",
    "    file_path = os.path.join(directory, f\"cesmi6gat31rblc230iveq-noeq500tg7701_ocn_SSS_ncea.nc\")\n",
    "    \n",
    "    # Load the dataset into xarray\n",
    "    dataset = xr.open_dataset(file_path, decode_times=time_coder, decode_timedelta=True)\n",
    "    \n",
    "    # Extract the variable and perform yearly averaging\n",
    "    variable_timeseries = regridder(dataset['SALT']).resample(time='YE').mean()\n",
    "    \n",
    "    return variable_timeseries\n",
    "\n",
    "def load_ocn_MOC_average(directory, variable_name):\n",
    "    # Construct the file path\n",
    "    file_path = os.path.join(directory, f\"cesmi6gat31rblc230iveq-noeq500tg7701_ocn_MOC_ncea.nc\")\n",
    "    \n",
    "    # Load the dataset into xarray\n",
    "    dataset = xr.open_dataset(file_path, decode_times=time_coder, decode_timedelta=True)\n",
    "    \n",
    "    # Extract the variable and perform yearly averaging\n",
    "    variable_timeseries = dataset['MOC'].resample(time='YE').mean()\n",
    "    \n",
    "    return variable_timeseries\n",
    "\n",
    "# Usage\n",
    "\n",
    "# done manually above for calculation and regriding\n",
    "#prects  = ('PRECT')\n",
    "\n",
    "#qflxs  = ('QFLX')\n",
    "#roffs  = ('ROFF_F')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 67,
   "id": "9818a503",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Load all climate variables needed for Figure 6 analysis\n",
    "# Variables loaded:\n",
    "# - TS: Surface air temperature (K)\n",
    "# - PSL: Mean sea level pressure (Pa)\n",
    "# - SALT/SSS: Sea surface salinity (g/kg)\n",
    "# - ICEFRAC: Sea ice fraction (0-1)\n",
    "# - BSF: Barotropic stream function (Sv)\n",
    "# - TAUX, TAUY: Zonal and meridional wind stress (N/m²)\n",
    "# - HMXL: Mixed layer depth (cm)\n",
    "# - P_E_R: Net freshwater forcing (mm/day, calculated above)\n",
    "# Time periods for averaging (3 phases of volcanic response):\n",
    "# Period 1: 7701-7705 (years 0-5 post-eruption, immediate response)\n",
    "# Period 2: 7706-7715 (years 5-15 post-eruption, transition phase)\n",
    "\n",
    "# Period 3: 7716-7720 (years 15-20 post-eruption, recovery phase)\n",
    "# plt_years = [[7701,7705], [7706,7715], [7716,7720]]\n",
    "\n",
    "base_directory = '/scratch/pproc/eq500tg7701_ens/'\n",
    "# now I need to create an averaging over \n",
    "tsanom  = load_atm_average_variable(base_directory, 'TS')\n",
    "peranom = P_E_R_timeseries\n",
    "pslanom  = load_atm_average_variable(base_directory, 'PSL')\n",
    "# match variable names for P-E+R\n",
    "sssanom  = load_ocn_SSS_average(base_directory, 'SALT')\n",
    "hmxlanom  = load_ocn_average_variable(base_directory, 'HMXL')\n",
    "iceanom  = load_atm_average_variable(base_directory, 'ICEFRAC')\n",
    "tauyanom = load_atm_average_variable(base_directory, 'TAUY')\n",
    "bsfanom  = load_ocn_average_variable(base_directory, 'BSF')\n",
    "tauxanom = load_atm_average_variable(base_directory, 'TAUX')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "id": "24b731c1",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Load Atlantic Meridional Overturning Circulation (AMOC) data\n",
    "# Sum over all MOC components (Eulerian-mean + eddy-induced + submesoscale)\n",
    "\n",
    "# Select Atlantic basin (transport_reg=1) to focus on AMOC\n",
    "\n",
    "# Result: AMOC strength as function of depth (moc_z) and latitude (lat_aux_grid)\n",
    "mocanom  = load_ocn_MOC_average(base_directory, 'MOC').sum(dim='moc_comp').isel(transport_reg=1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "id": "c413d0b3",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><svg style=\"position: absolute; width: 0; height: 0; overflow: hidden\">\n",
       "<defs>\n",
       "<symbol id=\"icon-database\" viewBox=\"0 0 32 32\">\n",
       "<path d=\"M16 0c-8.837 0-16 2.239-16 5v4c0 2.761 7.163 5 16 5s16-2.239 16-5v-4c0-2.761-7.163-5-16-5z\"></path>\n",
       "<path d=\"M16 17c-8.837 0-16-2.239-16-5v6c0 2.761 7.163 5 16 5s16-2.239 16-5v-6c0 2.761-7.163 5-16 5z\"></path>\n",
       "<path d=\"M16 26c-8.837 0-16-2.239-16-5v6c0 2.761 7.163 5 16 5s16-2.239 16-5v-6c0 2.761-7.163 5-16 5z\"></path>\n",
       "</symbol>\n",
       "<symbol id=\"icon-file-text2\" viewBox=\"0 0 32 32\">\n",
       "<path d=\"M28.681 7.159c-0.694-0.947-1.662-2.053-2.724-3.116s-2.169-2.030-3.116-2.724c-1.612-1.182-2.393-1.319-2.841-1.319h-15.5c-1.378 0-2.5 1.121-2.5 2.5v27c0 1.378 1.122 2.5 2.5 2.5h23c1.378 0 2.5-1.122 2.5-2.5v-19.5c0-0.448-0.137-1.23-1.319-2.841zM24.543 5.457c0.959 0.959 1.712 1.825 2.268 2.543h-4.811v-4.811c0.718 0.556 1.584 1.309 2.543 2.268zM28 29.5c0 0.271-0.229 0.5-0.5 0.5h-23c-0.271 0-0.5-0.229-0.5-0.5v-27c0-0.271 0.229-0.5 0.5-0.5 0 0 15.499-0 15.5 0v7c0 0.552 0.448 1 1 1h7v19.5z\"></path>\n",
       "<path d=\"M23 26h-14c-0.552 0-1-0.448-1-1s0.448-1 1-1h14c0.552 0 1 0.448 1 1s-0.448 1-1 1z\"></path>\n",
       "<path d=\"M23 22h-14c-0.552 0-1-0.448-1-1s0.448-1 1-1h14c0.552 0 1 0.448 1 1s-0.448 1-1 1z\"></path>\n",
       "<path d=\"M23 18h-14c-0.552 0-1-0.448-1-1s0.448-1 1-1h14c0.552 0 1 0.448 1 1s-0.448 1-1 1z\"></path>\n",
       "</symbol>\n",
       "</defs>\n",
       "</svg>\n",
       "<style>/* CSS stylesheet for displaying xarray objects in notebooks */\n",
       "\n",
       ":root {\n",
       "  --xr-font-color0: var(\n",
       "    --jp-content-font-color0,\n",
       "    var(--pst-color-text-base rgba(0, 0, 0, 1))\n",
       "  );\n",
       "  --xr-font-color2: var(\n",
       "    --jp-content-font-color2,\n",
       "    var(--pst-color-text-base, rgba(0, 0, 0, 0.54))\n",
       "  );\n",
       "  --xr-font-color3: var(\n",
       "    --jp-content-font-color3,\n",
       "    var(--pst-color-text-base, rgba(0, 0, 0, 0.38))\n",
       "  );\n",
       "  --xr-border-color: var(\n",
       "    --jp-border-color2,\n",
       "    hsl(from var(--pst-color-on-background, white) h s calc(l - 10))\n",
       "  );\n",
       "  --xr-disabled-color: var(\n",
       "    --jp-layout-color3,\n",
       "    hsl(from var(--pst-color-on-background, white) h s calc(l - 40))\n",
       "  );\n",
       "  --xr-background-color: var(\n",
       "    --jp-layout-color0,\n",
       "    var(--pst-color-on-background, white)\n",
       "  );\n",
       "  --xr-background-color-row-even: var(\n",
       "    --jp-layout-color1,\n",
       "    hsl(from var(--pst-color-on-background, white) h s calc(l - 5))\n",
       "  );\n",
       "  --xr-background-color-row-odd: var(\n",
       "    --jp-layout-color2,\n",
       "    hsl(from var(--pst-color-on-background, white) h s calc(l - 15))\n",
       "  );\n",
       "}\n",
       "\n",
       "html[theme=\"dark\"],\n",
       "html[data-theme=\"dark\"],\n",
       "body[data-theme=\"dark\"],\n",
       "body.vscode-dark {\n",
       "  --xr-font-color0: var(\n",
       "    --jp-content-font-color0,\n",
       "    var(--pst-color-text-base, rgba(255, 255, 255, 1))\n",
       "  );\n",
       "  --xr-font-color2: var(\n",
       "    --jp-content-font-color2,\n",
       "    var(--pst-color-text-base, rgba(255, 255, 255, 0.54))\n",
       "  );\n",
       "  --xr-font-color3: var(\n",
       "    --jp-content-font-color3,\n",
       "    var(--pst-color-text-base, rgba(255, 255, 255, 0.38))\n",
       "  );\n",
       "  --xr-border-color: var(\n",
       "    --jp-border-color2,\n",
       "    hsl(from var(--pst-color-on-background, #111111) h s calc(l + 10))\n",
       "  );\n",
       "  --xr-disabled-color: var(\n",
       "    --jp-layout-color3,\n",
       "    hsl(from var(--pst-color-on-background, #111111) h s calc(l + 40))\n",
       "  );\n",
       "  --xr-background-color: var(\n",
       "    --jp-layout-color0,\n",
       "    var(--pst-color-on-background, #111111)\n",
       "  );\n",
       "  --xr-background-color-row-even: var(\n",
       "    --jp-layout-color1,\n",
       "    hsl(from var(--pst-color-on-background, #111111) h s calc(l + 5))\n",
       "  );\n",
       "  --xr-background-color-row-odd: var(\n",
       "    --jp-layout-color2,\n",
       "    hsl(from var(--pst-color-on-background, #111111) h s calc(l + 15))\n",
       "  );\n",
       "}\n",
       "\n",
       ".xr-wrap {\n",
       "  display: block !important;\n",
       "  min-width: 300px;\n",
       "  max-width: 700px;\n",
       "  line-height: 1.6;\n",
       "}\n",
       "\n",
       ".xr-text-repr-fallback {\n",
       "  /* fallback to plain text repr when CSS is not injected (untrusted notebook) */\n",
       "  display: none;\n",
       "}\n",
       "\n",
       ".xr-header {\n",
       "  padding-top: 6px;\n",
       "  padding-bottom: 6px;\n",
       "  margin-bottom: 4px;\n",
       "  border-bottom: solid 1px var(--xr-border-color);\n",
       "}\n",
       "\n",
       ".xr-header > div,\n",
       ".xr-header > ul {\n",
       "  display: inline;\n",
       "  margin-top: 0;\n",
       "  margin-bottom: 0;\n",
       "}\n",
       "\n",
       ".xr-obj-type,\n",
       ".xr-obj-name,\n",
       ".xr-group-name {\n",
       "  margin-left: 2px;\n",
       "  margin-right: 10px;\n",
       "}\n",
       "\n",
       ".xr-group-name::before {\n",
       "  content: \"📁\";\n",
       "  padding-right: 0.3em;\n",
       "}\n",
       "\n",
       ".xr-group-name,\n",
       ".xr-obj-type {\n",
       "  color: var(--xr-font-color2);\n",
       "}\n",
       "\n",
       ".xr-sections {\n",
       "  padding-left: 0 !important;\n",
       "  display: grid;\n",
       "  grid-template-columns: 150px auto auto 1fr 0 20px 0 20px;\n",
       "  margin-block-start: 0;\n",
       "  margin-block-end: 0;\n",
       "}\n",
       "\n",
       ".xr-section-item {\n",
       "  display: contents;\n",
       "}\n",
       "\n",
       ".xr-section-item input {\n",
       "  display: inline-block;\n",
       "  opacity: 0;\n",
       "  height: 0;\n",
       "  margin: 0;\n",
       "}\n",
       "\n",
       ".xr-section-item input + label {\n",
       "  color: var(--xr-disabled-color);\n",
       "  border: 2px solid transparent !important;\n",
       "}\n",
       "\n",
       ".xr-section-item input:enabled + label {\n",
       "  cursor: pointer;\n",
       "  color: var(--xr-font-color2);\n",
       "}\n",
       "\n",
       ".xr-section-item input:focus + label {\n",
       "  border: 2px solid var(--xr-font-color0) !important;\n",
       "}\n",
       "\n",
       ".xr-section-item input:enabled + label:hover {\n",
       "  color: var(--xr-font-color0);\n",
       "}\n",
       "\n",
       ".xr-section-summary {\n",
       "  grid-column: 1;\n",
       "  color: var(--xr-font-color2);\n",
       "  font-weight: 500;\n",
       "}\n",
       "\n",
       ".xr-section-summary > span {\n",
       "  display: inline-block;\n",
       "  padding-left: 0.5em;\n",
       "}\n",
       "\n",
       ".xr-section-summary-in:disabled + label {\n",
       "  color: var(--xr-font-color2);\n",
       "}\n",
       "\n",
       ".xr-section-summary-in + label:before {\n",
       "  display: inline-block;\n",
       "  content: \"►\";\n",
       "  font-size: 11px;\n",
       "  width: 15px;\n",
       "  text-align: center;\n",
       "}\n",
       "\n",
       ".xr-section-summary-in:disabled + label:before {\n",
       "  color: var(--xr-disabled-color);\n",
       "}\n",
       "\n",
       ".xr-section-summary-in:checked + label:before {\n",
       "  content: \"▼\";\n",
       "}\n",
       "\n",
       ".xr-section-summary-in:checked + label > span {\n",
       "  display: none;\n",
       "}\n",
       "\n",
       ".xr-section-summary,\n",
       ".xr-section-inline-details {\n",
       "  padding-top: 4px;\n",
       "}\n",
       "\n",
       ".xr-section-inline-details {\n",
       "  grid-column: 2 / -1;\n",
       "}\n",
       "\n",
       ".xr-section-details {\n",
       "  display: none;\n",
       "  grid-column: 1 / -1;\n",
       "  margin-top: 4px;\n",
       "  margin-bottom: 5px;\n",
       "}\n",
       "\n",
       ".xr-section-summary-in:checked ~ .xr-section-details {\n",
       "  display: contents;\n",
       "}\n",
       "\n",
       ".xr-group-box {\n",
       "  display: inline-grid;\n",
       "  grid-template-columns: 0px 20px auto;\n",
       "  width: 100%;\n",
       "}\n",
       "\n",
       ".xr-group-box-vline {\n",
       "  grid-column-start: 1;\n",
       "  border-right: 0.2em solid;\n",
       "  border-color: var(--xr-border-color);\n",
       "  width: 0px;\n",
       "}\n",
       "\n",
       ".xr-group-box-hline {\n",
       "  grid-column-start: 2;\n",
       "  grid-row-start: 1;\n",
       "  height: 1em;\n",
       "  width: 20px;\n",
       "  border-bottom: 0.2em solid;\n",
       "  border-color: var(--xr-border-color);\n",
       "}\n",
       "\n",
       ".xr-group-box-contents {\n",
       "  grid-column-start: 3;\n",
       "}\n",
       "\n",
       ".xr-array-wrap {\n",
       "  grid-column: 1 / -1;\n",
       "  display: grid;\n",
       "  grid-template-columns: 20px auto;\n",
       "}\n",
       "\n",
       ".xr-array-wrap > label {\n",
       "  grid-column: 1;\n",
       "  vertical-align: top;\n",
       "}\n",
       "\n",
       ".xr-preview {\n",
       "  color: var(--xr-font-color3);\n",
       "}\n",
       "\n",
       ".xr-array-preview,\n",
       ".xr-array-data {\n",
       "  padding: 0 5px !important;\n",
       "  grid-column: 2;\n",
       "}\n",
       "\n",
       ".xr-array-data,\n",
       ".xr-array-in:checked ~ .xr-array-preview {\n",
       "  display: none;\n",
       "}\n",
       "\n",
       ".xr-array-in:checked ~ .xr-array-data,\n",
       ".xr-array-preview {\n",
       "  display: inline-block;\n",
       "}\n",
       "\n",
       ".xr-dim-list {\n",
       "  display: inline-block !important;\n",
       "  list-style: none;\n",
       "  padding: 0 !important;\n",
       "  margin: 0;\n",
       "}\n",
       "\n",
       ".xr-dim-list li {\n",
       "  display: inline-block;\n",
       "  padding: 0;\n",
       "  margin: 0;\n",
       "}\n",
       "\n",
       ".xr-dim-list:before {\n",
       "  content: \"(\";\n",
       "}\n",
       "\n",
       ".xr-dim-list:after {\n",
       "  content: \")\";\n",
       "}\n",
       "\n",
       ".xr-dim-list li:not(:last-child):after {\n",
       "  content: \",\";\n",
       "  padding-right: 5px;\n",
       "}\n",
       "\n",
       ".xr-has-index {\n",
       "  font-weight: bold;\n",
       "}\n",
       "\n",
       ".xr-var-list,\n",
       ".xr-var-item {\n",
       "  display: contents;\n",
       "}\n",
       "\n",
       ".xr-var-item > div,\n",
       ".xr-var-item label,\n",
       ".xr-var-item > .xr-var-name span {\n",
       "  background-color: var(--xr-background-color-row-even);\n",
       "  border-color: var(--xr-background-color-row-odd);\n",
       "  margin-bottom: 0;\n",
       "  padding-top: 2px;\n",
       "}\n",
       "\n",
       ".xr-var-item > .xr-var-name:hover span {\n",
       "  padding-right: 5px;\n",
       "}\n",
       "\n",
       ".xr-var-list > li:nth-child(odd) > div,\n",
       ".xr-var-list > li:nth-child(odd) > label,\n",
       ".xr-var-list > li:nth-child(odd) > .xr-var-name span {\n",
       "  background-color: var(--xr-background-color-row-odd);\n",
       "  border-color: var(--xr-background-color-row-even);\n",
       "}\n",
       "\n",
       ".xr-var-name {\n",
       "  grid-column: 1;\n",
       "}\n",
       "\n",
       ".xr-var-dims {\n",
       "  grid-column: 2;\n",
       "}\n",
       "\n",
       ".xr-var-dtype {\n",
       "  grid-column: 3;\n",
       "  text-align: right;\n",
       "  color: var(--xr-font-color2);\n",
       "}\n",
       "\n",
       ".xr-var-preview {\n",
       "  grid-column: 4;\n",
       "}\n",
       "\n",
       ".xr-index-preview {\n",
       "  grid-column: 2 / 5;\n",
       "  color: var(--xr-font-color2);\n",
       "}\n",
       "\n",
       ".xr-var-name,\n",
       ".xr-var-dims,\n",
       ".xr-var-dtype,\n",
       ".xr-preview,\n",
       ".xr-attrs dt {\n",
       "  white-space: nowrap;\n",
       "  overflow: hidden;\n",
       "  text-overflow: ellipsis;\n",
       "  padding-right: 10px;\n",
       "}\n",
       "\n",
       ".xr-var-name:hover,\n",
       ".xr-var-dims:hover,\n",
       ".xr-var-dtype:hover,\n",
       ".xr-attrs dt:hover {\n",
       "  overflow: visible;\n",
       "  width: auto;\n",
       "  z-index: 1;\n",
       "}\n",
       "\n",
       ".xr-var-attrs,\n",
       ".xr-var-data,\n",
       ".xr-index-data {\n",
       "  display: none;\n",
       "  border-top: 2px dotted var(--xr-background-color);\n",
       "  padding-bottom: 20px !important;\n",
       "  padding-top: 10px !important;\n",
       "}\n",
       "\n",
       ".xr-var-attrs-in + label,\n",
       ".xr-var-data-in + label,\n",
       ".xr-index-data-in + label {\n",
       "  padding: 0 1px;\n",
       "}\n",
       "\n",
       ".xr-var-attrs-in:checked ~ .xr-var-attrs,\n",
       ".xr-var-data-in:checked ~ .xr-var-data,\n",
       ".xr-index-data-in:checked ~ .xr-index-data {\n",
       "  display: block;\n",
       "}\n",
       "\n",
       ".xr-var-data > table {\n",
       "  float: right;\n",
       "}\n",
       "\n",
       ".xr-var-data > pre,\n",
       ".xr-index-data > pre,\n",
       ".xr-var-data > table > tbody > tr {\n",
       "  background-color: transparent !important;\n",
       "}\n",
       "\n",
       ".xr-var-name span,\n",
       ".xr-var-data,\n",
       ".xr-index-name div,\n",
       ".xr-index-data,\n",
       ".xr-attrs {\n",
       "  padding-left: 25px !important;\n",
       "}\n",
       "\n",
       ".xr-attrs,\n",
       ".xr-var-attrs,\n",
       ".xr-var-data,\n",
       ".xr-index-data {\n",
       "  grid-column: 1 / -1;\n",
       "}\n",
       "\n",
       "dl.xr-attrs {\n",
       "  padding: 0;\n",
       "  margin: 0;\n",
       "  display: grid;\n",
       "  grid-template-columns: 125px auto;\n",
       "}\n",
       "\n",
       ".xr-attrs dt,\n",
       ".xr-attrs dd {\n",
       "  padding: 0;\n",
       "  margin: 0;\n",
       "  float: left;\n",
       "  padding-right: 10px;\n",
       "  width: auto;\n",
       "}\n",
       "\n",
       ".xr-attrs dt {\n",
       "  font-weight: normal;\n",
       "  grid-column: 1;\n",
       "}\n",
       "\n",
       ".xr-attrs dt:hover span {\n",
       "  display: inline-block;\n",
       "  background: var(--xr-background-color);\n",
       "  padding-right: 10px;\n",
       "}\n",
       "\n",
       ".xr-attrs dd {\n",
       "  grid-column: 2;\n",
       "  white-space: pre-wrap;\n",
       "  word-break: break-all;\n",
       "}\n",
       "\n",
       ".xr-icon-database,\n",
       ".xr-icon-file-text2,\n",
       ".xr-no-icon {\n",
       "  display: inline-block;\n",
       "  vertical-align: middle;\n",
       "  width: 1em;\n",
       "  height: 1.5em !important;\n",
       "  stroke-width: 0;\n",
       "  stroke: currentColor;\n",
       "  fill: currentColor;\n",
       "}\n",
       "\n",
       ".xr-var-attrs-in:checked + label > .xr-icon-file-text2,\n",
       ".xr-var-data-in:checked + label > .xr-icon-database,\n",
       ".xr-index-data-in:checked + label > .xr-icon-database {\n",
       "  color: var(--xr-font-color0);\n",
       "  filter: drop-shadow(1px 1px 5px var(--xr-font-color2));\n",
       "  stroke-width: 0.8px;\n",
       "}\n",
       "</style><pre class='xr-text-repr-fallback'>&lt;xarray.DataArray &#x27;MOC&#x27; (time: 325, moc_z: 61, lat_aux_grid: 105)&gt; Size: 8MB\n",
       "array([[[-3.24204541e-03, -3.24204541e-03, -3.24204541e-03, ...,\n",
       "          1.97343310e-04,  6.56600605e-05,  1.73003573e-05],\n",
       "        [-1.27978530e-02, -1.27978530e-02, -1.27978530e-02, ...,\n",
       "         -4.30338643e-03, -4.51596268e-03, -4.91895294e-03],\n",
       "        [-1.62455663e-02, -1.62455663e-02, -1.62455663e-02, ...,\n",
       "         -2.22288724e-03, -2.32393015e-03, -2.46941438e-03],\n",
       "        ...,\n",
       "        [ 0.00000000e+00,  0.00000000e+00,  0.00000000e+00, ...,\n",
       "         -3.03818894e-07, -3.03818894e-07, -3.03818894e-07],\n",
       "        [ 0.00000000e+00,  0.00000000e+00,  0.00000000e+00, ...,\n",
       "          2.58542315e-07,  2.58542315e-07,  2.58542315e-07],\n",
       "        [ 0.00000000e+00,  0.00000000e+00,  0.00000000e+00, ...,\n",
       "          0.00000000e+00,  0.00000000e+00,  0.00000000e+00]],\n",
       "\n",
       "       [[ 1.11201277e-03,  1.11201277e-03,  1.11201277e-03, ...,\n",
       "         -1.43123209e-04, -5.20096401e-05, -1.85315457e-05],\n",
       "        [ 1.90767013e-02,  1.90767013e-02,  1.90767013e-02, ...,\n",
       "          9.29078180e-03,  9.15022846e-03,  9.09731817e-03],\n",
       "        [ 3.88066322e-02,  3.88066322e-02,  3.88066322e-02, ...,\n",
       "          1.16502773e-02,  1.17193125e-02,  1.15378210e-02],\n",
       "...\n",
       "          1.97381027e-07,  1.97381027e-07,  1.97381027e-07],\n",
       "        [ 0.00000000e+00,  0.00000000e+00,  0.00000000e+00, ...,\n",
       "         -1.66932097e-07, -1.66932097e-07, -1.66932097e-07],\n",
       "        [ 0.00000000e+00,  0.00000000e+00,  0.00000000e+00, ...,\n",
       "          0.00000000e+00,  0.00000000e+00,  0.00000000e+00]],\n",
       "\n",
       "       [[-4.22286764e-02, -4.22286764e-02, -4.22286764e-02, ...,\n",
       "          1.43455889e-03,  2.92325858e-04, -1.26820989e-04],\n",
       "        [-1.68354213e-01, -1.68354213e-01, -1.68354213e-01, ...,\n",
       "          1.79322548e-02,  1.39369238e-02,  1.66624803e-02],\n",
       "        [-2.58173645e-01, -2.58173645e-01, -2.58173645e-01, ...,\n",
       "          3.39883529e-02,  2.85237785e-02,  3.14202905e-02],\n",
       "        ...,\n",
       "        [ 0.00000000e+00,  0.00000000e+00,  0.00000000e+00, ...,\n",
       "         -1.48887611e-05, -1.48887611e-05, -1.48887611e-05],\n",
       "        [ 0.00000000e+00,  0.00000000e+00,  0.00000000e+00, ...,\n",
       "          1.23312784e-05,  1.23312784e-05,  1.23312784e-05],\n",
       "        [ 0.00000000e+00,  0.00000000e+00,  0.00000000e+00, ...,\n",
       "          0.00000000e+00,  0.00000000e+00,  0.00000000e+00]]],\n",
       "      shape=(325, 61, 105), dtype=float32)\n",
       "Coordinates:\n",
       "  * time          (time) object 3kB 7676-12-31 00:00:00 ... 8000-12-31 00:00:00\n",
       "  * moc_z         (moc_z) float32 244B 0.0 1e+03 2e+03 ... 5.25e+05 5.5e+05\n",
       "  * lat_aux_grid  (lat_aux_grid) float32 420B -80.26 -78.73 ... 88.38 90.0\n",
       "Attributes:\n",
       "    long_name:     Meridional Overturning Circulation\n",
       "    units:         Sverdrups\n",
       "    cell_methods:  time: mean</pre><div class='xr-wrap' style='display:none'><div class='xr-header'><div class='xr-obj-type'>xarray.DataArray</div><div class='xr-obj-name'>&#x27;MOC&#x27;</div><ul class='xr-dim-list'><li><span class='xr-has-index'>time</span>: 325</li><li><span class='xr-has-index'>moc_z</span>: 61</li><li><span class='xr-has-index'>lat_aux_grid</span>: 105</li></ul></div><ul class='xr-sections'><li class='xr-section-item'><div class='xr-array-wrap'><input id='section-cacf7276-6f81-4b22-bc48-2f3c1c8a2209' class='xr-array-in' type='checkbox' checked><label for='section-cacf7276-6f81-4b22-bc48-2f3c1c8a2209' title='Show/hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-array-preview xr-preview'><span>-0.003242 -0.003242 -0.003242 -0.003242 -0.003242 ... 0.0 0.0 0.0 0.0</span></div><div class='xr-array-data'><pre>array([[[-3.24204541e-03, -3.24204541e-03, -3.24204541e-03, ...,\n",
       "          1.97343310e-04,  6.56600605e-05,  1.73003573e-05],\n",
       "        [-1.27978530e-02, -1.27978530e-02, -1.27978530e-02, ...,\n",
       "         -4.30338643e-03, -4.51596268e-03, -4.91895294e-03],\n",
       "        [-1.62455663e-02, -1.62455663e-02, -1.62455663e-02, ...,\n",
       "         -2.22288724e-03, -2.32393015e-03, -2.46941438e-03],\n",
       "        ...,\n",
       "        [ 0.00000000e+00,  0.00000000e+00,  0.00000000e+00, ...,\n",
       "         -3.03818894e-07, -3.03818894e-07, -3.03818894e-07],\n",
       "        [ 0.00000000e+00,  0.00000000e+00,  0.00000000e+00, ...,\n",
       "          2.58542315e-07,  2.58542315e-07,  2.58542315e-07],\n",
       "        [ 0.00000000e+00,  0.00000000e+00,  0.00000000e+00, ...,\n",
       "          0.00000000e+00,  0.00000000e+00,  0.00000000e+00]],\n",
       "\n",
       "       [[ 1.11201277e-03,  1.11201277e-03,  1.11201277e-03, ...,\n",
       "         -1.43123209e-04, -5.20096401e-05, -1.85315457e-05],\n",
       "        [ 1.90767013e-02,  1.90767013e-02,  1.90767013e-02, ...,\n",
       "          9.29078180e-03,  9.15022846e-03,  9.09731817e-03],\n",
       "        [ 3.88066322e-02,  3.88066322e-02,  3.88066322e-02, ...,\n",
       "          1.16502773e-02,  1.17193125e-02,  1.15378210e-02],\n",
       "...\n",
       "          1.97381027e-07,  1.97381027e-07,  1.97381027e-07],\n",
       "        [ 0.00000000e+00,  0.00000000e+00,  0.00000000e+00, ...,\n",
       "         -1.66932097e-07, -1.66932097e-07, -1.66932097e-07],\n",
       "        [ 0.00000000e+00,  0.00000000e+00,  0.00000000e+00, ...,\n",
       "          0.00000000e+00,  0.00000000e+00,  0.00000000e+00]],\n",
       "\n",
       "       [[-4.22286764e-02, -4.22286764e-02, -4.22286764e-02, ...,\n",
       "          1.43455889e-03,  2.92325858e-04, -1.26820989e-04],\n",
       "        [-1.68354213e-01, -1.68354213e-01, -1.68354213e-01, ...,\n",
       "          1.79322548e-02,  1.39369238e-02,  1.66624803e-02],\n",
       "        [-2.58173645e-01, -2.58173645e-01, -2.58173645e-01, ...,\n",
       "          3.39883529e-02,  2.85237785e-02,  3.14202905e-02],\n",
       "        ...,\n",
       "        [ 0.00000000e+00,  0.00000000e+00,  0.00000000e+00, ...,\n",
       "         -1.48887611e-05, -1.48887611e-05, -1.48887611e-05],\n",
       "        [ 0.00000000e+00,  0.00000000e+00,  0.00000000e+00, ...,\n",
       "          1.23312784e-05,  1.23312784e-05,  1.23312784e-05],\n",
       "        [ 0.00000000e+00,  0.00000000e+00,  0.00000000e+00, ...,\n",
       "          0.00000000e+00,  0.00000000e+00,  0.00000000e+00]]],\n",
       "      shape=(325, 61, 105), dtype=float32)</pre></div></div></li><li class='xr-section-item'><input id='section-e0f144e6-a44e-4921-bd81-0b7dd5a30141' class='xr-section-summary-in' type='checkbox'  checked><label for='section-e0f144e6-a44e-4921-bd81-0b7dd5a30141' class='xr-section-summary' >Coordinates: <span>(3)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><ul class='xr-var-list'><li class='xr-var-item'><div class='xr-var-name'><span class='xr-has-index'>time</span></div><div class='xr-var-dims'>(time)</div><div class='xr-var-dtype'>object</div><div class='xr-var-preview xr-preview'>7676-12-31 00:00:00 ... 8000-12-...</div><input id='attrs-f26f3a86-9eb9-41ca-87fb-dabc168017ce' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-f26f3a86-9eb9-41ca-87fb-dabc168017ce' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-106ea5f1-6a2d-4347-aa31-037d9f133231' class='xr-var-data-in' type='checkbox'><label for='data-106ea5f1-6a2d-4347-aa31-037d9f133231' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'><dt><span>long_name :</span></dt><dd>time</dd><dt><span>bounds :</span></dt><dd>time_bound</dd></dl></div><div class='xr-var-data'><pre>array([cftime.DatetimeNoLeap(7676, 12, 31, 0, 0, 0, 0, has_year_zero=True),\n",
       "       cftime.DatetimeNoLeap(7677, 12, 31, 0, 0, 0, 0, has_year_zero=True),\n",
       "       cftime.DatetimeNoLeap(7678, 12, 31, 0, 0, 0, 0, has_year_zero=True),\n",
       "       ...,\n",
       "       cftime.DatetimeNoLeap(7998, 12, 31, 0, 0, 0, 0, has_year_zero=True),\n",
       "       cftime.DatetimeNoLeap(7999, 12, 31, 0, 0, 0, 0, has_year_zero=True),\n",
       "       cftime.DatetimeNoLeap(8000, 12, 31, 0, 0, 0, 0, has_year_zero=True)],\n",
       "      shape=(325,), dtype=object)</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span class='xr-has-index'>moc_z</span></div><div class='xr-var-dims'>(moc_z)</div><div class='xr-var-dtype'>float32</div><div class='xr-var-preview xr-preview'>0.0 1e+03 ... 5.25e+05 5.5e+05</div><input id='attrs-adb7ad69-b524-438c-8241-c50c39eb782a' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-adb7ad69-b524-438c-8241-c50c39eb782a' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-118ec14e-3921-4b5a-8936-339db8900e92' class='xr-var-data-in' type='checkbox'><label for='data-118ec14e-3921-4b5a-8936-339db8900e92' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'><dt><span>long_name :</span></dt><dd>depth from surface to top of layer</dd><dt><span>units :</span></dt><dd>centimeters</dd><dt><span>positive :</span></dt><dd>down</dd><dt><span>valid_min :</span></dt><dd>0.0</dd><dt><span>valid_max :</span></dt><dd>549999.06</dd></dl></div><div class='xr-var-data'><pre>array([     0.   ,   1000.   ,   2000.   ,   3000.   ,   4000.   ,   5000.   ,\n",
       "         6000.   ,   7000.   ,   8000.   ,   9000.   ,  10000.   ,  11000.   ,\n",
       "        12000.   ,  13000.   ,  14000.   ,  15000.   ,  16000.   ,  17019.682,\n",
       "        18076.129,  19182.125,  20349.932,  21592.344,  22923.312,  24358.453,\n",
       "        25915.58 ,  27615.26 ,  29481.47 ,  31542.373,  33831.227,  36387.473,\n",
       "        39258.047,  42498.887,  46176.656,  50370.688,  55174.91 ,  60699.668,\n",
       "        67072.86 ,  74439.805,  82960.695,  92804.35 , 104136.82 , 117104.016,\n",
       "       131809.36 , 148290.08 , 166499.2  , 186301.44 , 207487.39 , 229803.9  ,\n",
       "       252990.4  , 276809.84 , 301067.06 , 325613.84 , 350344.88 , 375189.2  ,\n",
       "       400101.16 , 425052.47 , 450026.06 , 475012.   , 500004.7  , 525000.94 ,\n",
       "       549999.06 ], dtype=float32)</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span class='xr-has-index'>lat_aux_grid</span></div><div class='xr-var-dims'>(lat_aux_grid)</div><div class='xr-var-dtype'>float32</div><div class='xr-var-preview xr-preview'>-80.26 -78.73 -77.22 ... 88.38 90.0</div><input id='attrs-8a5043a8-4e1b-4dde-9863-18b26e686ac9' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-8a5043a8-4e1b-4dde-9863-18b26e686ac9' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-e91e7cc3-470b-43b0-a74b-03e7ce5f06f4' class='xr-var-data-in' type='checkbox'><label for='data-e91e7cc3-470b-43b0-a74b-03e7ce5f06f4' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'><dt><span>long_name :</span></dt><dd>latitude grid for transport diagnostics</dd><dt><span>units :</span></dt><dd>degrees_north</dd><dt><span>valid_min :</span></dt><dd>-80.26017</dd><dt><span>valid_max :</span></dt><dd>90.0</dd></dl></div><div class='xr-var-data'><pre>array([-80.26017 , -78.73382 , -77.217636, -75.70146 , -74.18529 , -72.66911 ,\n",
       "       -71.15295 , -69.636795, -68.12066 , -66.60454 , -65.08846 , -63.481495,\n",
       "       -61.779697, -59.9793  , -58.07679 , -56.069073, -53.953655, -51.728966,\n",
       "       -49.39478 , -46.9529  , -44.40814 , -41.769688, -39.052826, -36.280697,\n",
       "       -33.48543 , -30.707624, -27.993225, -25.388052, -22.931374, -20.650919,\n",
       "       -18.560844, -16.662758, -14.948642, -13.404314, -12.012482, -10.754977,\n",
       "        -9.614184,  -8.573812,  -7.619225,  -6.737495,  -5.917311,  -5.148796,\n",
       "        -4.423321,  -3.733296,  -3.071989,  -2.43335 ,  -1.811855,  -1.202367,\n",
       "        -0.600001,   0.      ,   0.600001,   1.202367,   1.811855,   2.43335 ,\n",
       "         3.071989,   3.733296,   4.423321,   5.148796,   5.917311,   6.737495,\n",
       "         7.619225,   8.573812,   9.614184,  10.754977,  12.012482,  13.404314,\n",
       "        14.948642,  16.662758,  18.560844,  20.650919,  22.931374,  25.388052,\n",
       "        27.993225,  30.707624,  33.48543 ,  36.280697,  39.052826,  41.769688,\n",
       "        44.40814 ,  46.9529  ,  49.39478 ,  51.728966,  53.953655,  56.069073,\n",
       "        58.07679 ,  59.9793  ,  61.779697,  63.481495,  65.08846 ,  66.60454 ,\n",
       "        68.12066 ,  69.636795,  71.15295 ,  72.66911 ,  74.18529 ,  75.70146 ,\n",
       "        77.217636,  78.73382 ,  80.26017 ,  81.88347 ,  83.506775,  85.13008 ,\n",
       "        86.75339 ,  88.37669 ,  90.      ], dtype=float32)</pre></div></li></ul></div></li><li class='xr-section-item'><input id='section-0494d1eb-58ad-44ab-8fd0-cfccf9af4a95' class='xr-section-summary-in' type='checkbox'  checked><label for='section-0494d1eb-58ad-44ab-8fd0-cfccf9af4a95' class='xr-section-summary' >Attributes: <span>(3)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><dl class='xr-attrs'><dt><span>long_name :</span></dt><dd>Meridional Overturning Circulation</dd><dt><span>units :</span></dt><dd>Sverdrups</dd><dt><span>cell_methods :</span></dt><dd>time: mean</dd></dl></div></li></ul></div></div>"
      ],
      "text/plain": [
       "<xarray.DataArray 'MOC' (time: 325, moc_z: 61, lat_aux_grid: 105)> Size: 8MB\n",
       "array([[[-3.24204541e-03, -3.24204541e-03, -3.24204541e-03, ...,\n",
       "          1.97343310e-04,  6.56600605e-05,  1.73003573e-05],\n",
       "        [-1.27978530e-02, -1.27978530e-02, -1.27978530e-02, ...,\n",
       "         -4.30338643e-03, -4.51596268e-03, -4.91895294e-03],\n",
       "        [-1.62455663e-02, -1.62455663e-02, -1.62455663e-02, ...,\n",
       "         -2.22288724e-03, -2.32393015e-03, -2.46941438e-03],\n",
       "        ...,\n",
       "        [ 0.00000000e+00,  0.00000000e+00,  0.00000000e+00, ...,\n",
       "         -3.03818894e-07, -3.03818894e-07, -3.03818894e-07],\n",
       "        [ 0.00000000e+00,  0.00000000e+00,  0.00000000e+00, ...,\n",
       "          2.58542315e-07,  2.58542315e-07,  2.58542315e-07],\n",
       "        [ 0.00000000e+00,  0.00000000e+00,  0.00000000e+00, ...,\n",
       "          0.00000000e+00,  0.00000000e+00,  0.00000000e+00]],\n",
       "\n",
       "       [[ 1.11201277e-03,  1.11201277e-03,  1.11201277e-03, ...,\n",
       "         -1.43123209e-04, -5.20096401e-05, -1.85315457e-05],\n",
       "        [ 1.90767013e-02,  1.90767013e-02,  1.90767013e-02, ...,\n",
       "          9.29078180e-03,  9.15022846e-03,  9.09731817e-03],\n",
       "        [ 3.88066322e-02,  3.88066322e-02,  3.88066322e-02, ...,\n",
       "          1.16502773e-02,  1.17193125e-02,  1.15378210e-02],\n",
       "...\n",
       "          1.97381027e-07,  1.97381027e-07,  1.97381027e-07],\n",
       "        [ 0.00000000e+00,  0.00000000e+00,  0.00000000e+00, ...,\n",
       "         -1.66932097e-07, -1.66932097e-07, -1.66932097e-07],\n",
       "        [ 0.00000000e+00,  0.00000000e+00,  0.00000000e+00, ...,\n",
       "          0.00000000e+00,  0.00000000e+00,  0.00000000e+00]],\n",
       "\n",
       "       [[-4.22286764e-02, -4.22286764e-02, -4.22286764e-02, ...,\n",
       "          1.43455889e-03,  2.92325858e-04, -1.26820989e-04],\n",
       "        [-1.68354213e-01, -1.68354213e-01, -1.68354213e-01, ...,\n",
       "          1.79322548e-02,  1.39369238e-02,  1.66624803e-02],\n",
       "        [-2.58173645e-01, -2.58173645e-01, -2.58173645e-01, ...,\n",
       "          3.39883529e-02,  2.85237785e-02,  3.14202905e-02],\n",
       "        ...,\n",
       "        [ 0.00000000e+00,  0.00000000e+00,  0.00000000e+00, ...,\n",
       "         -1.48887611e-05, -1.48887611e-05, -1.48887611e-05],\n",
       "        [ 0.00000000e+00,  0.00000000e+00,  0.00000000e+00, ...,\n",
       "          1.23312784e-05,  1.23312784e-05,  1.23312784e-05],\n",
       "        [ 0.00000000e+00,  0.00000000e+00,  0.00000000e+00, ...,\n",
       "          0.00000000e+00,  0.00000000e+00,  0.00000000e+00]]],\n",
       "      shape=(325, 61, 105), dtype=float32)\n",
       "Coordinates:\n",
       "  * time          (time) object 3kB 7676-12-31 00:00:00 ... 8000-12-31 00:00:00\n",
       "  * moc_z         (moc_z) float32 244B 0.0 1e+03 2e+03 ... 5.25e+05 5.5e+05\n",
       "  * lat_aux_grid  (lat_aux_grid) float32 420B -80.26 -78.73 ... 88.38 90.0\n",
       "Attributes:\n",
       "    long_name:     Meridional Overturning Circulation\n",
       "    units:         Sverdrups\n",
       "    cell_methods:  time: mean"
      ]
     },
     "execution_count": 69,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "mocanom"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 70,
   "id": "120d4987",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Calculate period averages for all variables across three temporal phases\n",
    "# This reduces annual time series to 3 representative snapshots showing evolution\n",
    "# Each period captures a distinct phase of the volcanic-AMOC response:\n",
    "# - Period 1 (0-5 yr): Immediate cooling, freshening, and atmospheric circulation changes\n",
    "# - Period 2 (5-15 yr): Transition phase with cumulative effects on ocean circulation\n",
    "# - Period 3 (15-20 yr): Recovery phase as system begins to return toward equilibrium\n",
    "# Creates lists (e.g., ts_ens, psl_ens) with 3 elements, one per period\n",
    "## I want to take a variable and average over the year segment.sel(time=time_ref.dt.year.isin(year_sel)).mean('time')\n",
    "## I need a loop to average sections of time over a set variables\n",
    "vars = [tsanom, pslanom, sssanom, iceanom, bsfanom, tauxanom, tauyanom, hmxlanom, peranom] \n",
    "plt_years = [[7701,7705], [7706,7715], [7716,7720]]\n",
    "def average_over_years(variable, years):\n",
    "    return variable.sel(time=variable.time.dt.year.isin(range(years[0], years[1]))).mean('time')\n",
    "## I need a loop to average sections of time over a set variables and 3 sections of year plt_years = [[7701,7705], [7706,7715], [7716,7720]]\n",
    "## loop over the variables and years segments\n",
    "ts_ens = []\n",
    "psl_ens = []\n",
    "sss_ens = []\n",
    "ice_ens = []\n",
    "bsf_ens = []\n",
    "taux_ens = []\n",
    "tauy_ens = []\n",
    "hmxl_ens = []\n",
    "per_ens = []\n",
    "moc_ens = []\n",
    "for years in plt_years:\n",
    "    ts_ens.append(average_over_years(tsanom, years))\n",
    "    psl_ens.append(average_over_years(pslanom, years))\n",
    "    sss_ens.append(average_over_years(sssanom, years))\n",
    "    ice_ens.append(average_over_years(iceanom, years))\n",
    "    bsf_ens.append(average_over_years(bsfanom, years))\n",
    "    taux_ens.append(average_over_years(tauxanom, years))\n",
    "\n",
    "    tauy_ens.append(average_over_years(tauyanom, years))\n",
    "\n",
    "    hmxl_ens.append(average_over_years(hmxlanom, years))\n",
    "\n",
    "    per_ens.append(average_over_years(peranom, years))\n",
    "    moc_ens.append(average_over_years(mocanom, years))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 71,
   "id": "8498b998",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.collections.QuadMesh at 0x79c868580cb0>"
      ]
     },
     "execution_count": 71,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 45268 characters]",
      "text/plain": [
       "<Figure size 640x480 with 2 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "psl_ens[1].plot()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 72,
   "id": "b8540dd1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><svg style=\"position: absolute; width: 0; height: 0; overflow: hidden\">\n",
       "<defs>\n",
       "<symbol id=\"icon-database\" viewBox=\"0 0 32 32\">\n",
       "<path d=\"M16 0c-8.837 0-16 2.239-16 5v4c0 2.761 7.163 5 16 5s16-2.239 16-5v-4c0-2.761-7.163-5-16-5z\"></path>\n",
       "<path d=\"M16 17c-8.837 0-16-2.239-16-5v6c0 2.761 7.163 5 16 5s16-2.239 16-5v-6c0 2.761-7.163 5-16 5z\"></path>\n",
       "<path d=\"M16 26c-8.837 0-16-2.239-16-5v6c0 2.761 7.163 5 16 5s16-2.239 16-5v-6c0 2.761-7.163 5-16 5z\"></path>\n",
       "</symbol>\n",
       "<symbol id=\"icon-file-text2\" viewBox=\"0 0 32 32\">\n",
       "<path d=\"M28.681 7.159c-0.694-0.947-1.662-2.053-2.724-3.116s-2.169-2.030-3.116-2.724c-1.612-1.182-2.393-1.319-2.841-1.319h-15.5c-1.378 0-2.5 1.121-2.5 2.5v27c0 1.378 1.122 2.5 2.5 2.5h23c1.378 0 2.5-1.122 2.5-2.5v-19.5c0-0.448-0.137-1.23-1.319-2.841zM24.543 5.457c0.959 0.959 1.712 1.825 2.268 2.543h-4.811v-4.811c0.718 0.556 1.584 1.309 2.543 2.268zM28 29.5c0 0.271-0.229 0.5-0.5 0.5h-23c-0.271 0-0.5-0.229-0.5-0.5v-27c0-0.271 0.229-0.5 0.5-0.5 0 0 15.499-0 15.5 0v7c0 0.552 0.448 1 1 1h7v19.5z\"></path>\n",
       "<path d=\"M23 26h-14c-0.552 0-1-0.448-1-1s0.448-1 1-1h14c0.552 0 1 0.448 1 1s-0.448 1-1 1z\"></path>\n",
       "<path d=\"M23 22h-14c-0.552 0-1-0.448-1-1s0.448-1 1-1h14c0.552 0 1 0.448 1 1s-0.448 1-1 1z\"></path>\n",
       "<path d=\"M23 18h-14c-0.552 0-1-0.448-1-1s0.448-1 1-1h14c0.552 0 1 0.448 1 1s-0.448 1-1 1z\"></path>\n",
       "</symbol>\n",
       "</defs>\n",
       "</svg>\n",
       "<style>/* CSS stylesheet for displaying xarray objects in notebooks */\n",
       "\n",
       ":root {\n",
       "  --xr-font-color0: var(\n",
       "    --jp-content-font-color0,\n",
       "    var(--pst-color-text-base rgba(0, 0, 0, 1))\n",
       "  );\n",
       "  --xr-font-color2: var(\n",
       "    --jp-content-font-color2,\n",
       "    var(--pst-color-text-base, rgba(0, 0, 0, 0.54))\n",
       "  );\n",
       "  --xr-font-color3: var(\n",
       "    --jp-content-font-color3,\n",
       "    var(--pst-color-text-base, rgba(0, 0, 0, 0.38))\n",
       "  );\n",
       "  --xr-border-color: var(\n",
       "    --jp-border-color2,\n",
       "    hsl(from var(--pst-color-on-background, white) h s calc(l - 10))\n",
       "  );\n",
       "  --xr-disabled-color: var(\n",
       "    --jp-layout-color3,\n",
       "    hsl(from var(--pst-color-on-background, white) h s calc(l - 40))\n",
       "  );\n",
       "  --xr-background-color: var(\n",
       "    --jp-layout-color0,\n",
       "    var(--pst-color-on-background, white)\n",
       "  );\n",
       "  --xr-background-color-row-even: var(\n",
       "    --jp-layout-color1,\n",
       "    hsl(from var(--pst-color-on-background, white) h s calc(l - 5))\n",
       "  );\n",
       "  --xr-background-color-row-odd: var(\n",
       "    --jp-layout-color2,\n",
       "    hsl(from var(--pst-color-on-background, white) h s calc(l - 15))\n",
       "  );\n",
       "}\n",
       "\n",
       "html[theme=\"dark\"],\n",
       "html[data-theme=\"dark\"],\n",
       "body[data-theme=\"dark\"],\n",
       "body.vscode-dark {\n",
       "  --xr-font-color0: var(\n",
       "    --jp-content-font-color0,\n",
       "    var(--pst-color-text-base, rgba(255, 255, 255, 1))\n",
       "  );\n",
       "  --xr-font-color2: var(\n",
       "    --jp-content-font-color2,\n",
       "    var(--pst-color-text-base, rgba(255, 255, 255, 0.54))\n",
       "  );\n",
       "  --xr-font-color3: var(\n",
       "    --jp-content-font-color3,\n",
       "    var(--pst-color-text-base, rgba(255, 255, 255, 0.38))\n",
       "  );\n",
       "  --xr-border-color: var(\n",
       "    --jp-border-color2,\n",
       "    hsl(from var(--pst-color-on-background, #111111) h s calc(l + 10))\n",
       "  );\n",
       "  --xr-disabled-color: var(\n",
       "    --jp-layout-color3,\n",
       "    hsl(from var(--pst-color-on-background, #111111) h s calc(l + 40))\n",
       "  );\n",
       "  --xr-background-color: var(\n",
       "    --jp-layout-color0,\n",
       "    var(--pst-color-on-background, #111111)\n",
       "  );\n",
       "  --xr-background-color-row-even: var(\n",
       "    --jp-layout-color1,\n",
       "    hsl(from var(--pst-color-on-background, #111111) h s calc(l + 5))\n",
       "  );\n",
       "  --xr-background-color-row-odd: var(\n",
       "    --jp-layout-color2,\n",
       "    hsl(from var(--pst-color-on-background, #111111) h s calc(l + 15))\n",
       "  );\n",
       "}\n",
       "\n",
       ".xr-wrap {\n",
       "  display: block !important;\n",
       "  min-width: 300px;\n",
       "  max-width: 700px;\n",
       "  line-height: 1.6;\n",
       "}\n",
       "\n",
       ".xr-text-repr-fallback {\n",
       "  /* fallback to plain text repr when CSS is not injected (untrusted notebook) */\n",
       "  display: none;\n",
       "}\n",
       "\n",
       ".xr-header {\n",
       "  padding-top: 6px;\n",
       "  padding-bottom: 6px;\n",
       "  margin-bottom: 4px;\n",
       "  border-bottom: solid 1px var(--xr-border-color);\n",
       "}\n",
       "\n",
       ".xr-header > div,\n",
       ".xr-header > ul {\n",
       "  display: inline;\n",
       "  margin-top: 0;\n",
       "  margin-bottom: 0;\n",
       "}\n",
       "\n",
       ".xr-obj-type,\n",
       ".xr-obj-name,\n",
       ".xr-group-name {\n",
       "  margin-left: 2px;\n",
       "  margin-right: 10px;\n",
       "}\n",
       "\n",
       ".xr-group-name::before {\n",
       "  content: \"📁\";\n",
       "  padding-right: 0.3em;\n",
       "}\n",
       "\n",
       ".xr-group-name,\n",
       ".xr-obj-type {\n",
       "  color: var(--xr-font-color2);\n",
       "}\n",
       "\n",
       ".xr-sections {\n",
       "  padding-left: 0 !important;\n",
       "  display: grid;\n",
       "  grid-template-columns: 150px auto auto 1fr 0 20px 0 20px;\n",
       "  margin-block-start: 0;\n",
       "  margin-block-end: 0;\n",
       "}\n",
       "\n",
       ".xr-section-item {\n",
       "  display: contents;\n",
       "}\n",
       "\n",
       ".xr-section-item input {\n",
       "  display: inline-block;\n",
       "  opacity: 0;\n",
       "  height: 0;\n",
       "  margin: 0;\n",
       "}\n",
       "\n",
       ".xr-section-item input + label {\n",
       "  color: var(--xr-disabled-color);\n",
       "  border: 2px solid transparent !important;\n",
       "}\n",
       "\n",
       ".xr-section-item input:enabled + label {\n",
       "  cursor: pointer;\n",
       "  color: var(--xr-font-color2);\n",
       "}\n",
       "\n",
       ".xr-section-item input:focus + label {\n",
       "  border: 2px solid var(--xr-font-color0) !important;\n",
       "}\n",
       "\n",
       ".xr-section-item input:enabled + label:hover {\n",
       "  color: var(--xr-font-color0);\n",
       "}\n",
       "\n",
       ".xr-section-summary {\n",
       "  grid-column: 1;\n",
       "  color: var(--xr-font-color2);\n",
       "  font-weight: 500;\n",
       "}\n",
       "\n",
       ".xr-section-summary > span {\n",
       "  display: inline-block;\n",
       "  padding-left: 0.5em;\n",
       "}\n",
       "\n",
       ".xr-section-summary-in:disabled + label {\n",
       "  color: var(--xr-font-color2);\n",
       "}\n",
       "\n",
       ".xr-section-summary-in + label:before {\n",
       "  display: inline-block;\n",
       "  content: \"►\";\n",
       "  font-size: 11px;\n",
       "  width: 15px;\n",
       "  text-align: center;\n",
       "}\n",
       "\n",
       ".xr-section-summary-in:disabled + label:before {\n",
       "  color: var(--xr-disabled-color);\n",
       "}\n",
       "\n",
       ".xr-section-summary-in:checked + label:before {\n",
       "  content: \"▼\";\n",
       "}\n",
       "\n",
       ".xr-section-summary-in:checked + label > span {\n",
       "  display: none;\n",
       "}\n",
       "\n",
       ".xr-section-summary,\n",
       ".xr-section-inline-details {\n",
       "  padding-top: 4px;\n",
       "}\n",
       "\n",
       ".xr-section-inline-details {\n",
       "  grid-column: 2 / -1;\n",
       "}\n",
       "\n",
       ".xr-section-details {\n",
       "  display: none;\n",
       "  grid-column: 1 / -1;\n",
       "  margin-top: 4px;\n",
       "  margin-bottom: 5px;\n",
       "}\n",
       "\n",
       ".xr-section-summary-in:checked ~ .xr-section-details {\n",
       "  display: contents;\n",
       "}\n",
       "\n",
       ".xr-group-box {\n",
       "  display: inline-grid;\n",
       "  grid-template-columns: 0px 20px auto;\n",
       "  width: 100%;\n",
       "}\n",
       "\n",
       ".xr-group-box-vline {\n",
       "  grid-column-start: 1;\n",
       "  border-right: 0.2em solid;\n",
       "  border-color: var(--xr-border-color);\n",
       "  width: 0px;\n",
       "}\n",
       "\n",
       ".xr-group-box-hline {\n",
       "  grid-column-start: 2;\n",
       "  grid-row-start: 1;\n",
       "  height: 1em;\n",
       "  width: 20px;\n",
       "  border-bottom: 0.2em solid;\n",
       "  border-color: var(--xr-border-color);\n",
       "}\n",
       "\n",
       ".xr-group-box-contents {\n",
       "  grid-column-start: 3;\n",
       "}\n",
       "\n",
       ".xr-array-wrap {\n",
       "  grid-column: 1 / -1;\n",
       "  display: grid;\n",
       "  grid-template-columns: 20px auto;\n",
       "}\n",
       "\n",
       ".xr-array-wrap > label {\n",
       "  grid-column: 1;\n",
       "  vertical-align: top;\n",
       "}\n",
       "\n",
       ".xr-preview {\n",
       "  color: var(--xr-font-color3);\n",
       "}\n",
       "\n",
       ".xr-array-preview,\n",
       ".xr-array-data {\n",
       "  padding: 0 5px !important;\n",
       "  grid-column: 2;\n",
       "}\n",
       "\n",
       ".xr-array-data,\n",
       ".xr-array-in:checked ~ .xr-array-preview {\n",
       "  display: none;\n",
       "}\n",
       "\n",
       ".xr-array-in:checked ~ .xr-array-data,\n",
       ".xr-array-preview {\n",
       "  display: inline-block;\n",
       "}\n",
       "\n",
       ".xr-dim-list {\n",
       "  display: inline-block !important;\n",
       "  list-style: none;\n",
       "  padding: 0 !important;\n",
       "  margin: 0;\n",
       "}\n",
       "\n",
       ".xr-dim-list li {\n",
       "  display: inline-block;\n",
       "  padding: 0;\n",
       "  margin: 0;\n",
       "}\n",
       "\n",
       ".xr-dim-list:before {\n",
       "  content: \"(\";\n",
       "}\n",
       "\n",
       ".xr-dim-list:after {\n",
       "  content: \")\";\n",
       "}\n",
       "\n",
       ".xr-dim-list li:not(:last-child):after {\n",
       "  content: \",\";\n",
       "  padding-right: 5px;\n",
       "}\n",
       "\n",
       ".xr-has-index {\n",
       "  font-weight: bold;\n",
       "}\n",
       "\n",
       ".xr-var-list,\n",
       ".xr-var-item {\n",
       "  display: contents;\n",
       "}\n",
       "\n",
       ".xr-var-item > div,\n",
       ".xr-var-item label,\n",
       ".xr-var-item > .xr-var-name span {\n",
       "  background-color: var(--xr-background-color-row-even);\n",
       "  border-color: var(--xr-background-color-row-odd);\n",
       "  margin-bottom: 0;\n",
       "  padding-top: 2px;\n",
       "}\n",
       "\n",
       ".xr-var-item > .xr-var-name:hover span {\n",
       "  padding-right: 5px;\n",
       "}\n",
       "\n",
       ".xr-var-list > li:nth-child(odd) > div,\n",
       ".xr-var-list > li:nth-child(odd) > label,\n",
       ".xr-var-list > li:nth-child(odd) > .xr-var-name span {\n",
       "  background-color: var(--xr-background-color-row-odd);\n",
       "  border-color: var(--xr-background-color-row-even);\n",
       "}\n",
       "\n",
       ".xr-var-name {\n",
       "  grid-column: 1;\n",
       "}\n",
       "\n",
       ".xr-var-dims {\n",
       "  grid-column: 2;\n",
       "}\n",
       "\n",
       ".xr-var-dtype {\n",
       "  grid-column: 3;\n",
       "  text-align: right;\n",
       "  color: var(--xr-font-color2);\n",
       "}\n",
       "\n",
       ".xr-var-preview {\n",
       "  grid-column: 4;\n",
       "}\n",
       "\n",
       ".xr-index-preview {\n",
       "  grid-column: 2 / 5;\n",
       "  color: var(--xr-font-color2);\n",
       "}\n",
       "\n",
       ".xr-var-name,\n",
       ".xr-var-dims,\n",
       ".xr-var-dtype,\n",
       ".xr-preview,\n",
       ".xr-attrs dt {\n",
       "  white-space: nowrap;\n",
       "  overflow: hidden;\n",
       "  text-overflow: ellipsis;\n",
       "  padding-right: 10px;\n",
       "}\n",
       "\n",
       ".xr-var-name:hover,\n",
       ".xr-var-dims:hover,\n",
       ".xr-var-dtype:hover,\n",
       ".xr-attrs dt:hover {\n",
       "  overflow: visible;\n",
       "  width: auto;\n",
       "  z-index: 1;\n",
       "}\n",
       "\n",
       ".xr-var-attrs,\n",
       ".xr-var-data,\n",
       ".xr-index-data {\n",
       "  display: none;\n",
       "  border-top: 2px dotted var(--xr-background-color);\n",
       "  padding-bottom: 20px !important;\n",
       "  padding-top: 10px !important;\n",
       "}\n",
       "\n",
       ".xr-var-attrs-in + label,\n",
       ".xr-var-data-in + label,\n",
       ".xr-index-data-in + label {\n",
       "  padding: 0 1px;\n",
       "}\n",
       "\n",
       ".xr-var-attrs-in:checked ~ .xr-var-attrs,\n",
       ".xr-var-data-in:checked ~ .xr-var-data,\n",
       ".xr-index-data-in:checked ~ .xr-index-data {\n",
       "  display: block;\n",
       "}\n",
       "\n",
       ".xr-var-data > table {\n",
       "  float: right;\n",
       "}\n",
       "\n",
       ".xr-var-data > pre,\n",
       ".xr-index-data > pre,\n",
       ".xr-var-data > table > tbody > tr {\n",
       "  background-color: transparent !important;\n",
       "}\n",
       "\n",
       ".xr-var-name span,\n",
       ".xr-var-data,\n",
       ".xr-index-name div,\n",
       ".xr-index-data,\n",
       ".xr-attrs {\n",
       "  padding-left: 25px !important;\n",
       "}\n",
       "\n",
       ".xr-attrs,\n",
       ".xr-var-attrs,\n",
       ".xr-var-data,\n",
       ".xr-index-data {\n",
       "  grid-column: 1 / -1;\n",
       "}\n",
       "\n",
       "dl.xr-attrs {\n",
       "  padding: 0;\n",
       "  margin: 0;\n",
       "  display: grid;\n",
       "  grid-template-columns: 125px auto;\n",
       "}\n",
       "\n",
       ".xr-attrs dt,\n",
       ".xr-attrs dd {\n",
       "  padding: 0;\n",
       "  margin: 0;\n",
       "  float: left;\n",
       "  padding-right: 10px;\n",
       "  width: auto;\n",
       "}\n",
       "\n",
       ".xr-attrs dt {\n",
       "  font-weight: normal;\n",
       "  grid-column: 1;\n",
       "}\n",
       "\n",
       ".xr-attrs dt:hover span {\n",
       "  display: inline-block;\n",
       "  background: var(--xr-background-color);\n",
       "  padding-right: 10px;\n",
       "}\n",
       "\n",
       ".xr-attrs dd {\n",
       "  grid-column: 2;\n",
       "  white-space: pre-wrap;\n",
       "  word-break: break-all;\n",
       "}\n",
       "\n",
       ".xr-icon-database,\n",
       ".xr-icon-file-text2,\n",
       ".xr-no-icon {\n",
       "  display: inline-block;\n",
       "  vertical-align: middle;\n",
       "  width: 1em;\n",
       "  height: 1.5em !important;\n",
       "  stroke-width: 0;\n",
       "  stroke: currentColor;\n",
       "  fill: currentColor;\n",
       "}\n",
       "\n",
       ".xr-var-attrs-in:checked + label > .xr-icon-file-text2,\n",
       ".xr-var-data-in:checked + label > .xr-icon-database,\n",
       ".xr-index-data-in:checked + label > .xr-icon-database {\n",
       "  color: var(--xr-font-color0);\n",
       "  filter: drop-shadow(1px 1px 5px var(--xr-font-color2));\n",
       "  stroke-width: 0.8px;\n",
       "}\n",
       "</style><pre class='xr-text-repr-fallback'>&lt;xarray.DataArray &#x27;MOC&#x27; (moc_z: 61, lat_aux_grid: 105)&gt; Size: 26kB\n",
       "array([[ 5.5087567e-03,  5.5087567e-03,  5.5087567e-03, ...,\n",
       "         7.7653967e-05,  1.9195475e-05, -2.3486900e-06],\n",
       "       [ 1.0648091e-01,  1.0648091e-01,  1.0648091e-01, ...,\n",
       "         2.6971625e-02,  2.5901772e-02,  2.7210653e-02],\n",
       "       [ 1.2437049e-01,  1.2437049e-01,  1.2437049e-01, ...,\n",
       "         3.7987139e-02,  3.1099256e-02,  3.3645201e-02],\n",
       "       ...,\n",
       "       [ 0.0000000e+00,  0.0000000e+00,  0.0000000e+00, ...,\n",
       "         2.5319628e-07,  2.5319628e-07,  2.5319628e-07],\n",
       "       [ 0.0000000e+00,  0.0000000e+00,  0.0000000e+00, ...,\n",
       "        -2.0902311e-07, -2.0902311e-07, -2.0902311e-07],\n",
       "       [ 0.0000000e+00,  0.0000000e+00,  0.0000000e+00, ...,\n",
       "         0.0000000e+00,  0.0000000e+00,  0.0000000e+00]],\n",
       "      shape=(61, 105), dtype=float32)\n",
       "Coordinates:\n",
       "  * moc_z         (moc_z) float32 244B 0.0 1e+03 2e+03 ... 5.25e+05 5.5e+05\n",
       "  * lat_aux_grid  (lat_aux_grid) float32 420B -80.26 -78.73 ... 88.38 90.0\n",
       "Attributes:\n",
       "    long_name:     Meridional Overturning Circulation\n",
       "    units:         Sverdrups\n",
       "    cell_methods:  time: mean</pre><div class='xr-wrap' style='display:none'><div class='xr-header'><div class='xr-obj-type'>xarray.DataArray</div><div class='xr-obj-name'>&#x27;MOC&#x27;</div><ul class='xr-dim-list'><li><span class='xr-has-index'>moc_z</span>: 61</li><li><span class='xr-has-index'>lat_aux_grid</span>: 105</li></ul></div><ul class='xr-sections'><li class='xr-section-item'><div class='xr-array-wrap'><input id='section-2ab7ff1d-6af0-463c-9061-7c6d54114020' class='xr-array-in' type='checkbox' checked><label for='section-2ab7ff1d-6af0-463c-9061-7c6d54114020' title='Show/hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-array-preview xr-preview'><span>0.005509 0.005509 0.005509 0.005509 0.005509 ... 0.0 0.0 0.0 0.0 0.0</span></div><div class='xr-array-data'><pre>array([[ 5.5087567e-03,  5.5087567e-03,  5.5087567e-03, ...,\n",
       "         7.7653967e-05,  1.9195475e-05, -2.3486900e-06],\n",
       "       [ 1.0648091e-01,  1.0648091e-01,  1.0648091e-01, ...,\n",
       "         2.6971625e-02,  2.5901772e-02,  2.7210653e-02],\n",
       "       [ 1.2437049e-01,  1.2437049e-01,  1.2437049e-01, ...,\n",
       "         3.7987139e-02,  3.1099256e-02,  3.3645201e-02],\n",
       "       ...,\n",
       "       [ 0.0000000e+00,  0.0000000e+00,  0.0000000e+00, ...,\n",
       "         2.5319628e-07,  2.5319628e-07,  2.5319628e-07],\n",
       "       [ 0.0000000e+00,  0.0000000e+00,  0.0000000e+00, ...,\n",
       "        -2.0902311e-07, -2.0902311e-07, -2.0902311e-07],\n",
       "       [ 0.0000000e+00,  0.0000000e+00,  0.0000000e+00, ...,\n",
       "         0.0000000e+00,  0.0000000e+00,  0.0000000e+00]],\n",
       "      shape=(61, 105), dtype=float32)</pre></div></div></li><li class='xr-section-item'><input id='section-f28d7821-8906-4836-a711-cd8a4dc01ed1' class='xr-section-summary-in' type='checkbox'  checked><label for='section-f28d7821-8906-4836-a711-cd8a4dc01ed1' class='xr-section-summary' >Coordinates: <span>(2)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><ul class='xr-var-list'><li class='xr-var-item'><div class='xr-var-name'><span class='xr-has-index'>moc_z</span></div><div class='xr-var-dims'>(moc_z)</div><div class='xr-var-dtype'>float32</div><div class='xr-var-preview xr-preview'>0.0 1e+03 ... 5.25e+05 5.5e+05</div><input id='attrs-32424f99-b071-4418-b087-5e44049d4394' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-32424f99-b071-4418-b087-5e44049d4394' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-da98416e-3822-46bf-b257-2399a60adc4a' class='xr-var-data-in' type='checkbox'><label for='data-da98416e-3822-46bf-b257-2399a60adc4a' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'><dt><span>long_name :</span></dt><dd>depth from surface to top of layer</dd><dt><span>units :</span></dt><dd>centimeters</dd><dt><span>positive :</span></dt><dd>down</dd><dt><span>valid_min :</span></dt><dd>0.0</dd><dt><span>valid_max :</span></dt><dd>549999.06</dd></dl></div><div class='xr-var-data'><pre>array([     0.   ,   1000.   ,   2000.   ,   3000.   ,   4000.   ,   5000.   ,\n",
       "         6000.   ,   7000.   ,   8000.   ,   9000.   ,  10000.   ,  11000.   ,\n",
       "        12000.   ,  13000.   ,  14000.   ,  15000.   ,  16000.   ,  17019.682,\n",
       "        18076.129,  19182.125,  20349.932,  21592.344,  22923.312,  24358.453,\n",
       "        25915.58 ,  27615.26 ,  29481.47 ,  31542.373,  33831.227,  36387.473,\n",
       "        39258.047,  42498.887,  46176.656,  50370.688,  55174.91 ,  60699.668,\n",
       "        67072.86 ,  74439.805,  82960.695,  92804.35 , 104136.82 , 117104.016,\n",
       "       131809.36 , 148290.08 , 166499.2  , 186301.44 , 207487.39 , 229803.9  ,\n",
       "       252990.4  , 276809.84 , 301067.06 , 325613.84 , 350344.88 , 375189.2  ,\n",
       "       400101.16 , 425052.47 , 450026.06 , 475012.   , 500004.7  , 525000.94 ,\n",
       "       549999.06 ], dtype=float32)</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span class='xr-has-index'>lat_aux_grid</span></div><div class='xr-var-dims'>(lat_aux_grid)</div><div class='xr-var-dtype'>float32</div><div class='xr-var-preview xr-preview'>-80.26 -78.73 -77.22 ... 88.38 90.0</div><input id='attrs-a152ed99-ab3b-491b-92e0-61645f84c1b5' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-a152ed99-ab3b-491b-92e0-61645f84c1b5' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-f2231fd4-6bc0-43bf-ac20-39d4baac1c74' class='xr-var-data-in' type='checkbox'><label for='data-f2231fd4-6bc0-43bf-ac20-39d4baac1c74' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'><dt><span>long_name :</span></dt><dd>latitude grid for transport diagnostics</dd><dt><span>units :</span></dt><dd>degrees_north</dd><dt><span>valid_min :</span></dt><dd>-80.26017</dd><dt><span>valid_max :</span></dt><dd>90.0</dd></dl></div><div class='xr-var-data'><pre>array([-80.26017 , -78.73382 , -77.217636, -75.70146 , -74.18529 , -72.66911 ,\n",
       "       -71.15295 , -69.636795, -68.12066 , -66.60454 , -65.08846 , -63.481495,\n",
       "       -61.779697, -59.9793  , -58.07679 , -56.069073, -53.953655, -51.728966,\n",
       "       -49.39478 , -46.9529  , -44.40814 , -41.769688, -39.052826, -36.280697,\n",
       "       -33.48543 , -30.707624, -27.993225, -25.388052, -22.931374, -20.650919,\n",
       "       -18.560844, -16.662758, -14.948642, -13.404314, -12.012482, -10.754977,\n",
       "        -9.614184,  -8.573812,  -7.619225,  -6.737495,  -5.917311,  -5.148796,\n",
       "        -4.423321,  -3.733296,  -3.071989,  -2.43335 ,  -1.811855,  -1.202367,\n",
       "        -0.600001,   0.      ,   0.600001,   1.202367,   1.811855,   2.43335 ,\n",
       "         3.071989,   3.733296,   4.423321,   5.148796,   5.917311,   6.737495,\n",
       "         7.619225,   8.573812,   9.614184,  10.754977,  12.012482,  13.404314,\n",
       "        14.948642,  16.662758,  18.560844,  20.650919,  22.931374,  25.388052,\n",
       "        27.993225,  30.707624,  33.48543 ,  36.280697,  39.052826,  41.769688,\n",
       "        44.40814 ,  46.9529  ,  49.39478 ,  51.728966,  53.953655,  56.069073,\n",
       "        58.07679 ,  59.9793  ,  61.779697,  63.481495,  65.08846 ,  66.60454 ,\n",
       "        68.12066 ,  69.636795,  71.15295 ,  72.66911 ,  74.18529 ,  75.70146 ,\n",
       "        77.217636,  78.73382 ,  80.26017 ,  81.88347 ,  83.506775,  85.13008 ,\n",
       "        86.75339 ,  88.37669 ,  90.      ], dtype=float32)</pre></div></li></ul></div></li><li class='xr-section-item'><input id='section-013885cc-c6b1-4df0-8cf1-1254e96a2569' class='xr-section-summary-in' type='checkbox'  checked><label for='section-013885cc-c6b1-4df0-8cf1-1254e96a2569' class='xr-section-summary' >Attributes: <span>(3)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><dl class='xr-attrs'><dt><span>long_name :</span></dt><dd>Meridional Overturning Circulation</dd><dt><span>units :</span></dt><dd>Sverdrups</dd><dt><span>cell_methods :</span></dt><dd>time: mean</dd></dl></div></li></ul></div></div>"
      ],
      "text/plain": [
       "<xarray.DataArray 'MOC' (moc_z: 61, lat_aux_grid: 105)> Size: 26kB\n",
       "array([[ 5.5087567e-03,  5.5087567e-03,  5.5087567e-03, ...,\n",
       "         7.7653967e-05,  1.9195475e-05, -2.3486900e-06],\n",
       "       [ 1.0648091e-01,  1.0648091e-01,  1.0648091e-01, ...,\n",
       "         2.6971625e-02,  2.5901772e-02,  2.7210653e-02],\n",
       "       [ 1.2437049e-01,  1.2437049e-01,  1.2437049e-01, ...,\n",
       "         3.7987139e-02,  3.1099256e-02,  3.3645201e-02],\n",
       "       ...,\n",
       "       [ 0.0000000e+00,  0.0000000e+00,  0.0000000e+00, ...,\n",
       "         2.5319628e-07,  2.5319628e-07,  2.5319628e-07],\n",
       "       [ 0.0000000e+00,  0.0000000e+00,  0.0000000e+00, ...,\n",
       "        -2.0902311e-07, -2.0902311e-07, -2.0902311e-07],\n",
       "       [ 0.0000000e+00,  0.0000000e+00,  0.0000000e+00, ...,\n",
       "         0.0000000e+00,  0.0000000e+00,  0.0000000e+00]],\n",
       "      shape=(61, 105), dtype=float32)\n",
       "Coordinates:\n",
       "  * moc_z         (moc_z) float32 244B 0.0 1e+03 2e+03 ... 5.25e+05 5.5e+05\n",
       "  * lat_aux_grid  (lat_aux_grid) float32 420B -80.26 -78.73 ... 88.38 90.0\n",
       "Attributes:\n",
       "    long_name:     Meridional Overturning Circulation\n",
       "    units:         Sverdrups\n",
       "    cell_methods:  time: mean"
      ]
     },
     "execution_count": 72,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "moc_ens[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 73,
   "id": "e7ab13e0",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 619024 characters]",
      "text/plain": [
       "<Figure size 1600x1200 with 26 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Generate Figure 6: 3-row × 5-column multi-field analysis showing temporal evolution\n",
    "# Each row represents one time period (0-5 yr, 5-15 yr, 15-20 yr post-eruption)\n",
    "# Each column shows a different climate field combination:\n",
    "# A: TS (filled) + PSL (contours)\n",
    "# B: SSS (filled) + HMXL (contours)  \n",
    "# C: P-E+R (filled) + ICEFRAC (contours)\n",
    "# D: BSF (filled) + wind stress vectors\n",
    "# E: AMOC depth-latitude section\n",
    "# Figure reveals spatial patterns and temporal evolution of coupled climate response\n",
    "moc_z = mocanom.moc_z\n",
    "moc_lat = mocanom.lat_aux_grid\n",
    "nrow      = 3\n",
    "ncol      = 5\n",
    "lon_cnt   = 180\n",
    "alpha     = 0.05\n",
    "iw        = 1  # quiver subsampling (every 1st grid point)\n",
    "# contour alpha\n",
    "calpha    = 0.9\n",
    "\n",
    "# Define contour levels for each variable\n",
    "bd_ts     = np.linspace(-4, 4, 17)        # Surface air temp (°C)\n",
    "bd_psl    = np.linspace(-2.5, 2.5, 11)    # Sea level pressure (KPa)\n",
    "bd_sss    = np.linspace(-0.5, 0.5, 11)    # Sea surface salinity (g/kg)\n",
    "bd_hmxl   = np.linspace(-100, 100, 11)    # Mixed layer depth (m)\n",
    "bd_per    = np.linspace(-1, 1, 11)        # P-E+R (mm/day)\n",
    "bd_ice    = np.linspace(-20, 20, 11)      # Sea ice fraction (%)\n",
    "bd_bsf    = np.linspace(-5, 5, 11)        # Barotropic streamfunction (Sv)\n",
    "bd_moc    = np.linspace(-2, 2, 11)        # AMOC (Sv)\n",
    "data_proj = ccrs.PlateCarree(central_longitude=180)\n",
    "fig       = plt.figure(figsize=(16, 12))\n",
    "gs        = gridspec.GridSpec(nrow, ncol, figure=fig)\n",
    "cmap      = cmaps.BlueWhiteOrangeRed\n",
    "extent    = [100, lon[-1]-lon_cnt, 0, 85]  # Map extent: 100°E-180°W, 0-85°N (Northern Hemisphere focus)\n",
    "tscmap    = cmaps.BlueWhiteOrangeRed      # Diverging colormap for temperature\n",
    "ssscmap   = ocm.cm.curl                    # Oceanographic colormap for salinity\n",
    "percmap   = ocm.cm.balance_r               # Balanced colormap for freshwater\n",
    "bsfcmap   = ocm.cm.delta                   # Colormap for circulation\n",
    "\n",
    "# label pos\n",
    "lx = 0.025\n",
    "ly = 0.915\n",
    "firstlabel=True\n",
    "\n",
    "for p in range(nrow):\n",
    "    iyr, fyr = plt_years[p][0], plt_years[p][1]\n",
    "    #print(p)\n",
    "    ## 1. (TS + PSL)\n",
    "    ax1 = fig.add_subplot(gs[p, 0], projection=data_proj)\n",
    "    ts_enmean = ts_ens[p]\n",
    "    psl_enmean = psl_ens[p]/100.\n",
    "    CTS = ax1.contourf(lon-lon_cnt, lat, ts_enmean,  bd_ts, transform=data_proj, extend='both', cmap=tscmap)\n",
    "    CPSL_pos = ax1.contour(lon-lon_cnt, lat, psl_enmean.where(psl_enmean > 0), bd_psl[bd_psl > 0], transform=data_proj, colors='red', linewidths=1.0, alpha=calpha)\n",
    "    CPSL_neg = ax1.contour(lon-lon_cnt, lat, psl_enmean.where(psl_enmean < 0), bd_psl[bd_psl < 0], transform=data_proj, colors='magenta', linewidths=1.0, alpha=calpha)\n",
    "    ax1.coastlines(linewidth=0.3, color='black', alpha=0.9)\n",
    "    ax1.set_extent(extent, crs=data_proj)\n",
    "    gl = ax1.gridlines(draw_labels=True, linewidth=0)\n",
    "    gl.xlabel_style = {'size': 8}\n",
    "    gl.ylabel_style = {'size': 8}\n",
    "    gl.top_labels = False\n",
    "    gl.right_labels = False\n",
    "    ax1.set_title(f'Years: {iyr}-{fyr}', fontsize=10)        \n",
    "    ## 2. (SSS + HMXL)\n",
    "    ax2 = fig.add_subplot(gs[p, 1], projection=data_proj)\n",
    "    sss_enmean = sss_ens[p]\n",
    "    hmxl_enmean = hmxl_ens[p]/100.\n",
    "    CSSS = ax2.contourf(lon-lon_cnt, lat, sss_enmean,  bd_sss, transform=data_proj, extend='both', cmap=ssscmap)\n",
    "    CHMXL_pos = ax2.contour(lon-lon_cnt, lat, hmxl_enmean.where(hmxl_enmean > 0), bd_hmxl[bd_hmxl > 0], transform=data_proj, colors='yellow', linewidths=1.0, alpha=calpha)\n",
    "    CHMXL_neg = ax2.contour(lon-lon_cnt, lat, hmxl_enmean.where(hmxl_enmean < 0), bd_hmxl[bd_hmxl < 0], transform=data_proj, colors='cyan', linewidths=1.0, alpha=calpha)\n",
    "    ax2.coastlines(linewidth=0.3, color='black', alpha=0.9)\n",
    "    ax2.set_extent(extent, crs=data_proj)\n",
    "    gl = ax2.gridlines(draw_labels=True, linewidth=0)\n",
    "    gl.xlabel_style = {'size': 8}\n",
    "    gl.ylabel_style = {'size': 8}\n",
    "    gl.top_labels = False\n",
    "    gl.right_labels = False\n",
    "    ax2.set_title(f'Years: {iyr}-{fyr}', fontsize=10)        \n",
    "    ## 3. (PER + ICEFRAC)\n",
    "    ax3 = fig.add_subplot(gs[p, 2], projection=data_proj)\n",
    "    per_enmean = per_ens[p]\n",
    "    ice_con = ice_ens[p]*100.0\n",
    "    CPER = ax3.contourf(lon-lon_cnt, lat, per_enmean,  bd_per, transform=data_proj, extend='both', cmap=percmap)\n",
    "    CICE_pos = ax3.contour(lon-lon_cnt, lat, ice_con.where(ice_con > 0), bd_ice[bd_ice > 0], transform=data_proj, colors='dimgray', linewidths=1.0, alpha=calpha)\n",
    "    CICE_neg = ax3.contour(lon-lon_cnt, lat, ice_con.where(ice_con < 0), bd_ice[bd_ice < 0], transform=data_proj, colors='gold', linewidths=1.0, alpha=calpha)\n",
    "    #CICE_pos = ax3.contour(lon-lon_cnt, lat, ice_con, levels = ice_levels, transform=data_proj, colors='white', linewidths=1.0, alpha=calpha)\n",
    "    #CICE_pos = ax3.contour(lon-lon_cnt, lat, [ice_con.where(ice_con>0), ice_con.where(ice_con<0)][0], transform=data_proj, colors='white', linewidths=1.0, alpha=calpha)\n",
    "    ax3.coastlines(linewidth=0.3, color='black', alpha=0.9)\n",
    "    ax3.set_extent(extent, crs=data_proj)\n",
    "    gl = ax3.gridlines(draw_labels=True, linewidth=0)\n",
    "    gl.xlabel_style = {'size': 8}\n",
    "    gl.ylabel_style = {'size': 8}\n",
    "    gl.top_labels = False\n",
    "    gl.right_labels = False\n",
    "    ax3.set_title(f'Years: {iyr}-{fyr}', fontsize=10)        \n",
    "    ## 4. (BSF + TAU)\n",
    "    ax4 = fig.add_subplot(gs[p, 3], projection=data_proj)\n",
    "    bsf_enmean = bsf_ens[p]\n",
    "    taux     = taux_ens[p]\n",
    "    tauy     = tauy_ens[p]\n",
    "\n",
    "    CBSF = ax4.contourf(lon-lon_cnt, lat, bsf_enmean,  bd_bsf, transform=data_proj, extend='both', cmap=bsfcmap)\n",
    "    CQ = ax4.quiver  (lon[::iw]-lon_cnt, lat[::iw], -taux[::iw,::iw], -tauy[::iw,::iw], \\\n",
    "                        transform=data_proj, color='k', scale=0.5, width=0.003)\n",
    "    ax4.coastlines(linewidth=0.3, color='black', alpha=0.9)\n",
    "    ax4.set_extent(extent, crs=data_proj)\n",
    "    gl = ax4.gridlines(draw_labels=True, linewidth=0)\n",
    "    gl.xlabel_style = {'size': 8}\n",
    "    gl.ylabel_style = {'size': 8}\n",
    "    gl.top_labels = False\n",
    "    gl.right_labels = False\n",
    "    ax4.set_title(f'Years: {iyr}-{fyr}', fontsize=10)        \n",
    "    ## 5. (MOC)\n",
    "    ax5 = fig.add_subplot(gs[p, 4])\n",
    "    moc_enmean = moc_ens[p]\n",
    "    C5 = ax5.contourf(moc_z/100, moc_lat, moc_enmean.T, bd_moc, extend='both', cmap=cmap)\n",
    "    ax5.set_title(f'Years: {iyr}-{fyr}', fontsize=10)\n",
    "    ax5.set_ylim(extent[2], extent[3])\n",
    "    ax5.set_yticks(np.arange(20, 90, 20))\n",
    "    ax5.set_yticklabels(['20°N','40°N','60°N','80°N'], fontsize=8)\n",
    "    ax5.set_xlim(0, 5000)\n",
    "    ax5.set_xticks([0, 2000, 4000])\n",
    "    ax5.set_xticklabels(['0', '2000m','4000m'], fontsize=8)\n",
    "    ax5.grid(linewidth=0.5, color='gray', alpha=0.5, linestyle='--')\n",
    "\n",
    "    if firstlabel:\n",
    "        # Add text with bounding boxes\n",
    "        ax1.text(lx, ly, 'A', transform=ax1.transAxes, size=14, weight='bold',\n",
    "                   bbox=dict(facecolor='white', edgecolor='black', boxstyle='Square'))\n",
    "        ax2.text(lx, ly, 'B', transform=ax2.transAxes, size=14, weight='bold',\n",
    "                   bbox=dict(facecolor='white', edgecolor='black', boxstyle='Square'))\n",
    "        ax3.text(lx, ly, 'C', transform=ax3.transAxes, size=14, weight='bold',\n",
    "                   bbox=dict(facecolor='white', edgecolor='black', boxstyle='Square'))\n",
    "        ax4.text(lx, ly, 'D', transform=ax4.transAxes, size=14, weight='bold',\n",
    "                   bbox=dict(facecolor='white', edgecolor='black', boxstyle='Square'))\n",
    "        ax5.text(lx, ly, 'E', transform=ax5.transAxes, size=14, weight='bold',\n",
    "                   bbox=dict(facecolor='white', edgecolor='black', boxstyle='Square'))\n",
    "        firstlabel=False\n",
    "\n",
    "\n",
    "plt.subplots_adjust(left=0.1, right=0.9, top=0.9, bottom=0.2, wspace=0.2, hspace=0.2)\n",
    "\n",
    "titles = ['Surface Air Temperature\\nMean Sea Level Pressure', 'Sea Surface Salinity\\nMixed Layer Depth',\n",
    "           'Precip - Evap + Runoff\\nSea Ice Fraction', 'Barotropic Stream Function\\nSurface Wind Stress', 'AMOC']\n",
    "for col, title in enumerate(titles):\n",
    "    fig.text(0.17 + col * 0.165, 0.93, title, ha='center', va='center', fontsize=12, fontweight='bold')\n",
    "bar1y = 0.14\n",
    "bar2y = 0.088\n",
    "cbar1 = fig.colorbar(CTS, cax=fig.add_axes([0.105, bar1y, 0.125, 0.01]), orientation='horizontal') # [left, bottom, width, height]\n",
    "cbar1a = fig.colorbar(CPSL_neg, cax=fig.add_axes([0.10, bar2y, 0.0625, 0.01]), orientation='horizontal') # [left, bottom, width, height]\n",
    "cbar1b = fig.colorbar(CPSL_pos, cax=fig.add_axes([0.175, bar2y, 0.0625, 0.01]), orientation='horizontal') # [left, bottom, width, height]\n",
    "\n",
    "cbar2 = fig.colorbar(CSSS, cax=fig.add_axes([0.271, bar1y, 0.125, 0.01]), orientation='horizontal') # [left, bottom, width, height]\n",
    "cbar2a = fig.colorbar(CHMXL_neg, cax=fig.add_axes([0.265, bar2y, 0.0625, 0.01]), orientation='horizontal') # [left, bottom, width, height]\n",
    "cbar2b = fig.colorbar(CHMXL_pos, cax=fig.add_axes([0.34, bar2y, 0.0625, 0.01]), orientation='horizontal') # [left, bottom, width, height]\n",
    "\n",
    "cbar3 = fig.colorbar(CPER, cax=fig.add_axes([0.44, bar1y, 0.125, 0.01]), orientation='horizontal') # [left, bottom, width, height]\n",
    "cbar3a = fig.colorbar(CICE_neg, cax=fig.add_axes([0.435, bar2y, 0.0625, 0.01]), orientation='horizontal') # [left, bottom, width, height]\n",
    "cbar3b = fig.colorbar(CICE_pos, cax=fig.add_axes([0.51, bar2y, 0.0625, 0.01]), orientation='horizontal') # [left, bottom, width, height]\n",
    "\n",
    "cbar4 = fig.colorbar(CBSF, cax=fig.add_axes([0.605, bar1y, 0.125, 0.01]), orientation='horizontal') # [left, bottom, width, height]\n",
    "ax4.quiverkey(CQ, 0.65, bar2y, 0.05, '0.05 N/m²', labelpos='E', coordinates='figure', fontproperties={'size': 10})\n",
    "\n",
    "cbar5 = fig.colorbar(C5, cax=fig.add_axes([0.77, bar1y, 0.125, 0.01]), orientation='horizontal') # [left, bottom, width, height]\n",
    "cfbars = [cbar1, cbar2, cbar3, cbar4, cbar5]\n",
    "cclbars = [cbar1a, cbar2a, cbar3a]\n",
    "ccrbars = [cbar1b, cbar2b, cbar3b]\n",
    "cfunits = ['[°C]', '[g kg$^{-1}$]', '[mm day$^{-1}$]', '[Sv]', '[Sv]']\n",
    "ccunits = ['[KPa]', '[m]', '[%]']\n",
    "for x in range(ncol):\n",
    "    cfbars[x].ax.tick_params(labelsize=10)\n",
    "    cfbars[x].ax.set_title(cfunits[x], fontsize=10)\n",
    "    #plt.setp(cfbars[x].ax.get_xticklabels(), rotation=45, ha='right')\n",
    "for x in range(3):\n",
    "    cclbars[x].ax.tick_params(labelsize=10)\n",
    "    cclbars[x].ax.set_title(ccunits[x], fontsize=10, position=(1.1, 1.1))\n",
    "    plt.setp(cclbars[x].ax.get_xticklabels(), rotation=45, ha='right')\n",
    "    ccrbars[x].ax.tick_params(labelsize=10)\n",
    "    #ccrbars[x].ax.set_title(ccunits[x], fontsize=10)\n",
    "\n",
    "    plt.setp(ccrbars[x].ax.get_xticklabels(), rotation=45,  position=(0.1, 0.02))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "fce6422e",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (geosci)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
