#!/usr/bin/env python # Wenchang Yang (wenchang@princeton.edu) # Mon Apr 18 11:04:05 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 daname = 'slope' dsnames = ('SST', 'PI', 'RH', 'Vshear') obss = ('ERA5', 'MERRA2') cases = ('NH', 'SH', 'global') for dsname in dsnames: print(dsname) print(' '.rjust(10) + 'NH'.rjust(20) + 'SH'.rjust(20) + 'global'.rjust(20)) for obs in obss: print(obs.rjust(10), end='') for case in cases: #print(cas) ifile = f'{dsname}.tcseason3.{obs}.{case}.1982-2017.nc' da = xr.open_dataset(ifile)[daname] value = da.item() units = da.attrs['units'] print(f'{value:.3f} {units}'.rjust(20), end='') print() print() if __name__ == '__main__': #from wyconfig import * #my plot settings #savefig if len(sys.argv)>1 and 'savefig' in sys.argv[1:]: figname = __file__.replace('.py', f'.png') if 'overwritefig' in sys.argv[1:]: wysavefig(figname, overwritefig=True) else: wysavefig(figname) tt.check(f'**Done**') print() plt.show()