#!/usr/bin/env python # Wenchang Yang (wenchang@princeton.edu) # Wed Jun 25 09:56:34 PM EDT 2025 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 #ifile = 'Data-added-Ingrid-Jun2025_subset.csv' ifile = 'Updated-data-added-Ingrid-Jun28-2025_subset.csv' #updated data df = pd.read_csv(ifile, index_col=0) lat = xr.DataArray(df['Latitude'], dims='location', coords=[df.location]) lon = xr.DataArray(df['Longitude'], dims='location', coords=[df.location]) lon = lon.where(lon<180, other=lon-360) # 0 to 360 -> 0-180 to 180 -> 0 to 360 ds = xr.Dataset(dict(lon=lon, lat=lat)) if __name__ == '__main__': from wyconfig import * #my plot settings from geoplots import mapplot fig, ax = plt.subplots(figsize=(5,4)) im = ds.plot.scatter(x='lon', y='lat', c=range(ds.lon.size)) mapplot() ax = plt.gca() for ii,(idx,r) in enumerate(df.iterrows()): x = r.Longitude y = r.Latitude lname = r.location ax.text(x, y, f'{ii}', alpha=0.3, fontsize='small') print(f'{ii:02d}', f'{idx:03d}', lname, x, y) ax.set_aspect('equal') fig.colorbar(im, label='location # (see locations.csv)') #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()