#!/usr/bin/env python # Wenchang Yang (wenchang@princeton.edu) # Mon Mar 2 17:15:22 EST 2020 if __name__ == '__main__': from misc.timer import Timer tt = Timer(f'start {__file__}') import sys, os.path, os, datetime import xarray as xr, numpy as np, pandas as pd #import matplotlib.pyplot as plt #print() if __name__ == '__main__': tt.check('end import') model = 'HIRAM' expname = 'CTL1990s_v201910_plus2K_tigercpu_intelmpi_18_540PE' data_name = 'VI' years = range(101, 151) ofile = f'data.{data_name}.nc' ifiles = [f'/tigress/wenchang/MODEL_OUT/{model}/{expname}/analysis_wy/TCI/{year:04d}0101.atmos_month.VI.nc' for year in years] if __name__ == '__main__': ds = xr.open_mfdataset(ifiles, concat_dim='time', combine='by_coords') ds = ds.rename({'grid_xt': 'lon', 'grid_yt': 'lat'}) ds.attrs['model'] = model ds.attrs['expname'] = expname encoding = {data_name: {'dtype': 'float32', 'zlib': True, 'complevel': 1}} ds.load().to_netcdf(ofile, encoding=encoding) print('[saved]:', ofile) tt.check('**Done**') print()