Changeset a676cf7 in flex_extract.git for Source/Python/Mods/checks.py


Ignore:
Timestamp:
Oct 30, 2022, 1:13:24 AM (18 months ago)
Author:
Anne Tipka <anne.tipka@…>
Branches:
dev
Children:
7271b6f
Parents:
ea754d1
Message:

modifications and adjustments to dates and times for correctly retrieving analysis and forecast data in operational mode

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Source/Python/Mods/checks.py

    r5606fc9 ra676cf7  
    9393        else:
    9494            raise ValueError('GRID parameter contains two '
    95                              'different values: %s' (grid))
     95                             'different values: %s', grid)
    9696    # # determine grid format
    9797    # if float(grid) / 100. >= 0.5:
     
    236236    return levelist, level
    237237
    238 
    239238def check_ppid(c, ppid):
    240239    '''Sets the current PPID.
     
    262261    return
    263262
    264 
    265263def check_purefc(ftype):
    266264    '''Check for a pure forecast mode.
     
    283281
    284282    return 0
    285 
    286283
    287284def check_step(step):
     
    404401        Valid values are hours (HH) from forecast base time.
    405402    '''
    406     if not len(ftype) == len(ftime) == len(steps):
    407         raise ValueError('ERROR: The number of field types, times and steps '
    408                          'are not the same! Please check the settings in the '
    409                          'CONTROL file!')
    410 
    411403    # if pure forecast is selected and only one field type/time is set
    412404    # prepare a complete list of type/time/step combination upto maxstep
    413     if len(ftype) == 1 and purefc:
     405    if len(ftime) == 1 and purefc:
    414406        nftype = []
    415407        nsteps = []
     
    421413        return nftype, nftime, nsteps
    422414
     415    if not len(ftype) == len(ftime) == len(steps):
     416        raise ValueError('ERROR: The number of field types, times and steps '
     417                         'are not the same! Please check the settings in the '
     418                         'CONTROL file!')
    423419    return ftype, ftime, steps
    424420
     
    605601    return maxstep
    606602
    607 def check_basetime(basetime):
     603def check_basetime(basetime, time, purefc):
    608604    '''Check if basetime is set and contains one of the two
    609605    possible values (0, 12).
     
    615611        retrieved.
    616612
     613    time : str
     614        The time in hours of the field.
     615
     616    purefc : int
     617        1 if pure forecasts are to be retrieved. 0 if there are
     618        analysis fields in between.
     619
    617620    Return
    618621    ------
     
    620623        The time for a half day retrieval. The 12 hours upfront are to be
    621624        retrieved.
     625
     626    time : str or list of str
     627        The time in hours of the field.
    622628    '''
    623629    if basetime is not None:
     
    626632            raise ValueError('ERROR: Basetime has an invalid value '
    627633                             '-> {}'.format(str(basetime)))
    628     return basetime
     634        if purefc:
     635            time = str(basetime)
     636    return basetime, time
    629637
    630638def check_request(request, marsfile):
     
    707715    return acctype
    708716
    709 
    710 def check_acctime(acctime, marsclass, purefc, time):
     717def check_acctime(acctime, marsclass, purefc, time, basetime, oper):
    711718    '''Guarantees that the accumulation forecast times were set.
    712719
     
    725732        Switch for definition of pure forecast mode or not.
    726733
     734    basetime : int
     735        The time for a half day retrieval. The 12 hours upfront are to be
     736        retrieved.
     737
     738    oper : int
     739        Switch to prepare the operational job script. Start date, end date and
     740        basetime will be prepared with environment variables.
     741
    727742    Return
    728743    ------
     
    730745        The starting time for the accumulated forecasts.
    731746    '''
     747
     748    if acctime and basetime and oper:
     749        return basetime
    732750
    733751    if not acctime:
     
    817835        if '/' in addpar:
    818836            parlist = addpar.split('/')
    819             parlist = [p for p in parlist if p is not '']
     837            parlist = [p for p in parlist if p != '']
    820838        else:
    821839            parlist = [addpar]
     
    824842
    825843    return addpar
    826 
    827844
    828845def check_job_chunk(job_chunk):
     
    853870
    854871    return job_chunk
    855 
    856872
    857873def check_number(number):
Note: See TracChangeset for help on using the changeset viewer.
hosted by ZAMG