rlntds#

# Parameters
variable = "rlntds"
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 rlntds 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/c690e276457c23eb97f0a91b165b36206dd0332c87e9f96f004d871cf0f021b0.png _images/e3c1fde724beb5c38e4b530ee1ced205b9fcb5ac35e6228093bef8494c06d509.png

PersianGulf#

reg = 'PersianGulf'
ts_plot(variable, ds, fs, label, reg = reg)
_images/8b1ae9ac0d9078db7b132b2c07f197591e8a5919fe91eba3e42e4629605e2766.png _images/a8a4721b7e78daf0893c8c37a5f807a8b2a9df1b3379643638341028d5dadec7.png

RedSea#

reg = 'RedSea'
ts_plot(variable, ds, fs, label, reg = reg)
_images/53cb70c27444ad7d5b465bde1822fd4ec9064a2b8c77d3a528eed69137f45903.png _images/309c90fcd6bd5991ab686410db4b523349a001a31179469fbb50ca951e032714.png

BlackSea#

reg = 'BlackSea'
ts_plot(variable, ds, fs, label, reg = reg)
_images/08d334b0bd6ebf3eb7ba4b89e47a545efb1c0b751d16223ffc5246d044ab9155.png _images/41cd64fa52d270a3ab267df96952df09e05033da02e99fc10d8b73017b0f1d79.png

MedSea#

reg = 'MedSea'
ts_plot(variable, ds, fs, label, reg = reg)
_images/b850f7709dfccb95e321f6e01b06c0cd8f706016ae13f5e4141fda7880bfc30c.png _images/c5f4a6bbac71f267e2ee50147cff7a885b3bb9fa8351e7bc2ea70d7cbe2365ac.png

BalticSea#

reg = 'BalticSea'
ts_plot(variable, ds, fs, label, reg = reg)
_images/877b028740054431e2719a517f3f8869f84802ca9af3781d3b5df8198d6fdab9.png _images/61dfe52e59f509b0d68e5e0865d366f28238024d56e0c63e1d7bc7c2a9aa8ee3.png

HudsonBay#

reg = 'HudsonBay'
ts_plot(variable, ds, fs, label, reg = reg)
_images/03d18827b6cfe21d49e2ff3b7015d324bb1a1ce1d6b205109c4d76b3842424e7.png _images/b9b8e57a98bf1734ff5d4c288795e9b7fa00abc74010dbda10dbc6b7ae6bf2d4.png

Arctic#

reg = 'Arctic'
ts_plot(variable, ds, fs, label, reg = reg)
_images/900ddb82719cccfeec35cd76f4923ca21a5afa55513b064cd2f410014ee48b59.png _images/1e33f2ec15250f31427bb52b76bf11e63a714acf1a21b55bb2936daf389339d4.png

PacificOcean#

reg = 'PacificOcean'
ts_plot(variable, ds, fs, label, reg = reg)
_images/f789c8035b98fbdf0cf890ee601eec573ad50176270503b542a791fc44d06cef.png _images/54a4b632122ab740a28ac3a50dfd6f60c081d155904158bdc7bee002c9123424.png

AtlanticOcean#

reg = 'AtlanticOcean'
ts_plot(variable, ds, fs, label, reg = reg)
_images/29185528a25abec82682346e4d83b501e7e368a3b56d0f83720ea9884d6fbc6f.png _images/fb0f64ba4f824a2ca91cb6caf16d31a8a04cc3344b83fc421990a888f85b13ce.png

IndianOcean#

reg = 'IndianOcean'
ts_plot(variable, ds, fs, label, reg = reg)
_images/f76895008463a66d2090c136b73a7bc735e84e4db7baa7b01296210b2052459b.png _images/912c787954476f54a0983a66e7160479295e63724ff7136fad424a6ba344ddf8.png

SouthernOcean#

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

LabSea#

reg = 'LabSea'
ts_plot(variable, ds, fs, label, reg = reg)
_images/f814f3f48640943ffe08a74fef458fa48290e504f2672e2f8f453321fec7a1ba.png _images/d76059eac16b6dd2448fcbd4b21fc2f23bbd7063325ed09fda8157c5ad5ba519.png

BaffinBay#

reg = 'BaffinBay'
ts_plot(variable, ds, fs, label, reg = reg)
_images/d710860614b11671e306dd27c50980bc69833d0442145c5cb37ecd4ef6775bd7.png _images/63ca991eeb521547936522c7fe1c5c7f3b29213da4e8f15c62dff2b39ac1c074.png

Maritime#

reg = 'Maritime'
ts_plot(variable, ds, fs, label, reg = reg)
_images/b66e834e8f6652ba7a3ef85221cd0073e32ee25729b0cab8186587c8325a2214.png _images/040fc13235639d54bc6e2a3519a8308628957c38b38878dfec6466220081f938.png

SouthernOcean60S#

reg = 'SouthernOcean60S'
ts_plot(variable, ds, fs, label, reg = reg)
_images/7cbd05a2198ee28822c4c1716128a689419833f2276f4487c181f89130406351.png _images/9954892eeaa4404ab3b7935872d4cba19966605183e4fc1639c9ae173fc8b00f.png

EGreenlandIceland#

reg = 'EGreenlandIceland'
ts_plot(variable, ds, fs, label, reg = reg)
_images/46637fb2cc0359df1a3f86d480a61c42dce603f5acbd8720202aa631a1285603.png _images/eb0287b63d5c625e6f46f10befdc7a1d573bfecc8be8e732def6f099d0dd8780.png

GulfOfMexico#

reg = 'GulfOfMexico'
ts_plot(variable, ds, fs, label, reg = reg)
_images/723d1a4efb5b8f144c51a96c6f8c87752e7ad7748eb00ebf4a563251cdde1a2c.png _images/0653b55b9abbfbafc18e16189f68cf787b2be44397a9a7cb5b2890a07441f71a.png