#!/usr/bin/env python # Wenchang Yang (wenchang@princeton.edu) # Wed Apr 27 21:19:12 EDT 2022 if __name__ == '__main__': import sys from misc.timer import Timer tt = Timer('start ' + ' '.join(sys.argv)) 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 ifile = 'data_precip_FLOR_histRCP45_5ens_1861-2100_SouthAfrica_2drun_maxJul-Jun.nc' daname = 'precip' units = 'mm/day' title = f'FLOR histRCP45 5ens 1861-2100 SouthAfrica 2drun maxJul-Jun' tag = '_' + title.replace(' ', '_') da = xr.open_dataarray(ifile) if __name__ == '__main__': from wyconfig import * #my plot settings da.plot(hue='ens', color='C0', lw=1, alpha=0.3, add_legend=False) da.mean('ens').assign_attrs(units=units).plot(color='C0') plt.title(title, loc='left') #savefig if len(sys.argv)>1 and 'savefig' in sys.argv[1:]: figname = __file__.replace('.py', f'{tag}.png') if 'overwritefig' in sys.argv[1:]: wysavefig(figname, overwritefig=True) else: wysavefig(figname) tt.check(f'**Done**') print() plt.show()