heat_content_frunoff#

# Parameters
variable = "heat_content_frunoff"
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_frunoff 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/0b66546fe7d2cfb42be0a5a62c9dd7f63c4057dc6b02045e1c9b9aef9450c43d.png _images/f8e9a8034f45fe6f5d5086e724e3f5b7424f99a186f37af3cede9ae1f03da176.png

PersianGulf#

reg = 'PersianGulf'
ts_plot(variable, ds, fs, label, reg = reg)
_images/3c45031008df8f3cf778a3615ca42532475869b8b46006e691e1dc40e9abc4a0.png _images/d3ae874b7ce1fb6c243503ce9495cc2016d878d0d36c37aff23b25810f7d68e1.png

RedSea#

reg = 'RedSea'
ts_plot(variable, ds, fs, label, reg = reg)
_images/fdbc62ecef2975218b29c7d7d2b005042df1176f0a7e92e6b13fcc6e0e5ab815.png _images/55d9a5649ee281408c5746ec9101fff1790102de78447098308492069b5d4ea3.png

BlackSea#

reg = 'BlackSea'
ts_plot(variable, ds, fs, label, reg = reg)
_images/dd2166a929e146713ad45baa426c9b93d9708749942a68abb82d0125bfcd5c2b.png _images/ce59fbf5cdd0f9fa145522e21e294c22b45d554b2d1563f9cad7f35abae07b92.png

MedSea#

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

BalticSea#

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

HudsonBay#

reg = 'HudsonBay'
ts_plot(variable, ds, fs, label, reg = reg)
_images/dae5829a9e4ec60e4aa56bab682bbe5cc7cbfc3b6531f14b1ddb9f7bda9fe063.png _images/7ed6e5438c8ccb0802e94f0af73fb5368af6e7fc0ad7b9e41a7c0435db369b32.png

Arctic#

reg = 'Arctic'
ts_plot(variable, ds, fs, label, reg = reg)
_images/c271d0e3c6b23880f870d318ca4663aa3dde25a3f38d1c8377ddaeeb2aa7b74d.png _images/ebb96e5ffc80c66338bafd8edb6151e5a3853a238e38f52a46474414d00f87aa.png

PacificOcean#

reg = 'PacificOcean'
ts_plot(variable, ds, fs, label, reg = reg)
_images/65d81893dcd5b11991a91d08e2224dce0eb27ce7ed763876727f138b3bd9be20.png _images/33d2baecb8439c9bba0545ebd7ce4b3cf82898aa99a874cbb149f68de2bbfb15.png

AtlanticOcean#

reg = 'AtlanticOcean'
ts_plot(variable, ds, fs, label, reg = reg)
_images/0fafe6db558ed87a3665ec7fd856a8d987b596eb92a33bbe03a92d01e1099c7d.png _images/e6f2c3b3bc7ea7b8ad52b32f19ffa60cb3c5d98bbb345161fcd05bd054508b17.png

IndianOcean#

reg = 'IndianOcean'
ts_plot(variable, ds, fs, label, reg = reg)
_images/eb80c7629b88bdde558fcf4a797ae5b144d9e1ebcbe496c6ff4940c7c23c1070.png _images/84448b8b2399b383df2dbe53a47b710d9876f076928f6fa290bfe6b36ec52872.png

SouthernOcean#

reg = 'SouthernOcean'
ts_plot(variable, ds, fs, label, reg = reg)
_images/8aec7db88b5455a880e3a5726e822abdb9fa1acabf4796143f5d2d7aea1cfc2e.png _images/e48cb8cf8a44ef704726ace41111497868a718b010c05cc0ac43a2e8d470488b.png

LabSea#

reg = 'LabSea'
ts_plot(variable, ds, fs, label, reg = reg)
_images/c09cebd32cabd1c093c209ec1ad19c234ab4761aca6e14cb85e31acd24a6719a.png _images/7ad1ba5dd02321a6885ede8550b03df7fa027580dce7cfb2a25d3282e22878db.png

BaffinBay#

reg = 'BaffinBay'
ts_plot(variable, ds, fs, label, reg = reg)
_images/8c3a2bfa3c3b3525311fb37021f09cc3cc6b23a33f8f68bb0f7a251cb198a0a0.png _images/72542925e60aa2397b0c5a2d1bb676fdbb5e0c0387f724d81862440dc0323e77.png

Maritime#

reg = 'Maritime'
ts_plot(variable, ds, fs, label, reg = reg)
_images/151d8c077803409dc08792d8f81d5296e9afee1fa2e06f897d65a1d33989f7ec.png _images/dc29024a5720d126fe07edf0516d8df57f5a0adf0f3ceeb8ff86012b9bc200d9.png

SouthernOcean60S#

reg = 'SouthernOcean60S'
ts_plot(variable, ds, fs, label, reg = reg)
_images/a3404ede12566af8a268f2f32eb018dc95ce8bcaf252adce3cf2e614af7607d2.png _images/56a1f3bea7fcfa54b7f1797b458c44fd3b3a394fe7830b27939f9fc6ba83f8d3.png

EGreenlandIceland#

reg = 'EGreenlandIceland'
ts_plot(variable, ds, fs, label, reg = reg)
_images/69392e1332a8c1be59e305244fec3b1721e8d8b60859d84e0349c542d12ad2a1.png _images/b81481ae07f12af1370674ba08d6cc9e1376ff8e6c6b2455167617261a8ff0ab.png

GulfOfMexico#

reg = 'GulfOfMexico'
ts_plot(variable, ds, fs, label, reg = reg)
_images/3b662d09bdb3bec634fd96f2ffac18d1f5c22db1bd60d63c06b6456cfd838051.png _images/41d4b9c0b0e97d4bc3406ff5618c13d676c00b3134c90f69dcd7091bc2c2c48f.png