heat_content_cond#

# Parameters
variable = "heat_content_cond"
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_cond 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/175680c65afd72b6b11d70bd6104defb9ef167c768dd1c1a68231eb620dcdc55.png _images/779ea093aaeb2c785842caddaa84a17b45c0e3a9e6d0f5d5944dcdf4f41691fb.png

PersianGulf#

reg = 'PersianGulf'
ts_plot(variable, ds, fs, label, reg = reg)
_images/dad51b5e718845518f82ffdf9f2f7f94c7a1c70e589475daa216a22356eae9e8.png _images/29ae91ff7ac635a0149e5cc5544778a0e8059cb23db43dd7f443907b3b6a64c5.png

RedSea#

reg = 'RedSea'
ts_plot(variable, ds, fs, label, reg = reg)
_images/86bd01515f81edb29461071f5d54e5c722510db2956a0611dd548aeac99d37ce.png _images/5254c3d33bab27f4503d37f5cd95c1623fd1c9389f286a1ed7224e321d1d462a.png

BlackSea#

reg = 'BlackSea'
ts_plot(variable, ds, fs, label, reg = reg)
_images/1ae1658abe94327d88df40230cf7ffca89cfae37365f28e16864e1dfb66208fa.png _images/7dd6d63a4886e68569cff8c2891591046e580c7a28f25ed79fc42d08f58308d2.png

MedSea#

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

BalticSea#

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

HudsonBay#

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

Arctic#

reg = 'Arctic'
ts_plot(variable, ds, fs, label, reg = reg)
_images/4cfe3fe0fd08dd584ac37190adda0d2644954cb5e1ff930c043436b774bdc903.png _images/3072f75f7c8ee3591569221d240f8155e49b0db596fe5c2b409cbda87497a725.png

PacificOcean#

reg = 'PacificOcean'
ts_plot(variable, ds, fs, label, reg = reg)
_images/52f73b81f83447b4f9ed8dca4219f0f039eb9cf44c064970447d843e19def7c8.png _images/4426fbcb071c5bc47582703eaa66d2c233609dbaea738b2921e4d8a284d9e381.png

AtlanticOcean#

reg = 'AtlanticOcean'
ts_plot(variable, ds, fs, label, reg = reg)
_images/c6903098a9aa199c7ac8a9c77674f25716cd4c8051e923884d52083a8ac61c8b.png _images/46f938d39c581448f5f8027aa9c62b8ec2c93ff5ad4aa9b8fe2215809b500c36.png

IndianOcean#

reg = 'IndianOcean'
ts_plot(variable, ds, fs, label, reg = reg)
_images/752ef63eeaba01b276a37cef676ed820e2f7aeff8995a41030fb210cf744af6c.png _images/c56e25223f5f561854c9b200e29ee567703cb6a395a1f74f1ce69cd3f1b6b1e7.png

SouthernOcean#

reg = 'SouthernOcean'
ts_plot(variable, ds, fs, label, reg = reg)
_images/475f7ce153e657481a2ab331b401673684cb02ffa7143f89e7733a9fd648bb87.png _images/5fa95da8e991e7306296684078a769d297e15f63ef6e00ce49a3a1c03d0fef7c.png

LabSea#

reg = 'LabSea'
ts_plot(variable, ds, fs, label, reg = reg)
_images/687df7756d3b1afb8ef47f1a801f1d095b45fe879d4407fb1f5db8084b33e359.png _images/48f6f2eb02beaeb017e4f40c107e3f3cf9a4ab6d10245a53e40c8577ee4b755f.png

BaffinBay#

reg = 'BaffinBay'
ts_plot(variable, ds, fs, label, reg = reg)
_images/3004c0a2f7d930c8dedde4d337c3cb0ba6ef730f27ceb268b8eed517bce8dfa4.png _images/ad87e834ad9ad35dfa39b412187921a7998cccb9b676f42f39ed13401c4b363b.png

Maritime#

reg = 'Maritime'
ts_plot(variable, ds, fs, label, reg = reg)
_images/c4e227b324274cfe7ccc959979422d40fbc503a088d86b9222e7f866207557f8.png _images/e5cb3c882e51662cf48056db70bafea8b57f3df5f04498d844337de372dd71f0.png

SouthernOcean60S#

reg = 'SouthernOcean60S'
ts_plot(variable, ds, fs, label, reg = reg)
_images/54bfe2f1798939b70431bcba3b3e6fde1340332cbb93746440d1528e45c3239a.png _images/3d982da31c2993d2f5d547411eb40d42904f0ccac4a78bbd8f5f066640c821cc.png

EGreenlandIceland#

reg = 'EGreenlandIceland'
ts_plot(variable, ds, fs, label, reg = reg)
_images/ff2c61816873c7da30624911f9ec23b074512a2c0b475c6bf39262b00af96d99.png _images/c97efba0fb3595c6d877bc41fac1d351d73f49b17a2c4316f5b3aa4a95bbc758.png

GulfOfMexico#

reg = 'GulfOfMexico'
ts_plot(variable, ds, fs, label, reg = reg)
The history saving thread hit an unexpected error (OperationalError('database is locked')).History will not be written to the database.
_images/d6f7bc1bcfb2b75dff13f3f1268f6fd90fcd3d73cd9fcd61bee05f08ba10036b.png _images/863d49a9aeec227313dd086f895d74812fcbe8bf28a80c87d3b602372c84660d.png