#!/usr/bin/env python # Wenchang Yang (wenchang@princeton.edu) # Fri Aug 5 11:50:49 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 ofile = 'gps_facilities_all_clim.csv' if os.path.exists(ofile): print('[exists]:', ofile) sys.exit() #load data da = xr.open_dataarray('era5.2m_temperature.monthly.200001-202204.nc').load() df = pd.read_csv('gps_facilities_all.csv', index_col=0) ds = xr.Dataset(df) #nearest interp daa = da.sel(longitude=ds.longitude, latitude=ds.latitude, method='nearest') #save data df['latitude_clim'] = daa.latitude.values df['longitude_clim'] = daa.longitude.values df.to_csv(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() if 'notshowfig' in sys.argv: pass else: plt.show()