#!/usr/bin/env python # Wenchang Yang (wenchang@princeton.edu) # Mon May 20 16:54:29 EDT 2024 if __name__ == '__main__': import sys,os from misc.timer import Timer tt = Timer(f'[{os.getcwd()}] 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 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 import salem # if __name__ == '__main__': tt.check('end import') # #start from here #Ordos shapefile ifile = 'chn_adm_ocha_2020_shp/chn_admbnda_adm2_ocha_2020.shp' shdf = salem.read_shapefile(ifile) shdf = shdf[shdf['ADM2_EN']=='Ordos'] shdf_ordos = shdf #print(shdf.iloc[0,:].min_x) shdf0 = shdf.iloc[0,:] lonmin, lonmax, latmin, latmax = shdf0.min_x, shdf0.max_x, shdf0.min_y, shdf0.max_y #China shapefile ifile = 'chn_adm_ocha_2020_shp/chn_admbnda_adm1_ocha_2020.shp' shdf = salem.read_shapefile(ifile) shdf_china = shdf if __name__ == '__main__': from wyconfig import * #my plot settings from geoplots import mapplot fig,ax = plt.subplots() shdf_china.boundary.plot(ax=ax, lw=0.5, color='gray') shdf_ordos.boundary.plot(ax=ax, color='C1', label='Ordos City') ax.plot([lonmin, lonmax, lonmax, lonmin, lonmin], [latmin, latmin, latmax, latmax, latmin], color='C0', label='lonlatbox') mapplot(coastlines_color='none') ax.legend(loc='upper left') #ax.set_aspect('equal') #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) tt.check(f'**Done**') print() if 'notshowfig' in sys.argv or 'n' in sys.argv: pass else: if 'plt' in globals(): plt.show()