#!/usr/bin/env python # Wenchang Yang (wenchang@princeton.edu) # Mon Nov 18 19:15:46 EST 2024 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 # if __name__ == '__main__': try: tt.check('end import') except: pass # #start from here aerosol = get_kws_from_argv('aerosol', 'SO4') ifile = f'/projects/w/wenchang/analysis/TC/HIRAM/CTL1990s_v201910_zero{aerosol}_tigercpu_intelmpi_18_540PE/netcdf/tc_density.TS17.0101-0150.yearly.nc' ds = xr.open_dataset(ifile) #ctl ifile = '/projects/w/wenchang/analysis/TC/HIRAM/CTL1990s_v201910_tigercpu_intelmpi_18_540PE/netcdf/tc_density.TS17.0101-0300.yearly.nc' ds_ctl = xr.open_dataset(ifile) #slp ifile = f'/projects/w/wenchang/analysis/HIRAM/annualmean/slp_HIRAM_CTL1990s_v201910_zero{aerosol}_tigercpu_intelmpi_18_540PE_0101-0150_annualmean.nc' da = xr.open_dataarray(ifile) #ctl ifile = ifile.replace(f'_zero{aerosol}_', '_').replace('0150', '0300') da_ctl = xr.open_dataarray(ifile) if __name__ == '__main__': from wyconfig import * #my plot settings from geoplots import mapplot with xr.set_options(keep_attrs=True): daa = ds_ctl.density.mean('year') - ds.density.mean('year') daa = daa.sel(lat=slice(-60,60)) daa.plot.contourf(levels=21) #fig,ax = plt.subplots() with xr.set_options(keep_attrs=True): daa = da_ctl.mean('time') - da.mean('time') daa = daa.sel(lat=slice(-60,60)) daa.plot.contour(levels=21, colors='C2', linewidths=0.5) #mapplot() mapplot() ax = plt.gca() ax.set_title(f'TC track density (shading) and SLP (contours) anom: CTL $-$ zero{aerosol}') #savefig if 'savefig' in sys.argv or 's' in sys.argv: figname = __file__.replace('.py', f'__{aerosol}.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()