Time series plots of global salinity

Created by Ivan Lima on Tue Sep 1 2020 10:59:05 -0400

In [1]:
%matplotlib inline
import xarray as xr
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import os, datetime, warnings
from cesm_utils import fixtime
warnings.filterwarnings('ignore')
plt.rcParams['figure.dpi'] = 100
print('Last updated on {}'.format(datetime.datetime.now().ctime()))
Last updated on Thu Sep  3 09:47:34 2020

Global salinity plots for U & V restoring run

In [2]:
datadir = '/media/ivan/WD/Data/Postproc/1DPOP'
ds_min = xr.open_dataset(os.path.join(datadir, 'cesm.1dpop.03.abs.min.nc'), decode_times=False)
ds_min = fixtime(ds_min, 2051)
ds_min['time'] = ds_min.time.to_index().to_datetimeindex()

fig, ax = plt.subplots()
_ = ds_min.SALT.to_series().plot(ax=ax)
_ = ax.set(title='SALT global absolute min', ylabel=ds_min['SALT'].units)
In [3]:
ds_max = xr.open_dataset(os.path.join(datadir, 'cesm.1dpop.03.abs.max.nc'), decode_times=False)
ds_max = fixtime(ds_max, 2051)
ds_max['time'] = ds_max.time.to_index().to_datetimeindex()

fig, ax = plt.subplots()
_ = ds_max.SALT.to_series().plot(ax=ax)
_ = ax.set(title='SALT global absolute max', ylabel=ds_min['SALT'].units)
In [4]:
plt.rcParams['xtick.minor.bottom'] = False # fix strange minor ticks in time series plots

ds_mean = xr.open_dataset(os.path.join(datadir, 'cesm.1dpop.03.tseries_global.nc'), decode_times=False)
ds_mean = fixtime(ds_mean, 2051)
ds_mean['time'] = ds_mean.time.to_index().to_datetimeindex()

fig, axs = plt.subplots(2, 2, sharex=True, figsize=(11,9))
for ax, vname in zip(axs.ravel(),['SALT','TEMP','S_INTERIOR','PT_INTERIOR']):
    _ = ds_mean[vname].to_series().plot(ax=ax)
    _ = ax.set(title='{} global mean'.format(vname), ylabel=ds_mean[vname].units)