#!/usr/bin/env python # Wenchang Yang (wenchang@princeton.edu) # Sat Mar 2 11:17:10 EST 2024 if __name__ == '__main__': import sys,os from misc.timer import Timer tt = Timer(f'[{os.getcwd()}] 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 wython = '/tigress/wenchang/wython' if wython not in sys.path: sys.path.append(wython); print('added to python path:', wython) from misc import get_kws_from_argv # if __name__ == '__main__': tt.check('end import') # #start from here model = get_kws_from_argv('model', 'FLOR') if model == 'FLOR': ifile = '/tiger/scratch/gpfs/wenchang/FLOR/work/CTL1990_v201905_tigercpu_intelmpi_18_576PE_reproduce/POSTP/20010101.atmos_4xdaily.nc' ifile0 = '/tigress/wenchang/MODEL_OUT/CTL1990_v201905_tigercpu_intelmpi_18_576PE/POSTP_deflate1/20010101.atmos_4xdaily.nc' expname = 'CTL1990_v201905_tigercpu_intelmpi_18_576PE' elif model == 'HIRAM': ifile = '/tigress/wenchang/MODEL_OUT/HIRAM/CTL1990s_v201910_plus4K_redoNewDiag_tigercpu_intelmpi_18_540PE/POSTP/01500101.atmos_4xdaily.nc' ifile0 = '/tigress/wenchang/MODEL_OUT/HIRAM/CTL1990s_v201910_plus4K_tigercpu_intelmpi_18_540PE/POSTP/01500101.atmos_4xdaily.nc' expname = 'CTL1990s_v201910_plus4K_tigercpu_intelmpi_18_540PE' ds = xr.open_dataset(ifile) ds0 = xr.open_dataset(ifile0) if __name__ == '__main__': from wyconfig import * #my plot settings from geoplots import mapplot fig,axes = plt.subplots(3,1, figsize=(6,8), dpi=120) ax = axes[0] ds0.slp.isel(time=-2).plot(ax=ax) ax.set_title('original', loc='right') ax = axes[1] ds.slp.isel(time=-2).plot(ax=ax) ax.set_title('reproduce', loc='right') ax = axes[2] da = ds.slp.isel(time=-2) - ds0.slp.isel(time=-2) da.plot(ax=ax) ax.set_title('diff', loc='right') for ax in axes: ax.set_xlabel('') ax.set_ylabel('') mapplot(ax=ax) fig.suptitle(f'{model} {expname}') #savefig if 'savefig' in sys.argv or 's' in sys.argv: figname = __file__.replace('.py', f'.png') if model != 'FLOR': figname = figname.replace('.png', f'__{model}.png') if 'overwritefig' in sys.argv or 'o' in sys.argv: wysavefig(figname, overwritefig=True) else: wysavefig(figname) tt.check(f'**Done**') print() if 'notshowfig' in sys.argv or 'n' in sys.argv: pass else: if 'plt' in globals(): plt.show()