seaice_melt_heat#

# Parameters
variable = "seaice_melt_heat"
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 seaice_melt_heat 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/0e1e108833c3b6d1de53994e7babc1a3532e0bf1cea41623a6fd1ddd51dd4912.png _images/98260a08c6e5d1d726077d1f2525df36473183ac8d70a068ce156a08c766b605.png

PersianGulf#

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

RedSea#

reg = 'RedSea'
ts_plot(variable, ds, fs, label, reg = reg)
_images/12bfbece0bda39128b9c2b4653e9297c1d1b1be157f0e0df787c04e9ad1cbb55.png _images/e4638d1deb0710b47fa01b2090159f21eb3a708c0850791e4485bebf6b6a6632.png

BlackSea#

reg = 'BlackSea'
ts_plot(variable, ds, fs, label, reg = reg)
_images/227a7c94dba3618da73871d9ca6c1f2dd0c04e35cb32241304e9fa2c1641a200.png _images/33ef4106f64248f15e37f3dc3b49dc1f9ade1f6eea4ca6abcf587cb3deb7a183.png

MedSea#

reg = 'MedSea'
ts_plot(variable, ds, fs, label, reg = reg)
_images/4beba81edbff12b4a77f0e6865e52c34f74b8e9fe0c81da6b2ca2c4f9b4445dc.png _images/34d2ca4522a24c8e929cf7026d03d3bd082ffe9359c31c820af02b34167989e3.png

BalticSea#

reg = 'BalticSea'
ts_plot(variable, ds, fs, label, reg = reg)
_images/af695e506e4c76e208a718c2eebb705af1438d1ff21030f24e5f1111dca31ee4.png _images/a8c8db488013e79dc5ff49e1d8be2bf677ef80478f62a5ba684e748a3e5be644.png

HudsonBay#

reg = 'HudsonBay'
ts_plot(variable, ds, fs, label, reg = reg)
_images/49f65bcf0f4261eae75b8c4135419a9e3a77b66b00d0722c0f88b5d37954487e.png _images/a46678eea771a894749b13232aca77278a474cf074734c9f07859afad2a4057c.png

Arctic#

reg = 'Arctic'
ts_plot(variable, ds, fs, label, reg = reg)
_images/d102a6e3773d5baf4685b95810ac518ee73cccd344657c7574352f99a8caa5d0.png _images/5067d4b658c8e1ccb94f98ffb2af4dac1e0776c35a1f6768bf5502a1a7b08df7.png

PacificOcean#

reg = 'PacificOcean'
ts_plot(variable, ds, fs, label, reg = reg)
_images/1e48cc9df4579bd1ea2511710eab10d7cc22419fd3be876cf7081c8415b54959.png _images/e32ae97928f6f9fcd7b94b35f6e43f42c636c92f228eeee37a607ada5ad6fca6.png

AtlanticOcean#

reg = 'AtlanticOcean'
ts_plot(variable, ds, fs, label, reg = reg)
_images/7bf00f80a64b488044c927573ed1301b8c6dc70aec84e726a1e55a23ee610d11.png _images/601cb2086e0fec35d7a6026d6343f7a6bb9917d3cf4deda5d9f267e5c6f20511.png

IndianOcean#

reg = 'IndianOcean'
ts_plot(variable, ds, fs, label, reg = reg)
_images/9344e63da94a307839265f360d6c0c43543516cdbb52d25dbe8731677ba1e677.png _images/c3e81bcd26b107d1cc4a6c71bda2c17da9de28b97060c69ae29a1b415c3bf951.png

SouthernOcean#

reg = 'SouthernOcean'
ts_plot(variable, ds, fs, label, reg = reg)
_images/54e6ed216173e94cefeaa6162fa6df0025512defce3009333575f7bd1f58318f.png _images/4ce5ad429f610f4344cf77162210e509dd37a71fd5209770e49a4ba7c390ba9d.png

LabSea#

reg = 'LabSea'
ts_plot(variable, ds, fs, label, reg = reg)
_images/5ffaae22d6acbf55e5b630c8481e5fc787a65c6c5b1d47e9093a4a9a10a851f3.png _images/917d134bc922c54c1f27c5b5a2ca00338afcec0614acb4b589f04a666ace664a.png

BaffinBay#

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

Maritime#

reg = 'Maritime'
ts_plot(variable, ds, fs, label, reg = reg)
_images/1db21d3a9f930d19a496184ee3f3116df232e825cdd7b8c66f82934687d30d05.png _images/ff56db0a8f8c994f176ef03205d251be34603e58383efd463f6e44872470fe50.png

SouthernOcean60S#

reg = 'SouthernOcean60S'
ts_plot(variable, ds, fs, label, reg = reg)
_images/6b32cb8e7221e39d50698a42e0adbb51bc7d33b95e010d7a3db582a3c8d097fb.png _images/f0dab36d938dfa4721ee5e386df6bb75e772a81d3d98b67effc37fa723545fe0.png

EGreenlandIceland#

reg = 'EGreenlandIceland'
ts_plot(variable, ds, fs, label, reg = reg)
_images/e687330eae81240eb04ab00073436855e1cc8aa1196cd01845a6908e6222fb4a.png _images/e4c63cc65737577644c9cd09fce9faa2f4db8aea23bca8811cbe2a8fd3c9f141.png

GulfOfMexico#

reg = 'GulfOfMexico'
ts_plot(variable, ds, fs, label, reg = reg)
_images/5fe6ef28c892b172da90868cda388c98ab9977d9816ff62b06fe419bab27fb3d.png _images/b1ca6accd98776f03782a38e126ed30b38eb25bbfa6d199e6435575d2f82f39d.png