hfsifrazil#

# Parameters
variable = "hfsifrazil"
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 hfsifrazil 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/bdd483bac3bebc8b6b39dcb3307ce2d01f28aa690cca3d85aa2a8c60c84f7df1.png _images/6b925138c6934118a10262d960fcde601c044264a63f1b84fa795e5309f0442a.png

PersianGulf#

reg = 'PersianGulf'
ts_plot(variable, ds, fs, label, reg = reg)
_images/5e648d32293b3657e2c8b4df9eab1c075492ec7832b3bcc3497f0767c2f0217a.png _images/b2bd7b76641bf53692b05f390f21d90040b2c7b2d5c1d9bef98a76ff3c7ea5e4.png

RedSea#

reg = 'RedSea'
ts_plot(variable, ds, fs, label, reg = reg)
_images/2d37952c1e004e0de86f576066212c97a051509bfe6f9030c3a1681295eb174f.png _images/76815ce9719fb33d909fefa6262afa535182cbd73bc27933d41b76ebbc201adf.png

BlackSea#

reg = 'BlackSea'
ts_plot(variable, ds, fs, label, reg = reg)
_images/f4d5494bba02a276099e75eeef7362a4ab1ae461329e62326d67a6f11cd2de14.png _images/99e3ec8958ce1816d84ea6f794404b90096a273fe8932228a917f7ab7e0ba1bd.png

MedSea#

reg = 'MedSea'
ts_plot(variable, ds, fs, label, reg = reg)
_images/137ac91e53f427a40d549c9d0d5b8a51ded4d1f778989ce6d82de53088293a0d.png _images/de1364b9f266b702415b6cbce9463a7f28453c0aebee271f972ae6a694b6c410.png

BalticSea#

reg = 'BalticSea'
ts_plot(variable, ds, fs, label, reg = reg)
_images/92412c13d4ad1dd12f0071bfcf057de2a6cf3c6e40fb6f7bda78e7818f4b71a0.png _images/b0edebd69d37538b505c5a9897c6de235fb8309c6315958888172b7e3fee4515.png

HudsonBay#

reg = 'HudsonBay'
ts_plot(variable, ds, fs, label, reg = reg)
_images/4767477d671183a212b9a5dc5174939830a81f5a445e7c992c0776522e555db9.png _images/34567542ab8d0d5757dd963130ab1d499d4463e49f7fae85dd0126894983c027.png

Arctic#

reg = 'Arctic'
ts_plot(variable, ds, fs, label, reg = reg)
_images/1a3ef66f44c1db58a2f7eb9aaa4b8dface725dd24a8b733ca03021ccbad0ab71.png _images/115edbf8960fc80b206360f35077f060397cae2730b5c318a6e89f8c44c35253.png

PacificOcean#

reg = 'PacificOcean'
ts_plot(variable, ds, fs, label, reg = reg)
_images/96004778f1fdae9044787815caf0890edbfa14dd26830067f05737a532ebd987.png _images/51ce6d75b0d132fa348ca307057a66a525280d91a74a67db163f20325313e763.png

AtlanticOcean#

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

IndianOcean#

reg = 'IndianOcean'
ts_plot(variable, ds, fs, label, reg = reg)
_images/9be5989cb3c43483c8efd9e5d3808aade7a0868debc615e07d227ae2d0933b67.png _images/749a4245efc5164d024f13b6434055c0b2caee69d2b93a48402a8ba0007bd4b9.png

SouthernOcean#

reg = 'SouthernOcean'
ts_plot(variable, ds, fs, label, reg = reg)
_images/34129bb8cbd9b598229f3c85f2ebc9be380926a7a83b394fbf9480d7d3171985.png _images/17c789131012e14d58c0e78d87f510655e9d0972e506a58b3276dbe7994d8c01.png

LabSea#

reg = 'LabSea'
ts_plot(variable, ds, fs, label, reg = reg)
_images/17f4360f11a330108b481200bbf52d82b99e733f82cca177014730df9c6efa66.png _images/d0de7e4cc2a1a9ea8f75dd34b7c3f9e77a9f2ccc38b8385b1dd11f0f4d97aa5e.png

BaffinBay#

reg = 'BaffinBay'
ts_plot(variable, ds, fs, label, reg = reg)
_images/5568ce62a778bbfe7e677b06b346e1c41661e080088e90183ab85c4cd7605cb1.png _images/f27732545165e2793bf5b366daa1f451f660282aad56023ba77e6972acba2b5d.png

Maritime#

reg = 'Maritime'
ts_plot(variable, ds, fs, label, reg = reg)
_images/840fc3d2af842acd2b67869ea6baee242ecb39b74503170b5b2bbcba46613155.png _images/29df6e40939ab74b6afe0234b942146a77c034d41ac54033fd87f714231f68bd.png

SouthernOcean60S#

reg = 'SouthernOcean60S'
ts_plot(variable, ds, fs, label, reg = reg)
_images/e5ee0a6fb0c7db061a531a74051a7bdcc9332203bde8b399e151d3aa9cb11903.png _images/7570c18e1faab1bc663bdeeb22a46e10c3ffed42a0e52e290c8e40d1dcf5e282.png

EGreenlandIceland#

reg = 'EGreenlandIceland'
ts_plot(variable, ds, fs, label, reg = reg)
_images/64e71ce12f029af62aaffb257037bbced720e466a6b955f459f9e6614d28bb23.png _images/1d9f3ca9d0f4c90182ff806f7a93a90f3485e06fc3c9bc209e69d3787f95e0f6.png

GulfOfMexico#

reg = 'GulfOfMexico'
ts_plot(variable, ds, fs, label, reg = reg)
_images/72f1f60f51121eac3b67dd031c72fce481f0637b082495280e28893cd2895a59.png _images/635161cac7b10d8cfc6a708ecc59c38e4cd5ff04fcb6d28611e408917d173f25.png