# Parameters
variable = "ficeberg"
long_name = "Water Flux into Seawater from Icebergs"

ficeberg#

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 ficeberg in different basins.

%load_ext autoreload
%autoreload 2
%%capture 
# comment above line to see details about the run(s) displayed
import sys, os
sys.path.append(os.path.abspath(".."))
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, linestyle=linestyle[i], color=color[i])
    
    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, linestyle=linestyle[i], color=color[i])

        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/2aa99e70c81e0d92764857e49fb39e13ad5ec329e34c476485cfb05a36d83d24.png ../_images/4a24c52ff119338e1774eb13d84b3b2daf57a3009180513170b1876b3f7cf92f.png

PersianGulf#

reg = 'PersianGulf'
ts_plot(variable, ds, fs, label, reg = reg)
../_images/b7ec6c158a0d6ef3731b83c63be4ffb7364ce45d12039d100c03836fde76e340.png ../_images/f5ff4855095a1d44355d2bd46bad9f04f13e14d937b53f947f972b26906402a1.png

RedSea#

reg = 'RedSea'
ts_plot(variable, ds, fs, label, reg = reg)
../_images/f7fda3076517620438ac473d0217314e21896fe051bfab55b318d7a205184d27.png ../_images/f8e8c538391f5037ff0663b23959f4e5d44277afe1f6cbdaba896b4bb83b14db.png

BlackSea#

reg = 'BlackSea'
ts_plot(variable, ds, fs, label, reg = reg)
../_images/959573f14d29f3dcc8ddf5452b3548625ed192471f413f61b6c6e25a9b4d9edb.png ../_images/0d876325f22f8e58e6a486db2acb023e06d0ed00bf482505b2cb1153c1ba9e29.png

MedSea#

reg = 'MedSea'
ts_plot(variable, ds, fs, label, reg = reg)
../_images/06284c63313518565dc9f75edc749f0ac33d9fcde15905bc35d69e37752f152c.png ../_images/68bdcf038cf183eef862510ef3fe7ddcd81ff8706f5691142dfcac2623f1d893.png

BalticSea#

reg = 'BalticSea'
ts_plot(variable, ds, fs, label, reg = reg)
../_images/e2407fd277ca43181669938ca75d314b524efb4f3a635174d0ebd0855baa1363.png ../_images/115b2bc7f13eef8c1595a729365c5b76d36f42bc9317da231be14cbf4fa3182a.png

HudsonBay#

reg = 'HudsonBay'
ts_plot(variable, ds, fs, label, reg = reg)
../_images/369ef22920ae4a392dc0cabfdd880d4602fb86f54ece5ee924458b4d8e6258f2.png ../_images/b6391ec4bcc6f2f8e8e518e394ee18094ae5337fc81249419b2c75fd7cb6619a.png

Arctic#

reg = 'Arctic'
ts_plot(variable, ds, fs, label, reg = reg)
../_images/65ed12842e2918104b4571e5f1d32a3a2d810efb7bcb91eb666a0d3189fe803f.png ../_images/c0c541a202a5390ba12e59e004baa1bd1716450da663d102c92e045e5605c10e.png

PacificOcean#

reg = 'PacificOcean'
ts_plot(variable, ds, fs, label, reg = reg)
../_images/ac86206b4b2aa90664cfcf3a7baac64969dd2e3994364b3a63bc28e198b86693.png ../_images/a822a7542870801b08d10f07b67cd8ad4dec19a703b36ac292cef0790fed77ff.png

AtlanticOcean#

reg = 'AtlanticOcean'
ts_plot(variable, ds, fs, label, reg = reg)
../_images/4519eb8a71bc13f992e3e98958815ebbc8fb0d4e5a90d3e5cce61e0e1346f6f8.png ../_images/24ce34d77305a511114e3ac67ee0763382093cc1583fbadf1b755193d6b707f8.png

IndianOcean#

reg = 'IndianOcean'
ts_plot(variable, ds, fs, label, reg = reg)
../_images/87e8d17fdbf293bec1e7a5b5ed0cca3b1054816ea53f361475168786646db34e.png ../_images/3bed5adb888b5c5ad34205172447eeea4ad3fc6766a42edc4ac800933c0ee65e.png

SouthernOcean#

reg = 'SouthernOcean'
ts_plot(variable, ds, fs, label, reg = reg)
../_images/d4e872263a367c86faaeb9ea80664966c2f09563bcd65c0b9837edd377b4135f.png ../_images/da81988e227967cac0fe9e2870725e2a77091f88b042abff6683df747fa0c746.png

LabSea#

reg = 'LabSea'
ts_plot(variable, ds, fs, label, reg = reg)
../_images/997155c7c8451504e58828792f1849bfd369c0d53a1fb339660a7a15016ec6cd.png ../_images/c8916a1c75f427f57a90eab1f0f875c230133e5780283a4dc41865fd63c6073c.png

BaffinBay#

reg = 'BaffinBay'
ts_plot(variable, ds, fs, label, reg = reg)
../_images/c2d62b254a4ed9b3464a537a1c85b296ae392d66b536732efdc1391ee89c4544.png ../_images/cc2bb6de9865e890057a664dbf44af8bd0fa621d83b2e230dfb7cf7e175e638d.png

Maritime#

reg = 'Maritime'
ts_plot(variable, ds, fs, label, reg = reg)
../_images/5615c002029eb4babee4170b9e31128e70209a722233814edc7d1c2ef06e9b64.png ../_images/ab05a4503c4e691268c65bac8a17b154d49da7f9e5d749ed2fb63847416220ea.png

SouthernOcean60S#

reg = 'SouthernOcean60S'
ts_plot(variable, ds, fs, label, reg = reg)
../_images/d2ee575b11d241c216d6f94d90fc2607bfd08574e0fe8562bfaa9af7f21dd7b9.png ../_images/5c21ab5ae6ba59a987e397232c8da76a997428f1b20cbdb6e1ee5830957aaba4.png

EGreenlandIceland#

reg = 'EGreenlandIceland'
ts_plot(variable, ds, fs, label, reg = reg)
../_images/339c11a8ba706200674c5b3a10c3998ff127c38bdc5013f00914b3f48a5964b5.png ../_images/75f434f7162caf25d17f8e85fdd6e87e9bba1ecd5f2ed752301f00929beb5c8b.png

GulfOfMexico#

reg = 'GulfOfMexico'
ts_plot(variable, ds, fs, label, reg = reg)
../_images/fc70d7999bf3abf699a260ac703e7c74533fa591ced2aa07ca6f16f54f708cf6.png ../_images/1cc02baacc83825ade96b47d673ae7f326248916fbd33242f5f0d499297db85d.png