#!/usr/bin/env python # Wenchang Yang (wenchang@princeton.edu) # Fri Sep 10 17:25:40 EDT 2021 if __name__ == '__main__': from misc.timer import Timer tt = Timer(f'start {__file__}') import sys, os.path, os, glob, datetime import xarray as xr, numpy as np, pandas as pd, matplotlib.pyplot as plt #more imports import xfilter # if __name__ == '__main__': tt.check('end import') # #start from here ifile = 'LMR2018_ssttc_transformed.nc' ds_lmr2018tf = xr.open_dataset(ifile) ifile = 'LMR2019_ssttc_transformed.nc' ds_lmr2019tf = xr.open_dataset(ifile) if __name__ == '__main__': from wyconfig import * #my plot settings lpwindow =40 lowpass = lambda x: x.filter.lowpass(1/lpwindow, dim='year', padtype='even') selyears = lambda x: x.sel(year=slice(850, None)) fig, ax = plt.subplots() alpha = 0.1 daname = 'HU' #lmr2018tf da = ds_lmr2018tf[daname].pipe(lowpass).pipe(selyears) da.plot(hue='MCrun', add_legend=False, color='C0', alpha=alpha, ax=ax) da.mean('MCrun').plot(color='C0', ax=ax) #lmr2019tf da = ds_lmr2019tf[daname].pipe(lowpass).pipe(selyears) da.plot(hue='MCrun', add_legend=False, color='C1', alpha=alpha, ax=ax) da.mean('MCrun').plot(color='C1', ax=ax) #savefig if 'savefig' in sys.argv: figname = __file__.replace('.py', f'.png') wysavefig(figname) tt.check(f'**Done**') plt.show()