fsitherm#

# Parameters
variable = "fsitherm"
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 fsitherm 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/68023cd744717a540a1a4938393c10d0ac49a1dc4b327370dfa199e03c73548d.png _images/19366848a5690e820fa83733732ffc52c165b6e3a7ccf0f96e0a4c42ac956531.png

PersianGulf#

reg = 'PersianGulf'
ts_plot(variable, ds, fs, label, reg = reg)
_images/645e1c5dd65816035e79feea54286686940c338c2b584401453db1366032a094.png _images/2ddf5829da161d0d455b3ef99174e1c343cbf3aea6449a5043f25b43346b6742.png

RedSea#

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

BlackSea#

reg = 'BlackSea'
ts_plot(variable, ds, fs, label, reg = reg)
_images/c9bcc336360f3031fe6d0d8aab146819313cc13a6060202adc68defab183aaf5.png _images/495d947a8ed9c8750b303ecad97ed59a97f93e0b6a1130f58de9228237a2383c.png

MedSea#

reg = 'MedSea'
ts_plot(variable, ds, fs, label, reg = reg)
_images/48b48f87aaa207bf42e017a756bdabbb20a5fff43e7394e8b42e7d7d4ddc4fbe.png _images/952641f351482805237c265657198d01f699d745f1476c5fefe9cc8416f128ab.png

BalticSea#

reg = 'BalticSea'
ts_plot(variable, ds, fs, label, reg = reg)
_images/de9b30b1e402682b2fa1c4c9fb3a4384a1660513b3f747e283105eddb0c6ad1b.png _images/62b1c751a5f1f3e68682f66270f7afdcd9705f69f3ac0ef065fbbf5b0bbdcb7f.png

HudsonBay#

reg = 'HudsonBay'
ts_plot(variable, ds, fs, label, reg = reg)
_images/f7de7f4b112c953f1a66725987cdb0e0d243a0ac905713a4fef9d2f635018119.png _images/6baa4b649e883db40e191682b2f028dd0e3449be3a58a5f0c37a559da12204a6.png

Arctic#

reg = 'Arctic'
ts_plot(variable, ds, fs, label, reg = reg)
_images/1e7bca5707e31614c5b1c89ac5db19dcaf597166016939eb22d9a558877052c7.png _images/9ae90647bc1927c38070e84e550119908639451890d83cdb98018856a6b3d129.png

PacificOcean#

reg = 'PacificOcean'
ts_plot(variable, ds, fs, label, reg = reg)
_images/0e5d6f6c0e0cca24cbfbf99b20ae9f27029eb1294acaabe9d7e7f113938aeb99.png _images/c80b6d324318c266a050fbd74ef380c64541abf3e44de0b6d34e0859d1ac80e1.png

AtlanticOcean#

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

IndianOcean#

reg = 'IndianOcean'
ts_plot(variable, ds, fs, label, reg = reg)
_images/64c608f38a208db44bdb7d29c64af29c5fafdffb90eb4913cae2f99d65ba7b3d.png _images/cf3132c2d461f2bb99fe1e5e70c87c71ff98601672dffa2b4aea7c3b3d4ddf31.png

SouthernOcean#

reg = 'SouthernOcean'
ts_plot(variable, ds, fs, label, reg = reg)
_images/606f7927b8d28d46daf860f22758b81329fe26debfde0bd4779481cbba20ad42.png _images/286a8e76c517a36a492c7ed63a0b3684261a2d708451cf57e95fb48d03381dd3.png

LabSea#

reg = 'LabSea'
ts_plot(variable, ds, fs, label, reg = reg)
_images/671293977ad39c7760e6af509747a73302b4bfe7f8a47cb7fc1718a38114f925.png _images/8784700a249cee4027ebd2b83a57d7ac7d6e3238ba05da4255e42141fdb6aa4f.png

BaffinBay#

reg = 'BaffinBay'
ts_plot(variable, ds, fs, label, reg = reg)
_images/28c4eea78cb9584101e2e786f2157c011e5695a489f3bc88fdbfe9459a47524f.png _images/073b0d6ee9d82a800a42f423c34b5247f9b8ae88e024c9de258dda1ddc3c194d.png

Maritime#

reg = 'Maritime'
ts_plot(variable, ds, fs, label, reg = reg)
_images/a78ccc8762849be92edbd957033e60af26e915c1a493ffe2caf0d746e502e8f5.png _images/12a12c1237916a6bda19f2f115ac5bab42ceb056aa798c102fec2e160d589720.png

SouthernOcean60S#

reg = 'SouthernOcean60S'
ts_plot(variable, ds, fs, label, reg = reg)
_images/841b2f0b670c6c1c54fa832db3d5594dd3c12f423a2a5886841aec92660e7824.png _images/440b88c4c814fc03d7ef2ebb64660ac987e3da1fcec07ca82e49147c0f404134.png

EGreenlandIceland#

reg = 'EGreenlandIceland'
ts_plot(variable, ds, fs, label, reg = reg)
_images/569479ba3bfd30a94a324af0ebfcc7e1c2869ca2abed5132fd6975789a12c558.png _images/6fdf3a145856f811de9fa2c0da5493a794b1c098275301a50fbdc2487d02b7e6.png

GulfOfMexico#

reg = 'GulfOfMexico'
ts_plot(variable, ds, fs, label, reg = reg)
_images/0a9b089be0a3fdad50a7aecd67814a2dec69be8d1ea11ba6539dcecf3c4c8f8c.png _images/a2a1cfcf395962d31d8ec5af6f78bc3802b3025475953bf42698d6d1e69cda72.png