Changeset 0e576fc in flex_extract.git for source/python/classes


Ignore:
Timestamp:
Oct 8, 2018, 3:44:58 PM (5 years ago)
Author:
Anne Philipp <anne.philipp@…>
Branches:
master, ctbto, dev
Children:
0aaeb04
Parents:
ae88f7d
Message:

implemented extraction possibility of EA5 und CERA

Location:
source/python/classes
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • source/python/classes/ControlFile.py

    r5bad6ec r0e576fc  
    113113        self.time = None
    114114        self.step = None
     115        self.acctype = None
     116        self.acctime = None
     117        self.accmaxstep = None
    115118        self.marsclass = None
    116119        self.dataset = None
     
    118121        self.number = 'OFF'
    119122        self.expver = '1'
     123        self.gaussian = ''
    120124        self.grid = None
    121125        self.area = ''
     
    346350        # check for having at least a starting date
    347351        # otherwise program is not allowed to run
    348         if self.start_date is None:
     352        if not self.start_date:
    349353            print('start_date specified neither in command line nor \
    350354                   in CONTROL file ' +  self.controlfile)
     
    354358
    355359        # retrieve just one day if end_date isn't set
    356         if self.end_date is None:
     360        if not self.end_date:
    357361            self.end_date = self.start_date
    358362
     
    365369
    366370        # assure consistency of levelist and level
    367         if self.levelist is None and self.level is None:
     371        # up-to-date available maximum level numbers at ECMWF, 05.10.2018
     372        max_level_list = [16, 19, 31, 40, 50, 60, 62, 91, 137]
     373        if not self.levelist and not self.level:
    368374            print('Warning: neither levelist nor level \
    369375                               specified in CONTROL file')
    370376            sys.exit(1)
    371         elif self.levelist is None and self.level:
     377        elif not self.levelist and self.level:
    372378            self.levelist = '1/to/' + self.level
    373         elif (self.levelist and self.level is None) or \
     379        elif (self.levelist and not self.level) or \
    374380             (self.levelist[-1] != self.level[-1]):
    375381            self.level = self.levelist.split('/')[-1]
    376382        else:
    377383            pass
     384
     385        # check if max level is a valid level
     386        if int(self.level) not in max_level_list:
     387            print('ERROR: ')
     388            print('LEVEL must be the maximum level of a specified '
     389                  'level list from ECMWF, e.g.')
     390            print('[16, 19, 31, 40, 50, 60, 62, 91 or 137]')
     391            print('Check parameter "LEVEL" or the max level of "LEVELIST"!')
     392            sys.exit(1)
    378393
    379394        # if area was provided (only from commandline)
     
    404419        # if maxstep wasn't provided
    405420        # search for it in the "step" parameter
    406         if self.maxstep is None:
     421        if not self.maxstep:
    407422            self.maxstep = 0
    408423            for s in self.step:
     
    461476                  'the "dataset"-parameter has to be set in the control file!')
    462477            sys.exit(1)
     478
     479        if not isinstance(self.type, list):
     480            self.type = [self.type]
     481
     482        for i, val in enumerate(self.type):
     483            if self.type[i] == 'AN' and int(self.step[i]) != 0:
     484                print('Analysis retrievals must have STEP = 0 (is set to 0)')
     485                self.type[i] = 0
     486
     487        if not isinstance(self.time, list):
     488            self.time = [self.time]
     489
     490        if not isinstance(self.step, list):
     491            self.step = [self.step]
     492
     493        if not self.acctype:
     494            print('... Control paramter ACCTYPE was not defined.')
     495            try:
     496                if len(self.type) > 1 and self.type[1] != 'AN':
     497                    print('Use old setting by using TYPE[1] for flux forecast!')
     498                    self.acctype = self.type[1]
     499            except:
     500                print('Use default value "FC" for flux forecast!')
     501                self.acctype='FC'
     502
     503        if not self.acctime:
     504            print('... Control paramter ACCTIME was not defined.')
     505            print('Use default value "00/12" for flux forecast!')
     506            self.acctime='00/12'
     507
     508        if not self.accmaxstep:
     509            print('... Control paramter ACCMAXSTEP was not defined.')
     510            print('Use default value "12" for flux forecast!')
     511            self.accmaxstep='12'
    463512
    464513        return
  • source/python/classes/EcFlexpart.py

    r5bad6ec r0e576fc  
    135135
    136136        if c.maxstep > len(c.type):    # Pure forecast mode
    137             c.type = [c.type[1]]
     137            c.type = [c.type[0]]
    138138            c.step = ['{:0>3}'.format(int(c.step[0]))]
    139139            c.time = [c.time[0]]
     
    155155            # the initialisation times of the flux fields
    156156            # and therefore are zero all the time)
    157             self.types[c.type[1]] = {'times': '00/12', 'steps':
    158                                      '{}/to/12/by/{}'.format(c.dtime, c.dtime)}
     157            self.types[str(c.acctype)] = {'times': str(c.acctime),
     158                                          'steps': '{}/to/{}/by/{}'.format(
     159                                              c.dtime, c.accmaxstep, c.dtime)}
    159160        else:
    160161            for ty, st, ti in zip(c.type, c.step, c.time):
     
    165166                    btlist = [13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 0]
    166167
    167                 if i % int(c.dtime) == 0 and (i in btlist or c.maxstep > 24):
     168                if ((ty.upper() == 'AN' and
     169                     int(c.time[i]) % int(c.dtime) ==0) or
     170                    (ty.upper() != 'AN' and
     171                     int(c.step[i]) % int(c.dtime) == 0 and
     172                     int(c.step[i]) % int(c.dtime) == 0) ) and \
     173                    (int(c.time[i]) in btlist or c.maxstep > 24):
    168174
    169175                    if ty not in self.types.keys():
     
    191197        # for gaussian grid retrieval
    192198        self.glevelist = '1/to/' + c.level
    193 
    194         if hasattr(c, 'gaussian') and c.gaussian:
    195             self.gaussian = c.gaussian
    196         else:
    197             self.gaussian = ''
     199        self.gaussian = c.gaussian
    198200
    199201        if 'N' in c.grid:  # Gaussian output grid
     
    239241                self.params['OG__SL'][0] += '/' + '/'.join(c.addpar)
    240242
    241             self.params['OG_OROLSM__SL'] = ["160/27/28/173", \
    242                                             'SFC', '1', self.grid]
     243            if c.marsclass.upper() == 'EA' or c.marsclass.upper() == 'EP':
     244                self.params['OG_OROLSM__SL'] = ["160/27/28/244",
     245                                                'SFC', '1', self.grid]
     246            else:
     247                self.params['OG_OROLSM__SL'] = ["160/27/28/173", \
     248                                                'SFC', '1', self.grid]
    243249
    244250            self.params['OG__ML'] = ['T/Q', 'ML', self.levelist, self.grid]
     
    543549                if pk == 'OG_OROLSM__SL' and not oro:
    544550                    oro = True
    545                     retr_param_dict['stream'] = 'OPER'
     551                    # in CERA20C (class EP) there is no stream "OPER"!
     552                    if self.marsclass.upper() != 'EP':
     553                        retr_param_dict['stream'] = 'OPER'
    546554                    retr_param_dict['type'] = 'AN'
    547555                    retr_param_dict['time'] = '00'
     
    834842                    values = (np.reshape(values, (nj, ni))).flatten() / fak
    835843                    vdp.append(values[:])  # save the accumulated values
    836                     if step <= int(c.dtime):
     844                    if c.marsclass.upper() == 'EA' or \
     845                       step <= int(c.dtime):
    837846                        svdp.append(values[:] / int(c.dtime))
    838847                    else:  # deaccumulate values
  • source/python/classes/MarsRetrieval.py

    r5bad6ec r0e576fc  
    463463        # find all keys without a value and convert all other values to strings
    464464        empty_keys = []
    465         for key, value in attrs.itteritems():
     465        for key, value in attrs.iteritems():
    466466            if value == '':
    467467                empty_keys.append(str(key))
     
    486486                print("ERROR: ", e)
    487487                print('MARS Request failed!')
    488             if not self.public and os.stat(target).st_size == 0:
    489                 print('MARS Request returned no data - please check request')
    490                 raise IOError
    491             elif self.public and os.stat(target).st_size == 0:
    492                 print('Public MARS Request returned no data - '
    493                       'please check request')
    494                 raise IOError
    495             else:
    496                 raise IOError
     488                if not self.public and os.stat(target).st_size == 0:
     489                    print('MARS Request returned no data - '
     490                          'please check request')
     491                    raise IOError
     492                elif self.public and os.stat(target).st_size == 0:
     493                    print('Public MARS Request returned no data - '
     494                          'please check request')
     495                    raise IOError
     496                else:
     497                    raise IOError
    497498        # MARS request via extra process in shell
    498499        else:
     
    515516                print('MARS Request returned no data - please check request')
    516517                raise IOError
    517             else:
    518                 raise
    519518
    520519        return
Note: See TracChangeset for help on using the changeset viewer.
hosted by ZAMG