ficeberg#

# Parameters
variable = "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
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/d6ca03f55edfbdd199149e3d04294b12361a8db3dc3a830496f0ce064334a308.png _images/99c6af79d3770869dd994cf865852eb7e7554dd20a6087e9a43d1bbb6fcc78f6.png

PersianGulf#

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

RedSea#

reg = 'RedSea'
ts_plot(variable, ds, fs, label, reg = reg)
_images/2edac7b1d0acb73df00b6e3504867d8bf06f559459050296f46754f312e94a8d.png _images/b05816d3b1bb7b768ea3bf8e804034b7ae936c9e62178586ebfacb6b08b09b96.png

BlackSea#

reg = 'BlackSea'
ts_plot(variable, ds, fs, label, reg = reg)
_images/f79c79feb953f622779ce5cbd646750e9c1d42adabf75caef93ac34263249f95.png _images/898d54b6ffbfb2ee27574d691e08e7a996a1e96a68a496b425577f7e1ab216ff.png

MedSea#

reg = 'MedSea'
ts_plot(variable, ds, fs, label, reg = reg)
_images/62dc62067320e08851d09126ef27d015440d3e28d369c00c3b8e459ae8c8968a.png _images/47be179b2b0509f7d44dc0a6c04dc4fb08c63e06eaea1fcb2692529e03389df4.png

BalticSea#

reg = 'BalticSea'
ts_plot(variable, ds, fs, label, reg = reg)
_images/f628b95ef450ca2e0ff5a12fb0b084298d87e2483f05afdcc421716d11ea9128.png _images/93d47a2da1b789a06d99ed5a582b056f02d78cafce7eb1e0a109bd5187159fb4.png

HudsonBay#

reg = 'HudsonBay'
ts_plot(variable, ds, fs, label, reg = reg)
_images/57332e9ebd8726d038c1a08fcdc1ee1b90d00246cf335d39e73826dc901506d4.png _images/9e8b8fe10bbe9f1524331eaf9acc1768a7add80564693fdfa4db1d7e353a8321.png

Arctic#

reg = 'Arctic'
ts_plot(variable, ds, fs, label, reg = reg)
_images/2a9839c31a3a0432b255daf735302a7a98624bb71afdcc4843a91c7a80992e26.png _images/c78f1cd2cb9bc8e9b93fffc0c9bc7cc238aca3f9eebd0858f4039d332feeff50.png

PacificOcean#

reg = 'PacificOcean'
ts_plot(variable, ds, fs, label, reg = reg)
_images/95a655be388887b572351db7d4a094cc1946b8122e37d17d6bf1d906b6405ace.png _images/b602bf75f66b6c28d0fe2b268a64babb8cc26f92edeced34aa6f4b2525b255b9.png

AtlanticOcean#

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

IndianOcean#

reg = 'IndianOcean'
ts_plot(variable, ds, fs, label, reg = reg)
_images/2ed802e2f0f509ec828e57902beed0463c482787d048660afe807fa7b74e6b3b.png _images/d17037be6f18bd86dd0ea5a0048a752fa12b3b23313e7edc8ffa70e1299995a5.png

SouthernOcean#

reg = 'SouthernOcean'
ts_plot(variable, ds, fs, label, reg = reg)
_images/abd31752db7c79f8c2b4bf878d52be191bd3d67bc82e90d560120d8eac37c258.png _images/326ff1ebdd7360e6c0e03f577aa363d916933bf295fe9fa3db7c852eaa4719e8.png

LabSea#

reg = 'LabSea'
ts_plot(variable, ds, fs, label, reg = reg)
_images/49bc2a6f6b3b4362ae45736f20578d13c5d7a24dcc4c29bcb1957238412ff553.png _images/5e5bed82a8c10308c38834fc2d354f3006982465325699d70a7b6a063e2f2322.png

BaffinBay#

reg = 'BaffinBay'
ts_plot(variable, ds, fs, label, reg = reg)
_images/51a1f579ef2598b22cd981dd7867e2ac5a1804faa94cb365a487bd5289569fb2.png _images/ed39ecba890d4b70930420d1ccc55cac936121878f578f5c2951cb6bc75b9b92.png

Maritime#

reg = 'Maritime'
ts_plot(variable, ds, fs, label, reg = reg)
_images/300181d1cdb66120e83892fdee46133e410e51c0fba122787b301964b8fc37c6.png _images/f29d085b73f2a543d534ed0a5ca55847d760dbbb9b5d06e63f0f89024d9f718f.png

SouthernOcean60S#

reg = 'SouthernOcean60S'
ts_plot(variable, ds, fs, label, reg = reg)
_images/73ed0a293103c9132e4366e4e19503547107e4a7379cd69a38004b2e2bdde168.png _images/1838db7576e11d078bcee2138eb7abfcb1dddd67a327e923f56e75ea74eb31c7.png

EGreenlandIceland#

reg = 'EGreenlandIceland'
ts_plot(variable, ds, fs, label, reg = reg)
_images/8ecf140374ac56b0a5838f121747dabe7b5e3eca919db2f7858912dffbe09336.png _images/f404706b7dcb74519c1d931c2ff923b4def6cb4a5df8d6d19d94685526a1d1cc.png

GulfOfMexico#

reg = 'GulfOfMexico'
ts_plot(variable, ds, fs, label, reg = reg)
_images/d644dde5406ad62ca5ae9b3a9f968c32811720ee0d34a76477ccdcc27bcd1d95.png _images/cbb6efeb76f374e2ddd30c940317acc0166c3e5113f2c207f7aec9651a3dc39c.png