# Parameters
variable = "evs"
long_name = "Water Evaporation Flux Where Ice Free Ocean over Sea"

evs#

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 evs 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/d77d0fef9b93d30a1015d4f6eff3197e8b643898159c19ab3f3b1d34c17cd89e.png ../_images/10a71cfce2ee6f08134b4ad45ba586774e90e31b2ad0d0e409a0c92774b05c98.png

PersianGulf#

reg = 'PersianGulf'
ts_plot(variable, ds, fs, label, reg = reg)
../_images/09967aacff72f9905a2682654f7c5d05377ab89080beb85662e7c358da23fd03.png ../_images/2939917fd2280c35b82cfbe6532f7df5e2d5b5921e57bbced0875eac3b1e6969.png

RedSea#

reg = 'RedSea'
ts_plot(variable, ds, fs, label, reg = reg)
../_images/921aa15efb9b089eff617e7633162aa35f4f134924b1a3d5e5b604db6c2fdee3.png ../_images/f0fdd18db435783ec19fc00bf7fab74e63def6035e7aea669dddd3886c799c53.png

BlackSea#

reg = 'BlackSea'
ts_plot(variable, ds, fs, label, reg = reg)
../_images/5f13bfefdd51fb80ca3c43083685069fc18d77d64975348ac3b07eb688acb33e.png ../_images/18aced33cdb00b4bac5730469134f77f8b759f2f7b64cc16873e233ad4198c3b.png

MedSea#

reg = 'MedSea'
ts_plot(variable, ds, fs, label, reg = reg)
../_images/859f2937563335624ccb48f8b92290a0b3bfaf347f14fe58030da6f4cac25ab1.png ../_images/26268a3763e671887377ee667fde146e8f3755abdcd1974426f61ae60804feda.png

BalticSea#

reg = 'BalticSea'
ts_plot(variable, ds, fs, label, reg = reg)
../_images/192702a2b6c9202db8b611d76b0817cd26deb8f011ca56edc78301a877545606.png ../_images/acec31e1e96151911e4b41cf5634e2fcd4c1745a030192116298e5b049b08b4a.png

HudsonBay#

reg = 'HudsonBay'
ts_plot(variable, ds, fs, label, reg = reg)
../_images/9efe08911b6142d0e622135f4eb4785653481d6a1c6c3354677ca421283b970b.png ../_images/01a9f748a1fb565efc456c687bed1fa4a83f2d3622b6835a7a41c8012eaf49ce.png

Arctic#

reg = 'Arctic'
ts_plot(variable, ds, fs, label, reg = reg)
../_images/93f635ed6f2e91a8b188e26e495d5d27124f4cc095809d4ca9b68e455dded918.png ../_images/acceb9593379871d90d7af26964805283f0bb938b07976d194fbf80014ba522f.png

PacificOcean#

reg = 'PacificOcean'
ts_plot(variable, ds, fs, label, reg = reg)
../_images/cd8bb8d1f0f9828cbeab876c8796d563a48bcafb80ffd8dff9318a4e84bed936.png ../_images/84c53d18883a5bd3208c34585ef51d4fdea1f9c9ddf8e0ed0bd957cd731b1f96.png

AtlanticOcean#

reg = 'AtlanticOcean'
ts_plot(variable, ds, fs, label, reg = reg)
../_images/6b611abe4a3f40adabde5d5a671c44d8b0ef4f7abef8fee46af0d01adb44a727.png ../_images/1a2f9bc4515378fe47587463c4df28912de30cb1974ce494a8d2b9c0ee11f111.png

IndianOcean#

reg = 'IndianOcean'
ts_plot(variable, ds, fs, label, reg = reg)
../_images/1e091c8ef2e75c6adcd3b8c09def23aba9c39fefad7daa608e82bf65ba7784af.png ../_images/8eb7629a61e00e821e895af510d26f051ac2d1429ace0a7bab6f032d142742ba.png

SouthernOcean#

reg = 'SouthernOcean'
ts_plot(variable, ds, fs, label, reg = reg)
../_images/6fcb7ceb0947ce6423233b279bfc9c905acf7a02a73abe4ca82a5dfeb0da7e49.png ../_images/52cf15b33afd31e399006daada06e23b8a0b9771c50cda26127e0532d599a7dc.png

LabSea#

reg = 'LabSea'
ts_plot(variable, ds, fs, label, reg = reg)
../_images/2267cb998cba47f9bbab3792c1c4e71b2946948abb2fd451134a4d9d0b9de97d.png ../_images/fb58dcd2f2c8dd895f7d7f2f6096f21d4391b7bb6dd0b4d88b93a26a02c3c457.png

BaffinBay#

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

Maritime#

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

SouthernOcean60S#

reg = 'SouthernOcean60S'
ts_plot(variable, ds, fs, label, reg = reg)
../_images/a4ef4c9f76fad0cc2ba71676d6173b597bd6bc065c5254e680d6d27f7c6da335.png ../_images/d5a156fd0ed5001fa593e73a7e79dba56a5dc17cf4b3301602167f25764b47b4.png

EGreenlandIceland#

reg = 'EGreenlandIceland'
ts_plot(variable, ds, fs, label, reg = reg)
../_images/3b852fcea1deb2bc81e49dc468ec3157b81f1deda72221c5c3f803c0707cbfc9.png ../_images/440e7bb1eb529b174766901fe41e0a67b288e5c737d24105492bdbb876ee44fb.png

GulfOfMexico#

reg = 'GulfOfMexico'
ts_plot(variable, ds, fs, label, reg = reg)
../_images/b54586fd6e5267057a94097664f83338ea32d37b7f4ba3d10504cc7020001b04.png ../_images/704c02846df8d1e5311eabc7dcf19f17b84f2d2adc304dab6aeee148aa965d85.png