evs#

# Parameters
variable = "evs"
from IPython.display import display, Markdown
# Dynamically generate markdown content
markdown_text = f" This notebook compares area-weighted mean and, in some cases, integral time series for {variable} in different basins."

# Display the updated markdown content
display(Markdown(markdown_text))

This notebook compares area-weighted mean and, in some cases, integral time series for evs in different basins.

%load_ext autoreload
%autoreload 2
%%capture 
# comment above line to see details about the run(s) displayed
from misc import *
import glob
print("Last update:", date.today())
%matplotlib inline
# figure size
fs = (10,4)
# load data
ds = []
for c, p in zip(casename, ocn_path):
  file = glob.glob(p+'{}.native.{}.??????-??????.nc'.format(c, variable))[0]
  ds.append(xr.open_dataset(file))
def ts_plot(variable, ds, fs, label, reg='Global'):
    """
    Plot time series of regional means and integrals for a given variable from a list of datasets.

    Parameters
    ----------
    variable : str
        Name of the variable to plot (prefix for "_mean" and "_int" variables in dataset).
    ds : list of xarray.Dataset
        List of datasets, each containing time series data for the specified variable with
        variables named as `<variable>_mean` and optionally `<variable>_int`, and with
        attributes 'long_name', 'units_mean', and optionally 'units_int'.
    fs : tuple
        Figure size (width, height) in inches for the plots.
    label : list of str
        List of labels corresponding to each dataset, used for the legend.
    reg : str, optional
        Name of the region to select for plotting (default is 'Global').

    Returns
    -------
    None
        Displays the plots but does not return any value.

    Notes
    -----
    - This function creates one or two plots:
        1. A time series of the variable's regional mean (`<variable>_mean`).
        2. If available, a time series of the variable's regional integral (`<variable>_int`).
    - The function expects each dataset to have attributes 'long_name', 'units_mean', and optionally 'units_int'.
    - The same region name is applied across all datasets.
    """
    
    fig, ax = plt.subplots(nrows=1, ncols=1, figsize=fs)
    for l, i in zip(label, range(len(label))):
        ds[i][variable+"_mean"].sel(region=reg).plot(ax=ax, label=l, lw=3)
    
    long_name = ds[0].attrs['long_name']
    ax.set_title("{}, {}".format(reg, long_name))
    ax.set_ylabel(variable+"_mean, " + ds[i].attrs['units_mean'])
    ax.set_xlabel('Year')
    ax.grid()
    ax.legend(ncol=3, loc=1)
    
    if variable+"_int" in ds[0]:
        fig, ax = plt.subplots(nrows=1, ncols=1, figsize=fs)
        for l, i in zip(label, range(len(label))):
            ds[i][variable+"_int"].sel(region=reg).plot(ax=ax, label=l, lw=3)

        ax.set_title("{}, {}".format(reg, long_name))
        ax.set_ylabel(variable+"_int, " + ds[i].attrs['units_int'])
        ax.set_xlabel('Year')
        ax.grid()
        ax.legend(ncol=3, loc=1)

    return

Global#

reg = 'Global'
ts_plot(variable, ds, fs, label, reg = reg)
_images/a15e2786e8b41f69fa4f3344882ed6a1bc8e8129f106f62adec42f8593762519.png _images/077d296ddf8a885cb69def75173bb6e35abbc492e713c9b3524ae0ed3c6f46ce.png

PersianGulf#

reg = 'PersianGulf'
ts_plot(variable, ds, fs, label, reg = reg)
_images/16158f50930d27c08e2cf11ff3e63583fc866a514a68e14110865a0291b44fed.png _images/64284abf22d16e889f0e5ec0f64d94ee547867098ebd1865d5d6ddb7e3a4a3a7.png

RedSea#

reg = 'RedSea'
ts_plot(variable, ds, fs, label, reg = reg)
_images/0c987282c42f519bc8f7900ca57fefbd19f8a681c56ea04bb63e47f44a21fccd.png _images/9379711e7079d6fbc694a9274fa9fb3de5b72bbe32cd80e9150ec1ae6c1360e4.png

BlackSea#

reg = 'BlackSea'
ts_plot(variable, ds, fs, label, reg = reg)
_images/f128f052b8ca415414bf8bbc0ea861199aaad8d5604cb4f1a8966109a3528420.png _images/1e9ef65d3f1248a42801f314bafd032c75139825bbc435f0fc490acea1c50c81.png

MedSea#

reg = 'MedSea'
ts_plot(variable, ds, fs, label, reg = reg)
_images/4563be0e32890d11a43f638e5e094a483ff0f4ab1aa7acd2b878ad13250dbc78.png _images/5f7c0103535eaeba5d36919f7ac2ffeaeb6cb998e1ba599bac24b118dd406867.png

