opottempmint#

# Parameters
variable = "opottempmint"
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 opottempmint 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/7418a96dbba6ac96871c72a3b26fcbd948e906f11622bd6bb5467a4dc4c2840e.png _images/c96ae5fa6852a54ac13adcdc1626cb623a04d2754795fdb772535cc2ba3b2d95.png

PersianGulf#

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

RedSea#

reg = 'RedSea'
ts_plot(variable, ds, fs, label, reg = reg)
_images/892dbe20ec6c7d37156a576c34564dbb18ec093579b87c9a569af5b45a6c73bc.png _images/3d478694cc41d8f89a13b7ec5805dd96c297b864d0e5fe38b2b4a17ec0cd279f.png

BlackSea#

reg = 'BlackSea'
ts_plot(variable, ds, fs, label, reg = reg)
_images/832d31b7a2ac833347fa5bd642c684090876008ccb7258ddd8a2c1dfb74e30c6.png _images/437b5021da7ca358cfe2e41bcddfe20e77543cdae70c9c3ae48cedba3c712cdc.png

MedSea#

reg = 'MedSea'
ts_plot(variable, ds, fs, label, reg = reg)
_images/e4050410b279f913f8f5debdbeaa1a7561bf02e6613177e46d6590da0c9edc2d.png _images/8156e9810bc6e54f8d919002aefd48322b937172903d5ab947f06b358e22bea6.png

BalticSea#

reg = 'BalticSea'
ts_plot(variable, ds, fs, label, reg = reg)
_images/8a0b01122223dcb5e3578d1c167798a4d7de03c1f5cb5d5b79cd8f27b7f07f13.png _images/abab25e772693bb68c5d7aca415da6880b6132c69415894fc6a71312e46ced80.png

HudsonBay#

reg = 'HudsonBay'
ts_plot(variable, ds, fs, label, reg = reg)
_images/356d80b9b48cd4ff35a3137d8c272fa9964db54897cd2da38cf24391eb650718.png _images/7a31d4ed1be618fd4e42dbcb5e3653b73551d382db243629ca3527a6c9be68f7.png

Arctic#

reg = 'Arctic'
ts_plot(variable, ds, fs, label, reg = reg)
_images/0f4ecc87e732eaddf5fb8ee8a594498bbc2156b87f0e57e513ed28a27e3010d0.png _images/441a9a5f4c9f5590197a9d9f24e121e3043e6510b8f663f218886e3747884e36.png

PacificOcean#

reg = 'PacificOcean'
ts_plot(variable, ds, fs, label, reg = reg)
_images/1c4e80654483e2cae1e91e8761b740a02f5d9af9ee7c22c0dbd6bfdcc2fe8fb3.png _images/5ae127002d6408908d542149396a868274c799591185265772c762ca970bb337.png

AtlanticOcean#

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

IndianOcean#

reg = 'IndianOcean'
ts_plot(variable, ds, fs, label, reg = reg)
_images/1cc8fa5584bd8e6c3aa02b036444cb0e579c7fb8a98f6f6efc6f0b970aba1356.png _images/9035c94b838ba525405c41a7bab00b177403d8c57ed2ef1366acaf4c7fa28266.png

SouthernOcean#

reg = 'SouthernOcean'
ts_plot(variable, ds, fs, label, reg = reg)
_images/317329c772e12ad1eb36733cd9d4cab3cbb9b485eee21ba90e7fc0d13bddc111.png _images/48841a7dbf0689cbdf72235448c65328fb58ce7e11be781db83ae22583d9e132.png

LabSea#

reg = 'LabSea'
ts_plot(variable, ds, fs, label, reg = reg)
_images/04945d8c346c0c60d24b2d20feb37aeb421279d07c16fe653ff8f00db6ec4e9c.png _images/ece30c11d847ca7df247a8eb70a38750b28cf715c03d20916ba5d25cba97e9c5.png

BaffinBay#

reg = 'BaffinBay'
ts_plot(variable, ds, fs, label, reg = reg)
_images/e02c43d648e69757d66d4eac7cd4312d4583c96b3185ddc5523a4f046ee8d129.png _images/465c154e02c6e8e71ca46d019f1fa6539e81cb789903541ed49511083413c294.png

Maritime#

reg = 'Maritime'
ts_plot(variable, ds, fs, label, reg = reg)
_images/9057646d6c4b7cb42944f0cd9e9851e1271b6c1947dd90d51ee2f01f18818938.png _images/b80256011f804a51be30132592aabe84b5b146f0e23c18b36d9c2649698c02c6.png

SouthernOcean60S#

reg = 'SouthernOcean60S'
ts_plot(variable, ds, fs, label, reg = reg)
_images/9d2e95257a6cfbefba0c9f1a08450de8b5aaf71ac89af2b50012b0fcdb9d5f6a.png _images/1e98b05b3bcbe0487061af0c2659a10ffac8421256f987cb604510c3c3e8886c.png

EGreenlandIceland#

reg = 'EGreenlandIceland'
ts_plot(variable, ds, fs, label, reg = reg)
_images/37824f071118f539d2f3433119b7be912acfa03eec0b6d67b09efde53ddac4b6.png _images/e2bf276c27af5211fd47a1af3daddfbc7eddf7b6f64bc9026f8bcf4a9f69b2d1.png

GulfOfMexico#

reg = 'GulfOfMexico'
ts_plot(variable, ds, fs, label, reg = reg)
_images/a3f9d7d1638d7c60e8ead46aaeb1c83faf6aec8ccdcd62712270c67b0043fcc6.png _images/285c2510383daeaa71b02bf53c7fb2d070aed26bfb150698aaf4452a754e0118.png