wfo#

# Parameters
variable = "wfo"
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 wfo 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/7572d2d195dbe12cb98ad6d10320a04b33a56be78a1032e50095b76d18de26a7.png _images/99ec51c06d1c8ec61023d37e07783a83dc80eceb5d2211f654b1c7c30edc02e8.png

PersianGulf#

reg = 'PersianGulf'
ts_plot(variable, ds, fs, label, reg = reg)
_images/176c9d90d35aac4a635042132ea4125a318cc72c3f36d983c0279ce39d0be9f5.png _images/b1355278fd5d0b6359aeb734ad6b4d082e244fb741c11a76fb1d4c653e95ecb7.png

RedSea#

reg = 'RedSea'
ts_plot(variable, ds, fs, label, reg = reg)
_images/6733bf0e99fadb96a12921da440f58ec548eb7c531d3738501d9056e708f7e1a.png _images/9d50498a77423ccc1304c1f2bd20cf28824bb8d3aed8de0ba51e310cf5e327ad.png

BlackSea#

reg = 'BlackSea'
ts_plot(variable, ds, fs, label, reg = reg)
_images/8402d05cd187d99aa33fc985a3faadc7b360e4db965e3801615b8eaf50939b91.png _images/1675cdf891d5ccd18319eed33707a072a9f62f3da40d29b7688d80855da5268a.png

MedSea#

reg = 'MedSea'
ts_plot(variable, ds, fs, label, reg = reg)
_images/df5c6c32b0ef17a0240bc4ca61ae66609caa1d2fb837099173e52b87d994e814.png _images/3d3d58a617d321914813e861bed83944c5d34359f69bbdb995e97566c3da5588.png

BalticSea#

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

HudsonBay#

reg = 'HudsonBay'
ts_plot(variable, ds, fs, label, reg = reg)
_images/2be351a22bba7e7c3dd029c0a9ac560f2c23bc6550edb98e74c79f3e252d6094.png _images/4c823065bb064de24e713d25c1b52ef1f265d59bc585abb2bf046c5c0bbfaf4c.png

Arctic#

reg = 'Arctic'
ts_plot(variable, ds, fs, label, reg = reg)
_images/1fc7ede2aaf9c008a557eb551cde0c49070dcd70cbbacd2adf1aefa0039783b6.png _images/f81cd2fb1da0ed7e8f7d593fd2384330368806dca32237154a48fb4ffed0b50e.png

PacificOcean#

reg = 'PacificOcean'
ts_plot(variable, ds, fs, label, reg = reg)
_images/9de8d16f85d257639900e6959fe690d0c407b5c253a8cf40150f948aead60b0c.png _images/7fe4d9c823cee8e1515e4fab8b73c014d23cb887fff6112ca1aa3b0f4cb314b2.png

AtlanticOcean#

reg = 'AtlanticOcean'
ts_plot(variable, ds, fs, label, reg = reg)
_images/b142ba2fe0f8dbdcfa39c7c3505748fef2f107bcb13ca096926cd175f196ec57.png _images/d8710ca97670e092761275f68ec39828f1d63d913d121fea738d6c33e421dc0c.png

IndianOcean#

reg = 'IndianOcean'
ts_plot(variable, ds, fs, label, reg = reg)
_images/b06b3b1cb36fff0e241ce456410e604015bc48cd8b92ba681ec92a46a3a9a700.png _images/da4f3542ae7d3914a95d7eb8659904d85196dcb3847fe66a01b66bb1463dfbd9.png

SouthernOcean#

reg = 'SouthernOcean'
ts_plot(variable, ds, fs, label, reg = reg)
_images/4115f99bd8d2cb019512c5c69e716e3e81ae7f9e669c5c5484a951a6b54b8313.png _images/0fa67cc273375ceb158e1a4a54a8e5fe2152bd0748ce4a2615665a0f6d3c8ff2.png

LabSea#

reg = 'LabSea'
ts_plot(variable, ds, fs, label, reg = reg)
_images/49a61d37f1ff23cc547dca321e25d6a8e987f910e3d58df2bfe708d52246b12a.png _images/b04ee76c97f5e2eaf47e3745e0e0ba0370151643e7da51c1d843159056b75cab.png

BaffinBay#

reg = 'BaffinBay'
ts_plot(variable, ds, fs, label, reg = reg)
_images/7a88f56344419ed16b73bcaf3acaedacb72c0773ae6493dcc0c80ed770afd22b.png _images/dc89707e390b1d5739db05b9d2df183850b113f2176fd553108cebf10cc621ed.png

Maritime#

reg = 'Maritime'
ts_plot(variable, ds, fs, label, reg = reg)
_images/fdcb2352cd4a95e31b5f230e0894f427a30e872f4d8fe3a5b111435cf2044138.png _images/0718f8cd6d771cd06490e5c8cceb7fdb4cd35576616aac14bdc0dd48fdf2ee37.png

SouthernOcean60S#

reg = 'SouthernOcean60S'
ts_plot(variable, ds, fs, label, reg = reg)
_images/c1cb439132a655fdb1ab904eac4dd89f185718bdf29452a6a506997729b27e8f.png _images/9e193c9b4da9de3db516af75707422a6f2707f0f331c70d17423db8e834be664.png

EGreenlandIceland#

reg = 'EGreenlandIceland'
ts_plot(variable, ds, fs, label, reg = reg)
_images/ef92c04b98981650171514c27d6df6ac043f5e585558b801ed9a3c5c2f42e183.png _images/2ab73b4aaa33cf4361f0c586c6eb62e534c07269ba1c63dc7e3c50d6fb9b8045.png

GulfOfMexico#

reg = 'GulfOfMexico'
ts_plot(variable, ds, fs, label, reg = reg)
_images/7d9cfe3b0a0003bbf7ec88e3aa56b531951dadb1d0ae42e90db078defcf1ff24.png _images/d146f222d78cbcca7b099e92b7ff55328a997b4e6c832b8f660955037da6608b.png