BalticSea#

reg = 'BalticSea'
ts_plot(variable, ds, fs, label, reg = reg)
_images/60149dc260f0b8330bc9a188f2d7ca89ace6ca74da86c175fbb86d879bb76c7c.png _images/5aa34878d17e57607d306581b14b0619de9b255fa3ad24da86439eb195777b73.png

HudsonBay#

reg = 'HudsonBay'
ts_plot(variable, ds, fs, label, reg = reg)
_images/66a45b039de28e1a9fbe98cd5c124b0d6d8e74c7d37f95d1866362582faaa7be.png _images/826bfde5d50bf37686b42cf26276017c55bf1ba195fa4eb9c07e725dc759b346.png

Arctic#

reg = 'Arctic'
ts_plot(variable, ds, fs, label, reg = reg)
_images/15c2e040d45ce8dc00566e802e9b7dcc91b1deae21fe75337e9b6e1d8a0424b8.png _images/548f56cae7aec0290be2bb7c1df31304beffbfd18f51f9e112e39b63783b83ff.png

PacificOcean#

reg = 'PacificOcean'
ts_plot(variable, ds, fs, label, reg = reg)
_images/c189ff6e647553853f4f3b111c933121efcb84aa6ba6c3440dfb4e09212a703a.png _images/969d6ffeb4225197df557cffde3d2d202458b9be698a8387f406ec61f7d8e594.png

AtlanticOcean#

reg = 'AtlanticOcean'
ts_plot(variable, ds, fs, label, reg = reg)
_images/9d228e06628512dd32125206da39aeaf7050375d389b94f0821b28f8f482911e.png _images/f1c334059ea4e726b7c0fac2a9ea5bf060f5a444b2158e54375f4d34dca10f7b.png

IndianOcean#

reg = 'IndianOcean'
ts_plot(variable, ds, fs, label, reg = reg)
_images/0ef389fc90a025dd8f8351e4182a74fdc49d18e2dd1d2cfaf788edf0b36bdbf8.png _images/e8003d4c2f5f2c5c82e45e324b9b34219dbf979a3ec8e43ed0b5cfd6f46eef26.png

SouthernOcean#

reg = 'SouthernOcean'
ts_plot(variable, ds, fs, label, reg = reg)
_images/b8257f7234eeef2159a6d9c5beff13a488549fd378ac4a65a90758eaa4d88760.png _images/69ae119acc20364edae956e0913932624697456787e9deafdcb5a2bb76e8ac50.png

LabSea#

reg = 'LabSea'
ts_plot(variable, ds, fs, label, reg = reg)
_images/929567c59070c83ac3ba8966a046d1e95ad95e49cf98d2ad1887c4b60170b641.png _images/c9bc37438e9fd50c60b31d7185f316d34a39751956fb3421df61798557d8f2ee.png

BaffinBay#

reg = 'BaffinBay'
ts_plot(variable, ds, fs, label, reg = reg)
_images/9209ce791e127ddce34924c14020304458de94485fa9f17205b977f607022ad5.png _images/42bf331d5532065e1f8de724440b319060080e11ef139839997bfdbbd552d925.png

Maritime#

reg = 'Maritime'
ts_plot(variable, ds, fs, label, reg = reg)
_images/a0312981bf71a599f7e21ad983a30f9072a6d00bf1d098a835a576a4dcea9afd.png _images/559fb245e49825612b7ae237f00f18ea22b401042269f4f0111b636ec8960bf4.png

SouthernOcean60S#

reg = 'SouthernOcean60S'
ts_plot(variable, ds, fs, label, reg = reg)
_images/d555aa1f46354cf133712d7bd37b25c6dfdecdc538eef99411b6fee9f6da2026.png _images/79762582fa25684019b9bcba0e9261ed8cc2b93ca37e2989f5d0cf13fef73d41.png

EGreenlandIceland#

reg = 'EGreenlandIceland'
ts_plot(variable, ds, fs, label, reg = reg)
_images/674ccf896becf51aed70d066719f90cf4c281d63eea29155f72ae20a3b9a1ea9.png _images/116ba7ee9b25f7e9d18d54f41a6f76634a6b14638d04b31dc17c67a24d72ec80.png

GulfOfMexico#

reg = 'GulfOfMexico'
ts_plot(variable, ds, fs, label, reg = reg)
_images/966f0adcffb20dda1e31320179ef6160f7be4b222679bcd14a5f90b3f514e2df.png _images/9132300a4f58fb5dcf1c513d9c7085f744c7fec81d46648ac703c10f07834985.png