Changeset 3f36e42 in flex_extract.git for source/python/mods/checks.py
- Timestamp:
- Dec 4, 2018, 9:46:22 PM (5 years ago)
- Branches:
- master, ctbto, dev
- Children:
- fdda1b9
- Parents:
- 97f4f4c
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
source/python/mods/checks.py
r97f4f4c r3f36e42 26 26 # ------------------------------------------------------------------------------ 27 27 28 28 import _config 29 29 # ------------------------------------------------------------------------------ 30 30 # FUNCTIONS … … 32 32 33 33 34 def check_grid_area(grid, area, upper, lower, left , right): 35 ''' 34 def check_grid(grid): 36 35 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 49 38 if '/' in grid: 50 39 gridx, gridy = grid.split('/') … … 62 51 # grid is defined in normal degree; new format 63 52 grid = '{}/{}'.format(float(grid), float(grid)) 53 54 return grid 55 56 def 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 64 69 65 70 # determine area format … … 86 91 'formats: %s ' (area)) 87 92 88 return grid, area 93 return area 94 95 def 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 130 def 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 156 def 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.