#!/usr/bin/env python # Wenchang Yang (wenchang@princeton.edu) # Wed Jun 30 23:25:10 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 # if __name__ == '__main__': tt.check('end import') # #start from here ifiles = ['data_tmax_AM2.5C360_amip_5ens_1871-1920.nc', 'data_tmax_AM2.5C360_amip_5ens_1921-1970.nc', 'data_tmax_AM2.5C360_amip_5ens_1971-2019.nc' ] #ofile = 'data_tmax_AM2.5C360_amip_5ens_1871-2019.nc' ofile = __file__.replace('.py', '.nc').replace('get_', 'data_') if os.path.exists(ofile): ds = xr.open_dataset(ofile) print('[loaded]:', ofile) else: print('loading...') ds = xr.open_mfdataset(ifiles).load() print('saving...') ds.to_netcdf(ofile) print('[saved]:', ofile) if __name__ == '__main__': #from wyconfig import * #my plot settings #savefig if 'savefig' in sys.argv: figname = __file__.replace('.py', f'.png') wysavefig(figname) tt.check(f'**Done**') plt.show()