#!/usr/bin/env python # Wenchang Yang (wenchang@princeton.edu) # Fri May 28 14:03:59 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 # if __name__ == '__main__': tt.check('end import') # #start from here ds = xr.open_dataset('humh_adjusted.nc') if __name__ == '__main__': from wyconfig import * #my plot settings import xfilter plt.close() lowpass = lambda x: x.filter.lowpass(1/15, dim='year', padtype='constant') fig,ax = plt.subplots(figsize=(8,4)) #adjusted ci = ds.HU.quantile([0.025, 0.975], dim='sample') ax.fill_between(ci.year, ci[0], ci[1], alpha=0.5) ds.HU.mean('sample').plot(label='adjusted') #lowpass ci = ds.HU.pipe(lowpass).quantile([0.025, 0.975], dim='sample') ax.fill_between(ci.year, ci[0], ci[1], alpha=0.5) ds.HU.pipe(lowpass).mean('sample').plot(label='adjusted (LP15)') #raw recorded #ds.HU_raw.plot(color='gray') ds.HU_raw.pipe(lowpass).plot(color='gray', label='recorded (LP15)') #landfall ds.HUlandfall.pipe(lowpass).plot(color='gray', ls='--', label='landfall (LP15)') ax.set_xlim(1850, 2020) ax.set_xticks(range(1850,2021,10)) ax.legend(ncol=2)#frameon=True, loc='lower left') #ax.grid('on') ax.set_xlabel('') ax.set_ylabel('HU #') #savefig if 'savefig' in sys.argv: figname = __file__.replace('.py', f'.png') wysavefig(figname) tt.check(f'**Done**') plt.show()