#!/usr/bin/env python # Wenchang Yang (wenchang@princeton.edu) # Tue Mar 29 12:10:18 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 import geoxarray # if __name__ == '__main__': tt.check('end import') # #start from here ifiles = ''' data_Ts_AM4urban_wasteCool_0urban_amip_5ens_1870-2020.nc data_Ts_AM4urban_wasteCool_amip_5ens_1870-2020.nc data_Ts_AM4urban_wasteCool_urbanNAonly_amip_5ens_1870-2020.nc data_Ts_AM4urban_wasteCool_urbanASonly_amip_5ens_1870-2020.nc '''.split() for ifile in ifiles: ofile = ifile.replace('data_Ts', 'nino34JJA') if os.path.exists(ofile): print('[exits]:', ofile) continue da = xr.open_dataarray(ifile) da = da.sel(lon=slice(360-170, 360-120), lat=slice(-5, 5)).geo.fldmean() #nino34 index da = da.isel(time=(da.time.dt.month>=6)&(da.time.dt.month<=8)).groupby('time.year').mean('time') #JJA mean #save da.to_dataset(name='nino34JJA').to_netcdf(ofile) print('[saved]:', ofile) 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()