#!/usr/bin/env python # Wenchang Yang (wenchang@princeton.edu) # Thu Jan 22 11:39:45 AM EST 2026 if __name__ == '__main__': import sys,os try: from misc.timer import Timer tt = Timer(f'[{os.getcwd()}] start ' + ' '.join(sys.argv)) except: pass 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 from misc.seasons import sel_season # if __name__ == '__main__': try: tt.check('end import') except: pass # #start from here season = 'OND' #ifile = 'precip_AM2.5C360_nmmeHindcastJan01L12mon_tiger3_intel24ifort_openmpi_2430PE_10ens_1997-1998_ONDmean.nc' ifile = '/tigress/wenchang/analysis/AM2.5C360/seasonmean/precip_AM2.5C360_nmmeHindcastJan01L12mon_tiger3_intel24ifort_openmpi_2430PE_10ens_1997-1998_ONDmean.nc' da = xr.open_dataarray(ifile) daa = da.sel(time='1998').mean('time').mean('ens') - da.sel(time='1997').mean('time').mean('ens') #obs ifile = '/projects/w/wenchang/data/gpcp/v2p3/precip.mon.mean.197901_202412.nc' ds = xr.open_dataset(ifile) da_o = ds.precip da_o = da_o.pipe(sel_season, season).resample(time='AS').mean() daa_o = da_o.sel(time='1998').mean('time') - da_o.sel(time='1997').mean('time') if __name__ == '__main__': from wyconfig import * #my plot settings from geoplots import mapplot fig,axes = plt.subplots(2, 1, figsize=(6,6), sharex=True) ax = axes[0] daa_o.plot.contourf(ax=ax, vmax=5, levels=21, cmap='BrBG') ax.set_title('OND precip diff: 1998 minus 1997, GPCP') ax = axes[1] daa.plot.contourf(ax=ax, vmax=5, levels=21, cmap='BrBG') ax.set_title('OND precip diff: 1998 minus 1997, AM2.5C360 NMME') for ax in axes: plt.sca(ax) mapplot() #savefig if 'savefig' in sys.argv or 's' in sys.argv: figname = __file__.replace('.py', f'.png') if 'overwritefig' in sys.argv or 'o' in sys.argv: wysavefig(figname, overwritefig=True) else: wysavefig(figname) try: tt.check(f'**Done**') except: pass print() if 'notshowfig' in sys.argv or 'n' in sys.argv: pass else: if 'plt' in globals(): plt.show()