import sys sys.path.append('/home/jwalker/dynamics/python/atmos-tools') sys.path.append('/home/jwalker/dynamics/python/atmos-read') import os import numpy as np import matplotlib.pyplot as plt import merra import atmos as atm from merra import read_daily year = 1979 month = 7 lon1, lon2 = 60, 100 lat1, lat2 = -60, 60 days=None subset_dict = {'lat' : (lat1, lat2), 'lon' : (lon1, lon2)} u = read_daily('u', year, month, days, subset_dict=subset_dict) days=5 u2 = read_daily('u', year, month, days, subset_dict=subset_dict) days = np.arange(10,13) u3 = read_daily('u', year, month, days, subset_dict=subset_dict) # Multiple variables days = [10, 11] ds = read_daily(['u', 'v', 'T'], year, month, days, subset_dict=subset_dict)
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)