rsntds#

# Parameters
variable = "rsntds"
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 rsntds 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/85d547978fa3c606caf10b0d60ee87a9f41043262b259034d1e0c7a16ee54bd1.png _images/43118a3ee5a4f9978e031f456d42b0c04c12b3f97404520f1538a451db59fba3.png

PersianGulf#

reg = 'PersianGulf'
ts_plot(variable, ds, fs, label, reg = reg)
_images/610b0a527af14252630e4b1e68c0ed7ff1b7b7ef2e31f42aee94fdc59045844b.png _images/7ca3d904b922489204a473cf8d9272d5d5c834f8e0bd368fd06b89b7698de085.png

RedSea#

reg = 'RedSea'
ts_plot(variable, ds, fs, label, reg = reg)
_images/69cb5b3d679cc2da9f7f78ed96366a9249abc761ed30ace34c2bfd5558615fd7.png _images/71e9e0ec881ae61d55d215e0e29a2b5966201ce768f2c8ef0e2964fa12387c5e.png

BlackSea#

reg = 'BlackSea'
ts_plot(variable, ds, fs, label, reg = reg)
_images/c85ce7b65c75abc56264b1a5bba10565c446a921ccac79d32cc151e7d33dea18.png _images/2ffb12ff387f571c564bc08e6af264e9fe212e61859ac71ed320fff599b69fce.png

MedSea#

reg = 'MedSea'
ts_plot(variable, ds, fs, label, reg = reg)
_images/c67219000f65712ac7f89a402873a60f6a40ec8ef7210fd633ec24fbea8ba5ac.png _images/4d2c826f6af51e301ce4f52fc005d50bbdfb37d235ce9912133420b15c7ba3a6.png

BalticSea#

reg = 'BalticSea'
ts_plot(variable, ds, fs, label, reg = reg)
_images/9dd0bebee5649b8f5f8ff1f84d9aa3eb6b9c955ecfa5135f3b3a8051b7add05b.png _images/55684d7583ef0fef523cee897585577be4ce976697b4ebb5a6e64cd4ec4cd4bf.png

HudsonBay#

reg = 'HudsonBay'
ts_plot(variable, ds, fs, label, reg = reg)
_images/49a3ad536592df73e951dda884657aaffd5af69858685ce813cd2832483ce248.png _images/0a629533cf2085f42f232cec57af7a11ac6fc87deb2dd00d41af84ebf5ffc2d3.png

Arctic#

reg = 'Arctic'
ts_plot(variable, ds, fs, label, reg = reg)
_images/cc24b8279c9d4a46b4cb6aa9895dde9b77d65f509692fefa1d0f0ccc88bb8a18.png _images/0e962048450cac7b46d12a6218dcc756c20cee407c69ef7ffd151ba4c45bda1d.png

PacificOcean#

reg = 'PacificOcean'
ts_plot(variable, ds, fs, label, reg = reg)
_images/f75388960da41323ca2a900e4af25b2f7914cff535d671168120c6cb579f95d3.png _images/c6d5d35f529bcb656cec141d009d6d6cb15926ff59424d534fa030986d4d7dec.png

AtlanticOcean#

reg = 'AtlanticOcean'
ts_plot(variable, ds, fs, label, reg = reg)
_images/ce2f7ea85c9bcc96522a27afbb354c9b60324deeb3d643c6f0f7721c457fae8e.png _images/c61bd1f91c7457bc6031eefd5ea48df1f630494511688ce3f38d8a5c291cb268.png

IndianOcean#

reg = 'IndianOcean'
ts_plot(variable, ds, fs, label, reg = reg)
_images/1d66037ffdf937dc9b9385f5400365ed50ccd5a2040bea48cadc2596755ec8d7.png _images/15e82872c902a621e26c37d33979af3b4f4279c7a916496742813ef5e29bf9c4.png

SouthernOcean#

reg = 'SouthernOcean'
ts_plot(variable, ds, fs, label, reg = reg)
_images/a1c1e905fb656f8f375bdee8e0f5a661da3bd8f56f121b068a2464b4d47e20b4.png _images/fcf6a1bb2d2bf9f5dec49a1b91df00cea54aaf1bc692ca9724840eeb99425f1a.png

LabSea#

reg = 'LabSea'
ts_plot(variable, ds, fs, label, reg = reg)
_images/1f63456101aa141dcef1a5f286662e08f4c7f4c91eb010e1aa1f5bc928ee804d.png _images/ca99a18a8a64f223942efef7582c738360c1a8b600acbc14d0f0e26359ab39c0.png

BaffinBay#

reg = 'BaffinBay'
ts_plot(variable, ds, fs, label, reg = reg)
_images/6128d705afdaf86fbf1cfc2ce1539580b73f7e206081694bc04739223847b3b6.png _images/c5f147a8e9c1d3ae33ad10668e90b9d7fdda822bab52cb5efc1f362877a6cef1.png

Maritime#

reg = 'Maritime'
ts_plot(variable, ds, fs, label, reg = reg)
_images/1889077940e86360fdaf1b4d77ca077a0c97ad7ace37a092860c36c44c4d9553.png _images/f37ae7c793a34cab38e548b48e1b27c3f2632b1a2fbfed43800c83148c71bd93.png

SouthernOcean60S#

reg = 'SouthernOcean60S'
ts_plot(variable, ds, fs, label, reg = reg)
_images/8604169698cf5326aec5afe25856c8cb284f11075044a73227f1caeba7d1c519.png _images/ab6d173d5147f720fa2378a1ebf53f2cb27e5ed66ccc7068f602e9ba36b9615b.png

EGreenlandIceland#

reg = 'EGreenlandIceland'
ts_plot(variable, ds, fs, label, reg = reg)
_images/34ff9d1694b59f0d5aa042d79e57a690c1145f75379fc0ae45f452c3519ccf99.png _images/5eb27b6f056a96f7ef78b959dd0b29c33294cd7b11caf457260f30448fd75cf8.png

GulfOfMexico#

reg = 'GulfOfMexico'
ts_plot(variable, ds, fs, label, reg = reg)
_images/cf4f8728f28930cf051ee5d4ba40699cd3484b362390ae278bf5fc6f481bd307.png _images/cfe07cd263a6d6fb6174a5af20a3aa2103be6f2f9b0add173ba3d9401fbe3e7c.png