def read_ECMWF(date): """ Script reading the ECMWF data. Not a generator as this is synchronized with the 1h part slice. The data are assumed valid over the 1h period that follows the timestamp. This is quite OK for UDR as this quantity is defined as a mean/accumuation over this one-hour period. Cloud-cover is from analysis, therefore as an instantaneous map, but varies less rapidly than the UDR. """ dat = ECMWF('STC',date) dat._get_var('T') dat.attr['dlo'] = (dat.attr['lons'][-1] - dat.attr['lons'][0]) / (dat.nlon-1) dat.attr['dla'] = (dat.attr['lats'][-1] - dat.attr['lats'][0]) / (dat.nlat-1) if dat.attr['Lo1']>dat.attr['Lo2']: dat.attr['Lo1'] = dat.attr['Lo1']-360. #@@ test # print('LoLa ',dat.attr['Lo1'],dat.attr['La1'],dat.attr['dlo'],dat.attr['dla'],\ # dat.attr['levs'][0],len(dat.attr['levs'])) #@@ end test dat._get_var('UDR') #dat._get_var('CC') dat._mkp() dat._mkrho() dat.var['UDR'] /= dat.var['RHO'] dat.close() return dat
def Pinterpol(date): """ Read the ERA5 data and interpolate to the pressure levels. """ dat = ECMWF('FULL-EA', date, exp=['VOZ', 'QN']) dat._get_T() dat._get_var('O3') dat._get_var('Q') dat.close() dat._mkp() dat._mkz() dat2 = dat.shift2west(-20) dat3 = dat2.extract(lonRange=[-10, 160], latRange=[0, 50], varss='All') dat3._WMO() dat4 = dat3.interpolP(pressPa, varList=['Z', 'T', 'Q', 'O3']) dat4.d2d = dat3.d2d return (dat4)
i = 0 else: # Continuation with gzip.open('ERA5-extract-PT5.pkl', 'rb') as f: dats = pickle.load(f) i = len(dats) print('dats length ', len(dats)) date = day1 pts = list(np.arange(420, 610, 5)) varList = ['T', 'VO', 'O3', 'PV', 'Z', 'U', 'V'] while date < day2: print(date) dat = ECMWF('FULL-EA', date, exp='VOZ') dat._get_var('T') dat._get_var('VO') dat._get_var('O3') dat._get_var('U') dat._get_var('V') dat._mkp() dat._mkz() dat._mkthet() dat._mkpv() if date >= datetime(2017, 10, 12, 0): dats[i] = dat.interpolPT(pts, varList=varList, latRange=(5, 35), lonRange=(100, 220)) elif date >= datetime(2017, 10, 3, 0): datr = dat.shift2west(-180)
part0['x'] = np.empty(0, dtype=float) part0['y'] = np.empty(0, dtype=float) part0['t'] = np.empty(0, dtype=float) part0['p'] = np.empty(0, dtype=float) part0['idx_back'] = np.empty(0, dtype=int) # It is assumed that both date_end and date_beg are valid dates for the EN files date_f = date_end date_p = date_f - ENint date_current = date_end # first read and first interpolation #data = read_ECMWF(ENdir,date_f) # data is read from ERA5 data in the global domain at 1° horizontal resolution # and longitude origin at 0° data = ECMWF('FULL-EA', date_f) data._get_var('T') data._mkp( ) # Calculate pressure from surface pressure and hybrid coefficients data._mkthet() # Calculate the potential temperature # ACHTUNG: TO DO : ADD HERE A SHIFT IN LONGITUDE # data -> data.shit2west(-179) if not quiet: print('load first EN file ', date_f) T_p, P_p = interp3d_thet( data, theta_level) # First interpolation to the theta level delta_pf = ENint.total_seconds() numpart = 0 # loop on the EN time while date_p >= date_beg: T_f = T_p.copy()
from datetime import datetime #import pickle,gzip #import matplotlib.pyplot as plt from os.path import join from ECMWF_N import ECMWF date = datetime(2017, 8, 23, 3) dat = ECMWF('FULL-EA', date, exp='VOZ') #date = datetime(2020,1,23,6) #dat = ECMWF('OPZ',date) #date = datetime(2017,8,10,0) #dat = ECMWF('STC',date) #%% dat._get_T() dat._get_var('VO') dat._get_U() dat._get_V() dat._mkp() dat._mkthet() #%% print('now call mkpv') dat._mkpv() #%% #dats = dat.interpolPT([350,370,395,430],varList=['PV'],lonRange=(50,120),latRange=(0,50)) dats = dat.extract(varss='All', lonRange=(240, 330), latRange=(-80, -30))