# 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))
The history saving thread hit an unexpected error (OperationalError('attempt to write a readonly database')).History will not be written to the database.
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/74b0f7ef97a3de42e6f1ff69bf0a6a47b219c9bb523a10367f31c25c4d374c2b.png ../_images/388f2fd31ba8249fbc7babc34c1ba204d6e9c3559c6f7cd5dac40c34728b7d18.png

PersianGulf#

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

RedSea#

reg = 'RedSea'
ts_plot(variable, ds, fs, label, reg = reg)
../_images/997e30119542be0d0ed5823825c0a8edf2a6c15cb88b623be8e8dea1ebb144e4.png ../_images/d3d60a2ce3ce4d4763971959b124d053b2c0573f6846497faf8872afefce29b5.png

BlackSea#

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

MedSea#

reg = 'MedSea'
ts_plot(variable, ds, fs, label, reg = reg)
../_images/5ef2ae421af3e28fa333a552cfe339f9db19eba4433b0d915a913b0fe2a88410.png ../_images/fd65e43b158b3b8b4f51eb321281924793dbc0eacc9d685789669820d81ae3db.png

BalticSea#

reg = 'BalticSea'
ts_plot(variable, ds, fs, label, reg = reg)
../_images/54e973d9a5c1bc508ea59b87cb4a12d9d23facc78b7043da7bbbab8a2b590f54.png ../_images/8108920f3ac4ca287b98b7e6132d1842058d5b632535dddb665962a83acb8cb2.png

HudsonBay#

reg = 'HudsonBay'
ts_plot(variable, ds, fs, label, reg = reg)
../_images/5f562ea9e85454b4f76bb40accad85dd337b347a8c4bead701da527f76ccdfdc.png ../_images/7897d2f8fa12e7abd3f376d7a4cdb46cbb3a165b3aa8064e5d6cb7086335da88.png

Arctic#

reg = 'Arctic'
ts_plot(variable, ds, fs, label, reg = reg)
../_images/a2aedd41b9a11b06e0ac28bd9d087a1939ea52fd26b0a2269e301993991e4fff.png ../_images/271c42a80bfc0627cfcbb8c85e9a8a05901c6b8cbb978d7a7f790cf04cea42a2.png

PacificOcean#

reg = 'PacificOcean'
ts_plot(variable, ds, fs, label, reg = reg)
../_images/4cfe2af98e15e6c8eabce44db58d2095635d40bf2f8bc5c1c9f733a2b2ac0092.png ../_images/c3eabb282488239614369996f75ffb6580704ff94492b0290e85a96e8ed808b5.png

AtlanticOcean#

reg = 'AtlanticOcean'
ts_plot(variable, ds, fs, label, reg = reg)
../_images/6aa38d618b9a6be5d33e0cf242f96b3951783bd19717e67550139656b0a4e298.png ../_images/d910ca9c5dc9369c1a54eb79e50dc42b4363c741b394053e02670a7abc5bccdb.png

IndianOcean#

reg = 'IndianOcean'
ts_plot(variable, ds, fs, label, reg = reg)
../_images/dd720b867f5ffe687f9ff6d0104f377a4ffbd819d788035cfbd5a89eac1c4f26.png ../_images/b66d6228ef0e8201d682865fde0c3fb3f387661d647188a4d68ce1c5bd1603df.png

SouthernOcean#

reg = 'SouthernOcean'
ts_plot(variable, ds, fs, label, reg = reg)
../_images/17a46cda15ed5433d363cff6d101dbe76b445ee17fbcdefab144bb911b2cb018.png ../_images/5108539d690a9545cdd3b55a7dcaa627907d9068c8b5adad9251386475612f75.png

LabSea#

reg = 'LabSea'
ts_plot(variable, ds, fs, label, reg = reg)
../_images/c9681d199c2198c48f6ccf7f9520717c2c2047b5b89795da642cbaba188988a7.png ../_images/be0bbb7046da5d7c4c6b0f06ae77fe9752ce60cfe03a2d7bf2514d929edeea92.png

BaffinBay#

reg = 'BaffinBay'
ts_plot(variable, ds, fs, label, reg = reg)
../_images/29bb3c47238aa34f79a4cb644138a74dfb75653213d1082bcd0ff0c5f7942044.png ../_images/edf35f3b8233520b621da05e86bd19a84abb3a0b4d7364e8e07c3031b3a6db64.png

Maritime#

reg = 'Maritime'
ts_plot(variable, ds, fs, label, reg = reg)
../_images/2bb6ce16c5c42fa998bb2669bf54f4b022c92ca8c1b970ac1505a8227792a51e.png ../_images/0e39d54587875cc7b2c7d4dd40e41bafd6dc2f42a8a3bb7d24eae2639ec04103.png

SouthernOcean60S#

reg = 'SouthernOcean60S'
ts_plot(variable, ds, fs, label, reg = reg)
../_images/939104f049b8f82c5aaf569519f68094cad31ed980b97a0da6ae4c7252ab55c0.png ../_images/6b0dd4f918911c4e6278941d3ee29a18ebc0c691c71c4d260227dd4a86a31b1e.png

EGreenlandIceland#

reg = 'EGreenlandIceland'
ts_plot(variable, ds, fs, label, reg = reg)
../_images/14b38704482965e2ed949525a21c0bccd81cd45f87463ccb4740db9a037dba82.png ../_images/b3876b6d172eaf7b2827d8db37d8a12e2784e769ce5049ef5a6609cb21b6a2c6.png

GulfOfMexico#

reg = 'GulfOfMexico'
ts_plot(variable, ds, fs, label, reg = reg)
../_images/5945041637842e7939067258f6ff8e34f602cef30b7977d45b90f218bcac4701.png ../_images/04f2326136297e393f49e610f558c6b93778e80dbaab20d5635532b9c5d14e9f.png