def read_ERA5(t0, dtRange, pre=False, vshift=0):
    """ Generator reading the ERA5 data.
    The loop is infinite; ERA5 data are called when required until the end of
    the parcel loop.
    The output contain a function that gives the pressure of the tropo^pause as
    a function of lon and lat in the FullAMA domain"""
    # initial time for internal loop
    current_time = t0
    while True:
        try:
            if (current_time in blacklist): raise BlacklistError()
            # defining a new object is necessary to avoid messing dat if an error occurs
            dat = ECMWF('FULL-EA', current_time)
            dat._get_T()
            dat._mkp()
            dats = dat.shift2west(-179)
            # extraction in a domain that encompasses FullAMA
            datr0 = dats.extract(latRange=[-5, 55],
                                 lonRange=[-15, 165],
                                 varss=['P', 'T'])
            del dat, dats
            datr0._WMO()
            datr0.fP = RegularGridInterpolator(
                (np.arange(-5, 56), np.arange(-15, 166)),
                datr0.d2d['pwmo'],
                bounds_error=True)
            print('get ERA5 tropopause for ', current_time)
            try:
                del datr
            except:
                pass  # intended for the first pass when datr undefined
            datr = datr0  # datr as a view of datr0
            # We reproduce here the same sequence as for the satellite file
            # although perhapsnot appropriate (the ERA5 data are instantaneous)
            if pre:
                datr.tf = current_time + dtRange
                datr.ti = current_time
            else:
                datr.tf = current_time
                datr.ti = current_time - dtRange
        except BlacklistError:
            print('blacklisted date for GridSat', current_time)
            # extend the lease while keeping the old dat
            datr.ti -= dtRange
        except FileNotFoundError:
            print('ERA5 file not found ', current_time)
            # extend the lease while keeping the old dat
            datr.ti -= dtRange
        current_time -= dtRange

        yield datr
Пример #2
0
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)
Пример #3
0
 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)
     dats[i] = datr.interpolPT(pts,
                               varList=varList,
                               latRange=(20, 50),
                               lonRange=(-180, -60))
 elif date >= datetime(2017, 9, 23, 0):
     datr = dat.shift2west(-180)
     dats[i] = datr.interpolPT(pts,
                               varList=varList,
                               latRange=(20, 50),
                               lonRange=(-120, 0))
 elif date >= datetime(2017, 9, 11, 0):
     datr = dat.shift2west(-180)
     dats[i] = datr.interpolPT(pts,
                               varList=varList,
                               latRange=(20, 50),
Пример #4
0
if args.day1 is not None: day1 = args.day1
if args.day2 is not None: day2 = args.day2
if args.hour1 is not None: hour1 = args.hour1
if args.hour2 is not None: hour2 = args.hour2

date = datetime(year, month1, day1, hour1)

while date < datetime(year, month2, day2, hour2):
    print('processing ', date)
    outfile = date.strftime('TPP%y%m%d%H.hdf5')
    fullname = os.path.join(maindir, date.strftime('%Y/%m'), outfile)
    fdd = ECMWF('FULL-EA', date)
    fdd._get_T()
    fdd._mkp()
    fdd.close()
    fde = fdd.shift2west(-20)
    fdf = fde.extract(lonRange=[-10, 160], latRange=[0, 50], varss='All')
    fdf._CPT()
    fdf._WMO()
    tpp = {}
    tpp['Twmo'] = fdf.d2d['Twmo']
    tpp['pwmo'] = fdf.d2d['pwmo']
    tpp['Tcold'] = fdf.d2d['Tcold']
    tpp['pcold'] = fdf.d2d['pcold']
    tpp['nlon'] = fdf.nlon
    tpp['nlat'] = fdf.nlat
    tpp['lats'] = fdf.attr['lats']
    tpp['lons'] = fdf.attr['lons']
    tpp['date'] = fdd.date
    fl.save(fullname, tpp, compression='zlib')
    date += timedelta(hours=3)