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


Ignore:
Timestamp:
Oct 8, 2018, 3:44:58 PM (2 years ago)
Author:
Anne Philipp <anne.philipp@…>
Branches:
master, dev, feature/makefiles, origin/task/language-editing, sysinstall, task/language-editing
Children:
0aaeb04
Parents:
ae88f7d
Message:

implemented extraction possibility of EA5 und CERA

File:
1 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
Note: See TracChangeset for help on using the changeset viewer.
hosted by ZAMG