heat_content_evap#

# Parameters
variable = "heat_content_evap"
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 heat_content_evap 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/efbfddb35e92c81642cfd27ae2ed12913f667ba35c27bf0c7502104b2ef5ae1f.png _images/b4ac0cc9cc46bdd4bbf7f61e64d4da49604d0d21e2097f11cfd9b81d890bd235.png

PersianGulf#

reg = 'PersianGulf'
ts_plot(variable, ds, fs, label, reg = reg)
_images/cde4a76309df1ed9465dd7161a66632464003f1fccfd2058d0009fac186df606.png _images/4b2bbd92a16a10cc82fe60661d92cb9c5217ddd45279b1ded805c16628b1da30.png

RedSea#

reg = 'RedSea'
ts_plot(variable, ds, fs, label, reg = reg)
_images/57e45adf5989c0cbc870df32d7b5c35d00f3c6a6c13593a67094e53d80478fca.png _images/26f7f0ddd4236c9258209b19e975c8577685ba7c5e148535cbe34caf96d6f9bc.png

BlackSea#

reg = 'BlackSea'
ts_plot(variable, ds, fs, label, reg = reg)
_images/9a5284a8fa0da7a13cad49994a7b62524704f136838e3afaaef46b1419c42b46.png _images/29f7799c04c7f0a73d4db6e98dd12d101b241d84ca0df6eeb743c8408b20c9d6.png

MedSea#

reg = 'MedSea'
ts_plot(variable, ds, fs, label, reg = reg)
_images/7e859d4c7437774b8619cfe6b9293f097bcb888411b77ee42095459261972bb0.png _images/96116c1963c0b1fe6173f0fe92cc530697928cc63c4fdd920d0bcc7c58e2e571.png

BalticSea#

reg = 'BalticSea'
ts_plot(variable, ds, fs, label, reg = reg)
_images/1afbf4f08d8cf7e41a5b09f9c0bf08b2913b8c04dae9493fe4a677fffaa70d57.png _images/b687c6f3552dade39d56ffb49f4a00f12e3c9b4168e6c0054d247ba5e0824980.png

HudsonBay#

reg = 'HudsonBay'
ts_plot(variable, ds, fs, label, reg = reg)
_images/26bb98b5e399c5d1e5f4ac1d8ae84613bf54278b5475672eb104b1e54763eab8.png _images/885ff6fb5f9522cd18451142a89cd344a5d17ccbc77527e6766eefe1bff2d5c0.png

Arctic#

reg = 'Arctic'
ts_plot(variable, ds, fs, label, reg = reg)
_images/b7722129c9d2e0efeb14bb4fafbac6dc5458a72da53077f135c46b5a1d6fd1fc.png _images/ef8b84b8fad12df9b9d0951526cfe11b3fb3dc89d147335ab50de8cb6fdcd0bb.png

PacificOcean#

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

AtlanticOcean#

reg = 'AtlanticOcean'
ts_plot(variable, ds, fs, label, reg = reg)
_images/14ba6062c78f8c0744b0d983e9662afa102c7610ba579bbac015c8db10866ed1.png _images/65f87ee82501bb8d92196c5e2eb36221a613d60bab21df71058af4e49617b265.png

IndianOcean#

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

SouthernOcean#

reg = 'SouthernOcean'
ts_plot(variable, ds, fs, label, reg = reg)
_images/9e4b342928b7242eb7c2e174c95a4569d0814250d51220a5f47a617be8f08ce2.png _images/b6f9f9340c91d763264d85009955b01a6704539b6b9a6e38153d5c0e83abab03.png

LabSea#

reg = 'LabSea'
ts_plot(variable, ds, fs, label, reg = reg)
_images/053219803908a707aa823dde3cce65495ddf5172f90729e521cd5d81d4c8451a.png _images/090ff19e35f6c609e667d7530c21d6ccc27451bced62a6bd4327f40af15ab95d.png

BaffinBay#

reg = 'BaffinBay'
ts_plot(variable, ds, fs, label, reg = reg)
_images/e1b8a77a3310b71f2d92d95ebdd32a540a379eb6afa590c99023b5a6b2e772f4.png _images/766b4bf1b5ff5314e74dd6b7e796ca62b72f8a946dd96c5224506111bbf9642d.png

Maritime#

reg = 'Maritime'
ts_plot(variable, ds, fs, label, reg = reg)
_images/0888961d71596b2d930dc3f2fe3e08696d8e6459a4ff77dd40dd5db4fc94c193.png _images/06376decd95e68aec48b01c19b47037f8fd13c44337d7a035588a99993eaaeaf.png

SouthernOcean60S#

reg = 'SouthernOcean60S'
ts_plot(variable, ds, fs, label, reg = reg)
_images/e77769fae4aa4759d345c467e3ae33d081867711ffb1783ea3502f7dfdc39a3f.png _images/0ced60e6e34c8896fe7666fb5041dce1111b0b6cad6ce4d760c675ca7a3df1fb.png

EGreenlandIceland#

reg = 'EGreenlandIceland'
ts_plot(variable, ds, fs, label, reg = reg)
_images/a19cd9f7581fb3950ab4c9033a1cec9e240ae75e118638a4d8035949a770495e.png _images/1c268ec6bd13140799afcdda545c998e468875e639d9e0c5941d236d8d87bf48.png

GulfOfMexico#

reg = 'GulfOfMexico'
ts_plot(variable, ds, fs, label, reg = reg)
_images/1bf6f0184d6b0483117f582ce10a1c950ecf8496076e2b0279eb72fdcd88990f.png _images/962a8d0efd00fa8f6328603ed6f321731fb8665d297aed60905c5bc3f5efa5d1.png