#!/usr/bin/env python # Wenchang Yang (wenchang@princeton.edu) # Thu Mar 18 15:32:26 EDT 2021 if __name__ == '__main__': from misc.timer import Timer tt = Timer(f'start {__file__}') import sys, os.path, os, glob, datetime import xarray as xr, numpy as np, pandas as pd, matplotlib.pyplot as plt #more imports from get_data_wt import daname, ds_tmean as ds # if __name__ == '__main__': tt.check('end import') # #start from here if __name__ == '__main__': from wyconfig import * #my plot settings da = ds[daname].assign_attrs(units='m/s') fig, ax = plt.subplots() da.sel(yt_ocean=35, method='nearest').sel(xt_ocean=slice(-80,-60)).plot(ax=ax, cmap='RdBu_r', levels=21, robust=True, yincrease=False, extend='both') ax.set_facecolor('0.3') ax.text(.98, .98, 'Gulf Stream', transform=ax.transAxes, ha='right', va='top') #savefig if len(sys.argv) > 1 and sys.argv[1] == 'savefig': figtype = 'png' figname = __file__.replace('.py', f'.{figtype}') #archive existing fig if os.path.exists(figname): mdate = tt.getmdate(figname) figname_archive = figname.replace(f'.{figtype}', f'.{figtype}.{mdate}') os.rename(figname, figname_archive) print('[renamed]:', figname, '->', figname_archive) plt.savefig(figname) print('[saved]:', figname) tt.check(f'**Done**') plt.show()