#!/usr/bin/env python # Wenchang Yang (wenchang@princeton.edu) # Thu Mar 25 23:36:42 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 import seaborn as sns # if __name__ == '__main__': tt.check('end import') # #start from here ifile = '/tigress/wenchang/analysis/TC/HIRAM/CTL1990s_v201910_tigercpu_intelmpi_18_540PE/netcdf/tc_counts.TS17.0101-0300.yearly.nc' ds = xr.open_dataset(ifile) if __name__ == '__main__': from wyconfig import * #my plot settings fig, ax = plt.subplots() sns.violinplot(ax=ax, data=ds, y='global') #sns.boxplot(ax=ax, data=ds, y='global', zorder=10, width=0.5) ax.set_ylabel('global TC # per year') ax.set_xlabel('HiRAM CTL1990s_v201910_tigercpu_intelmpi_18_540PE') #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()