Changeset 3f36e42 in flex_extract.git for source/python/mods/checks.py


Ignore:
Timestamp:
Dec 4, 2018, 9:46:22 PM (5 years ago)
Author:
Anne Philipp <anne.philipp@…>
Branches:
master, ctbto, dev
Children:
fdda1b9
Parents:
97f4f4c
Message:

outsourced some checks from CONTROL class to checks module; translated namelist generation by genshi templating; corrected a bug in grib2 conversion

File:
1 edited

Legend:

Unmodified
Added
Removed
  • source/python/mods/checks.py

    r97f4f4c r3f36e42  
    2626# ------------------------------------------------------------------------------
    2727
    28 
     28import _config
    2929# ------------------------------------------------------------------------------
    3030# FUNCTIONS
     
    3232
    3333
    34 def check_grid_area(grid, area, upper, lower, left , right):
    35     '''
     34def check_grid(grid):
    3635
    37 
    38     '''
    39     # if area was provided
    40     # decompose area into its 4 components
    41     if area:
    42         components = area.split('/')
    43         upper, left, lower, right = components
    44 
    45     if 'N' in grid:  # Gaussian output grid
    46         area = 'G'
    47         return grid, area
    48 
     36    if 'N' in grid:
     37        return grid
    4938    if '/' in grid:
    5039        gridx, gridy = grid.split('/')
     
    6251        # grid is defined in normal degree; new format
    6352        grid = '{}/{}'.format(float(grid), float(grid))
     53
     54    return grid
     55
     56def check_area(grid, area, upper, lower, left , right):
     57    '''
     58
     59
     60    '''
     61    if 'N' in grid:  # Gaussian output grid
     62        area = 'G'
     63        return area
     64
     65    # if area was provided decompose area into its 4 components
     66    if area:
     67        components = area.split('/')
     68        upper, left, lower, right = components
    6469
    6570    # determine area format
     
    8691                         'formats: %s ' (area))
    8792
    88     return grid, area
     93    return area
     94
     95def check_levels(levelist, level):
     96    '''
     97
     98    Parameters
     99    ----------
     100    par : :obj:``
     101        ...
     102
     103    Return
     104    ------
     105
     106    '''
     107    # assure consistency of levelist and level
     108    if not levelist and not level:
     109        raise ValueError('ERROR: neither levelist nor level '
     110                         'specified in CONTROL file')
     111    elif not levelist and level:
     112        levelist = '1/to/' + level
     113    elif (levelist and not level) or \
     114         (levelist[-1] != level[-1]):
     115        level = levelist.split('/')[-1]
     116    else:
     117        pass
     118
     119    # check if max level is a valid level
     120    if int(level) not in _config.MAX_LEVEL_LIST:
     121        raise ValueError('ERROR: \n'
     122                         'LEVEL must be the maximum level of a specified '
     123                         'level list from ECMWF, e.g. {} \n'
     124                         'Check parameter "LEVEL" or the max level of '
     125                         '"LEVELIST"!'.format(str(_config.MAX_LEVEL_LIST)))
     126
     127    return levelist, level
     128
     129
     130def check_ppid(c, ppid):
     131    '''Sets the current PPID.
     132
     133    Parameters
     134    ----------
     135    c : :obj:`ControlFile`
     136            Contains all the parameters of CONTROL file and
     137            command line.
     138
     139    ppid : :obj:`int` or :obj:`None`
     140        Contains the ppid number provided by the command line parameter
     141        of is None otherwise.
     142
     143    Return
     144    ------
     145
     146    '''
     147
     148    if not ppid:
     149        c.ppid = str(os.getppid())
     150    else:
     151        c.ppid = ppid
     152
     153    return
     154
     155
     156def check_():
     157    '''
     158
     159    Parameters
     160    ----------
     161    par : :obj:``
     162        ...
     163
     164    Return
     165    ------
     166
     167    '''
     168    return
Note: See TracChangeset for help on using the changeset viewer.
hosted by ZAMG