heat_content_fprec#

# Parameters
variable = "heat_content_fprec"
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_fprec 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/e620f44e68eedc5750ae572ec3f40b7b80f73acc2029b30301ab13df61d20d11.png _images/1650f78374558a3da2151a6a4718bbe5bbab663131b155a5c81750a20e9a8d15.png

PersianGulf#

reg = 'PersianGulf'
ts_plot(variable, ds, fs, label, reg = reg)
_images/b6883136873e3ec3e54ed404ef3c19be28ba2ef8ece0c1e96cd7577c41a91201.png _images/81e7f8862532bb705348fd7d2ad27a253bf9e61f05bd0f9de5dbed29d8d6cf55.png

RedSea#

reg = 'RedSea'
ts_plot(variable, ds, fs, label, reg = reg)
_images/de7b42e8aa1c77a7a69493463b65aa5252a66aa006ebba57799653c37993d9e4.png _images/e08dabe14fb7c83dfe20363b04906a868f765f3b0ea7b0fba5ea15eb4a31f882.png

BlackSea#

reg = 'BlackSea'
ts_plot(variable, ds, fs, label, reg = reg)
_images/6a1676059142e8af63cfa2280bedecded9f37fb4ca938570406951d4357dbf30.png _images/52a335ad3ab1bb64c01004c0eab85164dd04eceaaedc2dfb48290cfc17a38057.png

MedSea#

reg = 'MedSea'
ts_plot(variable, ds, fs, label, reg = reg)
_images/49c7ad78ec2c96cff35ae5c4ffd6ebcc4045fcb3bdb56b973ddf538a2ba296f0.png _images/203470ccb6786510bf490b9efaf0a335ccf35b4cf5b0a170fe53f6226d8149a7.png

BalticSea#

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

HudsonBay#

reg = 'HudsonBay'
ts_plot(variable, ds, fs, label, reg = reg)
_images/e1e1cbd907781271a2909a3cbc387371f085e48f6a7ec85b0f02010afc1f1609.png _images/a0bf0ac727618471211fc6ba720197b0a388de179fedba933d1354083c2795c9.png

Arctic#

reg = 'Arctic'
ts_plot(variable, ds, fs, label, reg = reg)
_images/7635d4064c3f338c468ad5c2c805f02b8b08fbae7a38c6f4a5d38f45af63df9f.png _images/58e09186fbc71647a39e60c1a4db7383b0ddde1e7592c63e1c1ed8a7c2d9ea75.png

PacificOcean#

reg = 'PacificOcean'
ts_plot(variable, ds, fs, label, reg = reg)
_images/ffd04eab4acbb663a2b02fea3ffa5b9ec7b599d3cb12c350038add439fae9f04.png _images/1ba2a90ef6dee3f2cd6e2ab8ddcb660436262adec6845e3f550662799feef3d3.png

AtlanticOcean#

reg = 'AtlanticOcean'
ts_plot(variable, ds, fs, label, reg = reg)
_images/2c864853e28b04f4e8318738d81bb97ae5d5a89f2ebc29ee7db3df453fb155e1.png _images/99d87a2a19186d35512a3a2a5c3b7c76b3b0e24f60324495e891ffc0159bf5cb.png

IndianOcean#

reg = 'IndianOcean'
ts_plot(variable, ds, fs, label, reg = reg)
_images/462b8b4b32b66cdadb979efb8a67b4f82c732868352d77d609d5afbb085d168a.png _images/c658057bccce9f2e72e3510d9504abb919f172e03de705a63290adbfae9ceead.png

SouthernOcean#

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

LabSea#

reg = 'LabSea'
ts_plot(variable, ds, fs, label, reg = reg)
_images/4ddeddf336407bce44a4761d0fb07ccf6925fc9ff2ada268184c60c6d1e886f2.png _images/0dfe85981e4a8121a349d2551594d005a96124b0206f34e87f5d44938717a26c.png

BaffinBay#

reg = 'BaffinBay'
ts_plot(variable, ds, fs, label, reg = reg)
_images/3f7df0c687f49b83d14d260300e5d86e2c041074ebbd1cf4b9c7e4c975ecbd17.png _images/23f9c8bf8465b18e3211031c04522d98f46ed60f87e8c77c0bdedf6a13239d43.png

Maritime#

reg = 'Maritime'
ts_plot(variable, ds, fs, label, reg = reg)
_images/e50dcc25362c10e3ecc5320120c334867005754b61cd2be56ba011c73117b936.png _images/966c7095fd3043e7f7f55276cda64f1184e4c0f12945122088e08d746e09f2dd.png

SouthernOcean60S#

reg = 'SouthernOcean60S'
ts_plot(variable, ds, fs, label, reg = reg)
_images/573a86bb641bcea93617e65fc1bb0aa8aefb0a91aabbbc50983d0908f59c17a6.png _images/694903368807b0d47749de2e74e2798813ab36a6f6293ce4e4ecfb107207c373.png

EGreenlandIceland#

reg = 'EGreenlandIceland'
ts_plot(variable, ds, fs, label, reg = reg)
_images/10eccf7578d990bb1e4813ec2179a883c6790aa8e9f9d1d4ff2103e6ab352121.png _images/00e29deae18d6a10b6e0556578fc197aa8463ece3d468938dd823d1e1a6d8d40.png

GulfOfMexico#

reg = 'GulfOfMexico'
ts_plot(variable, ds, fs, label, reg = reg)
_images/5e26ae6cad07c9a1be3135c7f5b30688f416c986e49c16028c5c347a69d0b46f.png _images/b792cb9e3c96d101870362187f0241d2ab6c3a0dff26a325ad7b12d298995cd6.png