heat_content_lrunoff#

# Parameters
variable = "heat_content_lrunoff"
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_content_lrunoff 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/8af2eaefb618fa0b5e45a2407200919d864f9f2d56d26753662cf1a559483b3c.png _images/1234874320696057a946ecb34e0c2b01c31cb54b4f490455faa1166efde4c20e.png

PersianGulf#

reg = 'PersianGulf'
ts_plot(variable, ds, fs, label, reg = reg)
_images/0f2246d1d2b2031fbb4229f51b8e8254206e4116edb0bcba44363f258cbbd045.png _images/15c8361ab6558ee2d984395d333b46bc1e9851cf193633ed28d81c41c85ab2eb.png

RedSea#

reg = 'RedSea'
ts_plot(variable, ds, fs, label, reg = reg)
_images/7519c5631974fb16518779f443dbe8eb1c8be7ccfa3d13887a88d2c975fef6c2.png _images/bcf6c203ff6b2c36eb09aa404c9bccc8b723a6f34edc875493667718038720d4.png

BlackSea#

reg = 'BlackSea'
ts_plot(variable, ds, fs, label, reg = reg)
_images/f4648427e701f81ae6ecd71f62452f90f8adb399cdef2de4ce0de0df8d638810.png _images/0c05d207e2976c8991f60f85112d2d59cd8adfacc02b1dca8c2417eec33e3b04.png

MedSea#

reg = 'MedSea'
ts_plot(variable, ds, fs, label, reg = reg)
_images/72443ff0d1fb5cfad7150fc7f27d772f1c86cdcba7d4a880c5bef03b18e4edd3.png _images/3854b841269b0775da2ece4b7e6c06d5556675e3dc47c87f565a2de278ff2c8c.png

BalticSea#

reg = 'BalticSea'
ts_plot(variable, ds, fs, label, reg = reg)
_images/d3651b6041987543c148d172d7f0d1845fad7ce52ab4ecb7cc110871a910a986.png _images/875e1407427361dc3308e94432069a65e9650c00463baf03501326601d8e3c08.png

HudsonBay#

reg = 'HudsonBay'
ts_plot(variable, ds, fs, label, reg = reg)
_images/c0608b093ffde97a09f03a771b5b8cbcab929d6a17fe09cdc2db803948af5544.png _images/9aaecaa19433f071af3e84bb02247519bff913c51812c2285f693bb8729ff815.png

Arctic#

reg = 'Arctic'
ts_plot(variable, ds, fs, label, reg = reg)
_images/d5e555d9ab8c0a144a1afdee8377216643ce789e28b406354fb024df094f2199.png _images/3c1144daccf59a133d8e8db2b5037ef15bf4c79764d632d1e6fd2307dc9c476b.png

PacificOcean#

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

AtlanticOcean#

reg = 'AtlanticOcean'
ts_plot(variable, ds, fs, label, reg = reg)
_images/37c94c08d75fed4d8cc8e742fcde7ee6c84f2f65b88c4c3ad20e103c8b4a2bfd.png _images/6de03395615df24db3d521ff43edf1eb3636a3b4df24aa3757c38fa06f9e35d1.png

IndianOcean#

reg = 'IndianOcean'
ts_plot(variable, ds, fs, label, reg = reg)
_images/7b2305d46e8cc4b60cc83a47ec4659a9d498af62db1fa83da24e86c6506b7fe2.png _images/de117ca1a2d1f8013ae67bfbcd151934c915910c1574d22d3264c6fe8155b370.png

SouthernOcean#

reg = 'SouthernOcean'
ts_plot(variable, ds, fs, label, reg = reg)
_images/0273f41e0f88d00370d0cb46b349805aeed3f8f6311436accd154ac5fd8f5db2.png _images/dc54d6dc5fd7fd498c07e3665179a8276f63118e161c7ca2d7a3cfe583837495.png

LabSea#

reg = 'LabSea'
ts_plot(variable, ds, fs, label, reg = reg)
_images/5f914c6a584fda812ba89dcddc27a538b0a67b2eaae9434e597eef26cfa541a7.png _images/9cdb4e659d5a556ceefc286d733cdd0b44190d8f4937db59c2e212c26e9e2685.png

BaffinBay#

reg = 'BaffinBay'
ts_plot(variable, ds, fs, label, reg = reg)
_images/724c0f63600d655b312c9f0a07f9da02392b91114a3dee0fe9909892f8dc421d.png _images/3c00e3287d62fec89364ee572fb274295bbeff59583ccaa32d25fca8f7054e99.png

Maritime#

reg = 'Maritime'
ts_plot(variable, ds, fs, label, reg = reg)
_images/2d556abe9d756dcaeae02e51a70e52d2afc51388036bce3c836af2a710c53177.png _images/2726e96e549515cf7f831795bd61c37a4aeb08849264447fe984561bd1142b67.png

SouthernOcean60S#

reg = 'SouthernOcean60S'
ts_plot(variable, ds, fs, label, reg = reg)
_images/22a712528cde0673809347cbf29abba2e9f86ac46a19b91a89a15ec15a6eeef6.png _images/b4afdc6584717634d140ddf45c49c310036b6fa0d1d3cbb6397a554618363e20.png

EGreenlandIceland#

reg = 'EGreenlandIceland'
ts_plot(variable, ds, fs, label, reg = reg)
_images/b97f0aa2ba55f843a3c57c23f2db52fbcc103c2cedd12882e72248167dc85364.png _images/01273b287454270a02561acfc1a77b17cb8da153717d6825a4490629bc421665.png

GulfOfMexico#

reg = 'GulfOfMexico'
ts_plot(variable, ds, fs, label, reg = reg)
_images/eeca78ad6ae9bb40f617321040a20ca12288baefaae22b62aba6059dbdb9400a.png _images/3e5282324402a232d223fb24c95199ecaec50c595d6dd659ce0d86f5aee56d3f.png