#!/usr/bin/env python # Wenchang Yang (wenchang@princeton.edu) # Tue Dec 1 11:52:52 EST 2020 if __name__ == '__main__': from misc.timer import Timer tt = Timer(f'start {__file__}') import sys, os.path, os, glob import xarray as xr, numpy as np, pandas as pd #import matplotlib.pyplot as plt #more imports # if __name__ == '__main__': tt.check('end import') # #start from here ifile = '/tigress/wenchang/analysis/TC_statmodel/HadISST.sstindex.187001-201912.nc' ds = xr.open_dataset(ifile) if __name__ == '__main__': from wyconfig import * #my plot settings ds = ds.sel(time=slice('1980', '2018')) #figname = __file__.replace('.py', f'_{tt.today()}.png') fig, ax = plt.subplots() da = (ds.sst_mdr - ds.sst_trop).groupby('time.month').mean('time') da.plot(ax=ax, marker='o', label='SST_MDR $-$ SST_Trop', color='C0') ax.set_ylabel('$^\circ$C') ax.legend(loc='upper left') ax_ = ax.twinx() da = np.exp(da) da.plot(ax=ax_, marker='o', fillstyle='none', label='exp(SST_MDR $-$ SST_Trop)(right)', color='C1') ax_.set_ylabel('') ax_.legend(loc='lower right') ax_.set_title('Annual cycle of MDR relative SST from HadISST(1980-2018)') if len(sys.argv)>1 and sys.argv[1]=='savefig': figname = __file__.replace('.py', '.png') wysavefig(figname) tt.check(f'**Done**') plt.show()