# 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/9c1ef7b2eab73a0f9f5cd7f27698561e9f7459d66d07dfa7c0fb9a0b4e831bfd.png ../_images/9573271af831280269b1755afeda8ca203c0bd40f88b05d6ad065eebf5657671.png

PersianGulf#

reg = 'PersianGulf'
ts_plot(variable, ds, fs, label, reg = reg)
../_images/efda8461024a30bd9f819e667d2b4235429cd5cf91648cbf820609796d082aaa.png ../_images/170bebda4aa778a827594e677ab69b5a4f654dd729c951800ed4960795074253.png

RedSea#

reg = 'RedSea'
ts_plot(variable, ds, fs, label, reg = reg)
../_images/155bd7d09dc4a7f44ae756458080588cef6c0f845fa4e854e8f31b8d8f712179.png ../_images/6699398dc7aa0aa2a5b2878afea0240dc82fd7ef512156cb755a221f6213fc80.png

BlackSea#

reg = 'BlackSea'
ts_plot(variable, ds, fs, label, reg = reg)
../_images/cb857804f5ee3a79f32fc6277c353e819134ed5698c76775c72f7ab6eb0aca7b.png ../_images/fdef5accb3f2d171fb7f1cbc962ae3ccc7a96feed2185c4c732fdde29528e42e.png

MedSea#

reg = 'MedSea'
ts_plot(variable, ds, fs, label, reg = reg)
../_images/0edd9e4113e2e4c83bab7f7dc68b9192f51d93eccc118cfaf34a4be57fadc90b.png ../_images/25b1623bad49b1f28f9c51c9a93e4121ccc01b2e7252e16ca85358a9f3a9497e.png

BalticSea#

reg = 'BalticSea'
ts_plot(variable, ds, fs, label, reg = reg)
../_images/63ed22999e89bb2c2f53fa68fc4a809ec22eaee10a9e2af247fdafb7ed890392.png ../_images/6cafc8e57cf4c06b7d1edfa28fc6d844a093432ffb5c4b02cdc3db848773c50a.png

HudsonBay#

reg = 'HudsonBay'
ts_plot(variable, ds, fs, label, reg = reg)
../_images/f3b1f7c2678ebc204e6c0d14ae6f0d1dfa2367c7d65d64b5398229488bcda3eb.png ../_images/5fb7ed0d8e0208fb6eae04fe32201275ff9a5266eaf255d20dca64f563aa8dd7.png

Arctic#

reg = 'Arctic'
ts_plot(variable, ds, fs, label, reg = reg)
../_images/d03b89882ba4983a52b4cf9c27bb1b976ef8213fa10acab859a7e016c3b889f2.png ../_images/869cc08235f2ed05edc50c3d8327b1f21761957d1a996df25bcd06945e007ccc.png

PacificOcean#

reg = 'PacificOcean'
ts_plot(variable, ds, fs, label, reg = reg)
../_images/1098a17c81a846892288bc7fe2e432dfeec88bbc6eb13b77e04c9b1fdf8f6f43.png ../_images/dd3843a5e3ccf51f6f39b488b6cf65c524b8f92348bb13bf54c6c6995ff0df33.png

AtlanticOcean#

reg = 'AtlanticOcean'
ts_plot(variable, ds, fs, label, reg = reg)
../_images/353387c19f309519508cb647125cc7029de7e302bffad261bd5280b3b22f0f29.png ../_images/7066f7234fac03a4d8962395a07996a1a9a6eff8e9fc38c6ef8a55f3e20f8e86.png

IndianOcean#

reg = 'IndianOcean'
ts_plot(variable, ds, fs, label, reg = reg)
../_images/00ab317921341ed9b838356013c9f7c34967a0e2a44b654ae58da35887319e2c.png ../_images/82d0fd3cd7c1f16b29a9538438a860f089b7110a5295142be9597cc3c9e256d7.png

SouthernOcean#

reg = 'SouthernOcean'
ts_plot(variable, ds, fs, label, reg = reg)
../_images/2ff3dc9152bfbd88c7bd3142d0e161fd6e3a16176a959aa7f49e40e7976c4afb.png ../_images/3e323ded4703d79609243ae598590060ad34d6c8927b61617770505ebfdda10a.png

LabSea#

reg = 'LabSea'
ts_plot(variable, ds, fs, label, reg = reg)
../_images/6278ccebca461e917983d24fb5fd0d43e5eb95f4d9df1838f6f39256cd7d0373.png ../_images/ee9df021bd24667506970755bb1e3073e039098c95fbe6098d4c67e03d90b5b8.png

BaffinBay#

reg = 'BaffinBay'
ts_plot(variable, ds, fs, label, reg = reg)
../_images/fa5c383fe3715c4949e8d7b24f89316142b5d971fb744853611856520a7777bd.png ../_images/2ccc5bc776307d2be63b7ae5713c27402a9fa58f3d58185309aebe6a7af28535.png

Maritime#

reg = 'Maritime'
ts_plot(variable, ds, fs, label, reg = reg)
../_images/82fd526b971233aa7e56683f342fdbdcb849865dd0f0294808c0919fb240f029.png ../_images/eaf15704852df69667b2d8f42af65dd116ba7ccb311088930fcc46be45a2ff1c.png

SouthernOcean60S#

reg = 'SouthernOcean60S'
ts_plot(variable, ds, fs, label, reg = reg)
../_images/ff446c27c320dd3d3fff59629cdd69a266060347bcc2920e23f0cff406b4da8a.png ../_images/286c45f464c1768a2a9efeee74c6ab0bb12309d936d2e22306d709405d1bef23.png

EGreenlandIceland#

reg = 'EGreenlandIceland'
ts_plot(variable, ds, fs, label, reg = reg)
../_images/c24f6c0decb140afc47cd74d908c82488be4dab30ceda84dfe387c8c826c3f9d.png ../_images/06d5e712a7492d70a41e5336b622cad0b57f33d4664afe77a1940a7b1f64264c.png

GulfOfMexico#

reg = 'GulfOfMexico'
ts_plot(variable, ds, fs, label, reg = reg)
../_images/95863cc5f15c775209f4a485b2d1b2be71b1ed28896497bf766cbad72e2985ca.png ../_images/dfa7146001cc3e77547a228b37aa854f61971263a8465ca04220a0db0214bbca.png