lon1, lon2 = 40, 100 lat1, lat2 = -15, 35 varlist = ['T'] pmin, pmax = 200e2, 600e2 years = range(1979, 2015) months = [4, 5, 6, 7, 8, 9] g = atm.constants.g.values nperday = 8 subset_dict = {'lon' : (lon1, lon2), 'lat' : (lat1, lat2)} for year in years: for mon in months: dayvals = atm.season_days(atm.month_str(mon), atm.isleap(year)) T = merra.read_daily(varlist, year, mon, subset_dict=subset_dict) # Daily means of 3-hourly data T = atm.daily_from_subdaily(T, nperday, dayvals=dayvals) # Vertical integral Tbar = atm.int_pres(T, pmin=pmin, pmax=pmax) Tbar = Tbar * g / (pmax - pmin) Tbar.name='Tbar' Tbar.attrs['long_name'] = 'Vertical mean atmospheric temperature' Tbar.attrs['pmin'] = pmin Tbar.attrs['pmax'] = pmax # Save to file atm.save_nc(savefile(year, mon, pmin, pmax), T, Tbar)
lat1, lat2 = -20, 30 varlist = ['u', 'v', 'q'] pmin = 300e2 years = range(1979, 2015) #months = [5, 6, 7, 8] months = [4] subset_dict = {'lon' : (lon1, lon2), 'lat' : (lat1, lat2)} for year in years: for mon in months: dayvals = atm.season_days(atm.month_str(mon), atm.isleap(year)) ds = merra.read_daily(varlist, year, mon, subset_dict=subset_dict) uq = ds['U'] * ds['QV'] vq = ds['V'] * ds['QV'] # Daily means of 3-hourly data nperday = 8 uq = atm.daily_from_subdaily(uq, nperday, dayvals=dayvals) vq = atm.daily_from_subdaily(vq, nperday, dayvals=dayvals) # Vertical integral uq_int = atm.int_pres(uq, pmin=pmin) vq_int = atm.int_pres(vq, pmin=pmin) uq_int.name='uq_int' uq_int.attrs['pmin'] = pmin vq_int.name='vq_int' vq_int.attrs['pmin'] = pmin # Save to file atm.save_nc(savefile(year, mon), uq_int, vq_int)