Heat_PmE#

# Parameters
variable = "Heat_PmE"
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 Heat_PmE 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/efc343c1edf28ef71df72997bc769bbf0d504c626979903de357406d0fb2809f.png _images/b7c9799f8d41c15a061ad6974d04e32c00dc0b9c1890adac816779f4696b430a.png

PersianGulf#

reg = 'PersianGulf'
ts_plot(variable, ds, fs, label, reg = reg)
_images/3c718cb87626789f8f25c8c02c85ea12647b62bbd3c41770da34ed4646b9f250.png _images/9aed58d2269fffb87d371959b0271ecd2a2ab65cfda79e45099d9e17ce2f4503.png

RedSea#

reg = 'RedSea'
ts_plot(variable, ds, fs, label, reg = reg)
_images/011926b5de9a1610c90a8b5f20781eb5211863c197cc3a9a0ae91cd4841b6408.png _images/5b1e9fce70c055d53dcae666437627e2dd37f21f0dd766d2798d4a7964602e5e.png

BlackSea#

reg = 'BlackSea'
ts_plot(variable, ds, fs, label, reg = reg)
_images/8268486cedc91fbb7b38e737a566d809e7bf592fa40db6e82379d62c3dc5292c.png _images/12aedb715b46768b29cb32c5736abdd129a1dc783cc2ed31a09ce5648b55a1da.png

MedSea#

reg = 'MedSea'
ts_plot(variable, ds, fs, label, reg = reg)
_images/63b1a90bd40e42aba3c17db6a291600b6f51a9fe026932076f23621cc546303c.png _images/1ce1dff316512c81b75b03a182d8cc244b250c199c9eaa7b213ecb0ba329bd6c.png

BalticSea#

reg = 'BalticSea'
ts_plot(variable, ds, fs, label, reg = reg)
_images/a7ef556310f5c47347ed48dd6af524f8b30b022ce4cb42471effe82568d1ebf8.png _images/cfca0ba549e0d945c213bb9ac1508359e4df29d0d919509da1a9fecfa7414d9b.png

HudsonBay#

reg = 'HudsonBay'
ts_plot(variable, ds, fs, label, reg = reg)
_images/03f32c75dc62a216ce2ef301ff2e00dedc596435b26382143b4df5f825430306.png _images/720cbc6e386a2b25663e9f53ead84bd62eff2a4d7144325d385ef20d1cc89734.png

Arctic#

reg = 'Arctic'
ts_plot(variable, ds, fs, label, reg = reg)
_images/7f1673178a0bed1eb543f1994d16b82082b34f84209f19c6a26805d6c2af124c.png _images/852346acc7a9947cbd8f76348a6621388461be05e4f72e3c20c60ec50775da09.png

PacificOcean#

reg = 'PacificOcean'
ts_plot(variable, ds, fs, label, reg = reg)
_images/880cdf9a0f7c955225a6229b78e05c2325df59b1d741d250acc5defc9caa1e5f.png _images/74209d5190de83fc7df017ca1eb7122d455c761dd44609fc318dd8466045a48e.png

AtlanticOcean#

reg = 'AtlanticOcean'
ts_plot(variable, ds, fs, label, reg = reg)
_images/8c175b8bf1f2df21396421e14e0af97a528f8ce699f4af18e89d1a4d0ec55486.png _images/ea46782e55814263d6fdf417b26479b20a4bda302c98a6c700337196d871a787.png

IndianOcean#

reg = 'IndianOcean'
ts_plot(variable, ds, fs, label, reg = reg)
_images/8be7ad7f792d5de2b8557254e9af1d1f1d6cceed8fef00fa57c235b674af80d3.png _images/61db541304f0f6f15a16a6218ee33443751a2a45df4930df810cfbc9ad5069fe.png

SouthernOcean#

reg = 'SouthernOcean'
ts_plot(variable, ds, fs, label, reg = reg)
_images/d9471486a0bbf7ac37068957f42e92faedd65467ae948556cc396cfa942ec092.png _images/0e4dd320d5c355e34a59cda8ad3d243b264c163e8fe754ac1d173c1244939379.png

LabSea#

reg = 'LabSea'
ts_plot(variable, ds, fs, label, reg = reg)
_images/89f4908f1804011137c111cf72f12f7f24f96959885a5aa9904c11c4fc5f5ca5.png _images/0a41751739f7a4d76248391fe2d6894021780edc650e81ccc359254c4d105d6d.png

BaffinBay#

reg = 'BaffinBay'
ts_plot(variable, ds, fs, label, reg = reg)
_images/01f4b46e1a1410efdd1d12eac84c865dcfdcb5a620692559ab0626c98012a417.png _images/dfdbb7c194cdf305d3d6c31481dcb1d17fef71397b70897a696b2762071b4def.png

Maritime#

reg = 'Maritime'
ts_plot(variable, ds, fs, label, reg = reg)
_images/5f855bf91a8603eccf93e6196255ef117880b2f6817f21fc3bd301386e519229.png _images/acdc6c712b4a909c1a74c7d82cdd5c83b13b5803b170912989ee1fd7e5fc0214.png

SouthernOcean60S#

reg = 'SouthernOcean60S'
ts_plot(variable, ds, fs, label, reg = reg)
_images/ade767a6615c396a5a90553801bcef68e15f521f622a03af4634c7e08b1c4868.png _images/9d8a1d3004751a4336adb6e90208e3a5f7ef4bbbef197bf2d83ade3cd63322b0.png

EGreenlandIceland#

reg = 'EGreenlandIceland'
ts_plot(variable, ds, fs, label, reg = reg)
_images/73892d4ab30993ebe6db796ec2d298333456c0524cb6196aa273973db47dce4a.png _images/cc7073dd64cfe535a9205d587a2bfa489a14f241a788a0cae7123f8d032f5313.png

GulfOfMexico#

reg = 'GulfOfMexico'
ts_plot(variable, ds, fs, label, reg = reg)
_images/d788a324ae53fbb8547a25a9cdc43070692940bf138bd32d8db06fe4c912724c.png _images/6ceab897f67dfc8e9717ae86d02e40aa590df1cc05dcf90270413fa60de63626.png