# 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/9d6350906b252306f0150f31dbf344743ba35795bd73f10053cf953171086ed2.png ../_images/4cad46fd891c7a11f8e23cf7169c0679f00f05282ef9ff60b2bca1b057201aaf.png

PersianGulf#

reg = 'PersianGulf'
ts_plot(variable, ds, fs, label, reg = reg)
../_images/b078754ead30503c87689b9039aacab4cafa4e94e31cd4b72f97fd7422676d17.png ../_images/9c20561f671617534288864ab2e3be15954d90017ab311fce9c790785461175e.png

RedSea#

reg = 'RedSea'
ts_plot(variable, ds, fs, label, reg = reg)
../_images/6c466c7e34e2437dd28e7837ff6fa8b662dfb84b53724d74066c2ea37009077b.png ../_images/28b1d6ef5cf4c5e4a5bf53a369a7f135b022f49c8bf2cea490a3985a70ff0fb8.png

BlackSea#

reg = 'BlackSea'
ts_plot(variable, ds, fs, label, reg = reg)
../_images/586d17079e9d810e5e50fe04429e246c3ead40f025872356e557cc3479f5c75e.png ../_images/0f57b314786e89154c0ca41b57582b177bf54bfdf44657cd0d4e917ca45375f3.png

MedSea#

reg = 'MedSea'
ts_plot(variable, ds, fs, label, reg = reg)
../_images/7761a34878df39e832c6683a19c893c71cd7b92386860552b890cd779086827e.png ../_images/ba25c4109681b770e6716647ecb79ad2747e2e2d8823030a9b0ebb42a160a2c7.png

BalticSea#

reg = 'BalticSea'
ts_plot(variable, ds, fs, label, reg = reg)
../_images/11cf8332c78bbe701d617e9550a16d07ba8def8a3cc271abaa4b0b1533ddb405.png ../_images/f4e5224e2f3e8650eb6e1bb1fd03ae089a32874f282c3326700fc53d52f8b5c6.png

HudsonBay#

reg = 'HudsonBay'
ts_plot(variable, ds, fs, label, reg = reg)
../_images/4468bc8fe8bb3b4878244c22766ccff113cfcceab2232f86b8dfb0309f94c049.png ../_images/05b217aa2d13e86228b9f7ea92de3c2b5b27eaf9f24663938cb0e747c0d85914.png

Arctic#

reg = 'Arctic'
ts_plot(variable, ds, fs, label, reg = reg)
../_images/b8b3aa005f7c366576f635344baed1a4f1b90b7a2492aee3bf041c5e8e534096.png ../_images/8182a7947d24f947b2d6beb27e3416b5a580c2c1037a45141840280c84be0da1.png

PacificOcean#

reg = 'PacificOcean'
ts_plot(variable, ds, fs, label, reg = reg)
../_images/41a42cd6bb565a554eb2b504504a225af166a08e2dcbdb7dcd7e3fab100bb527.png ../_images/79d48a0d6cc8620464fc09cc7663cacb783d2b7cda7cc7d098c7a159c3aaebb2.png

AtlanticOcean#

reg = 'AtlanticOcean'
ts_plot(variable, ds, fs, label, reg = reg)
../_images/424906588eae6a7ca3cb55ada8b3c9e7c020bb4ecce745e5fdce60078971f15a.png ../_images/4a0d3e38a831ba7288ec7923571f9ceb5672157ed9ca704db4ebe7cef45cf4a1.png

IndianOcean#

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

SouthernOcean#

reg = 'SouthernOcean'
ts_plot(variable, ds, fs, label, reg = reg)
../_images/4389d383b30309aa9abb16cf0a22062c0eb31e35cd04cd007f9c8b9478f73165.png ../_images/afc0c7aee5a98556211c2b5ab5c8e3f0d45f58b075da83766c26e63aa6d4d103.png

LabSea#

reg = 'LabSea'
ts_plot(variable, ds, fs, label, reg = reg)
../_images/70970d8f25cdbf2e15b5577f6c50bb6b841e1755a099e23654eafe7b77bbef7f.png ../_images/7adfde9e84ee57d1dd2e0571bd89b34e473a45ceddd5ba0087b7716619b3fa20.png

BaffinBay#

reg = 'BaffinBay'
ts_plot(variable, ds, fs, label, reg = reg)
../_images/6200b942cf85a269100fd1d5da0929fdd50efcd83cbece36fc9cf9f58b2fe00d.png ../_images/91f0fa2bd666e5a10b59553b2d89a2abdc3c589461ef4871afc7d7073a383d92.png

Maritime#

reg = 'Maritime'
ts_plot(variable, ds, fs, label, reg = reg)
../_images/cb83696c6722dce800af8bcd2aa285513b8ae7aecfff596a94988c6b73fe0f67.png ../_images/b8ba09c44f23a0db684afa5088dda6dfaf270f4bd246a31384a0591c185893e2.png

SouthernOcean60S#

reg = 'SouthernOcean60S'
ts_plot(variable, ds, fs, label, reg = reg)
../_images/fa3df8e36f3ecff6ab1f3f20756548dcd3b2214c17cedfb98f3bdad2261bbfec.png ../_images/0504cc6007fe7fc320d05d5c50986a729b0bbd965ada1a2cb1e8f9de482be749.png

EGreenlandIceland#

reg = 'EGreenlandIceland'
ts_plot(variable, ds, fs, label, reg = reg)
../_images/7c3cbbe8e621fea6fd3e409796828d226082a642238e24304f5448c9a82c29dd.png ../_images/c51a50c51e70579034b31c6daca261e89b2c6ccf7a27bbbb08816f0aa39b3172.png

GulfOfMexico#

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