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


Ignore:
Timestamp:
Dec 19, 2019, 8:07:12 PM (4 years ago)
Author:
Anne Philipp <anne.philipp@…>
Branches:
master, ctbto, dev
Children:
a73c0f6
Parents:
0d99607
Message:

diverse changes due to PEP8 style guide and eliminating grib2flexpart; removed unused parameter

File:
1 edited

Legend:

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

    r44174de r0f89116  
    2929import os
    3030import sys
    31 
    32 import _config
     31from datetime import datetime
     32# pylint: disable=unused-import
    3333try:
    3434    import exceptions
    3535except ImportError:
    3636    import builtins as exceptions
    37 from datetime import datetime
     37# pylint: enable=unused-import
     38
     39# software specific classes and modules from flex_extract
     40import _config
    3841from Mods.tools import my_error, silent_remove
    3942# ------------------------------------------------------------------------------
     
    113116    return grid
    114117
    115 def check_area(grid, area, upper, lower, left , right):
     118def check_area(grid, area, upper, lower, left, right):
    116119    '''Defines the correct area string.
    117120
     
    158161
    159162    # determine area format
    160     if ((abs(float(upper) / 10000.) >= 0.01 or float(upper) / 1000. == 0. ) and
    161         (abs(float(lower) / 10000.) >= 0.01 or float(lower) / 1000. == 0. ) and
    162         (abs(float(left) / 10000.) >= 0.01 or float(left) / 1000. == 0. ) and
    163         (abs(float(right) / 10000.) >= 0.01 or float(right) / 1000. == 0.)):
     163    if all([(abs(float(upper) / 10000.) >= 0.01 or float(upper) / 1000. == 0.),
     164            (abs(float(lower) / 10000.) >= 0.01 or float(lower) / 1000. == 0.),
     165            (abs(float(left) / 10000.) >= 0.01 or float(left) / 1000. == 0.),
     166            (abs(float(right) / 10000.) >= 0.01 or float(right) / 1000. == 0.)]):
    164167        # area is defined in 1/1000 degrees; old format
    165168        area = '{}/{}/{}/{}'.format(float(upper) / 1000.,
     
    167170                                    float(lower) / 1000.,
    168171                                    float(right) / 1000.)
    169     elif (abs(float(upper) / 10000.) < 0.05 and
    170           abs(float(lower) / 10000.) < 0.05 and
    171           abs(float(left) / 10000.) < 0.05 and
    172           abs(float(right) / 10000.) < 0.05):
     172    elif all([abs(float(upper) / 10000.) < 0.05,
     173              abs(float(lower) / 10000.) < 0.05,
     174              abs(float(left) / 10000.) < 0.05,
     175              abs(float(right) / 10000.) < 0.05]):
    173176        # area is already in new format
    174177        area = '{}/{}/{}/{}'.format(float(upper),
     
    180183                         'formats (upper, lower, left, right): '
    181184                         '{}/{}/{}/{}'.format(str(upper), str(lower),
    182                                               str(left) , str(right)))
     185                                              str(left), str(right)))
    183186
    184187    return area
     
    281284
    282285
    283 def check_step(step, mailfail):
     286def check_step(step):
    284287    '''Checks on step format and convert into a list of steps.
    285288
     
    293296        Specifies the forecast time step from forecast base time.
    294297        Valid values are hours (HH) from forecast base time.
    295 
    296     mailfail : list of str
    297         Contains all email addresses which should be notified.
    298         It might also contain just the ecmwf user name which will trigger
    299         mailing to the associated email address for this user.
    300298
    301299    Return
     
    405403        Valid values are hours (HH) from forecast base time.
    406404    '''
    407     if not (len(ftype) == len(ftime) == len(steps)):
     405    if not len(ftype) == len(ftime) == len(steps):
    408406        raise ValueError('ERROR: The number of field types, times and steps '
    409407                         'are not the same! Please check the setting in the '
     
    553551                         'in CONTROL file.\n'
    554552                         'Try "{} -h" to print usage information'
    555                          .format(sys.argv[0].split('/')[-1]) )
     553                         .format(sys.argv[0].split('/')[-1]))
    556554
    557555    # retrieve just one day if end_date isn't set
     
    790788            accmaxstep = maxstep
    791789            print('... For pure forecast mode, the accumulated forecast must '
    792                           'have the same maxstep as the normal forecast fields!\n'
    793                           '\t\t Accmaxstep was set to maxstep!')
     790                  'have the same maxstep as the normal forecast fields!\n'
     791                  '\t\t Accmaxstep was set to maxstep!')
    794792    return accmaxstep
    795793
     
    851849
    852850
    853 def check_number(number, mailfail):
     851def check_number(number):
    854852    '''Check for correct string format of ensemble member numbers.
    855853
     
    858856    number : str
    859857        List of ensemble member forecast runs.
    860 
    861     mailfail : list of str
    862         Contains all email addresses which should be notified.
    863         It might also contain just the ecmwf user name which will trigger
    864         mailing to the associated email address for this user.
    865858
    866859    Return
Note: See TracChangeset for help on using the changeset viewer.
hosted by ZAMG