Changeset 274f9ef in flex_extract.git for source/python/classes/GribTools.py
- Timestamp:
- Oct 22, 2018, 11:44:47 AM (6 years ago)
- Branches:
- master, ctbto, dev
- Children:
- db27c09
- Parents:
- 708c667
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
source/python/classes/GribTools.py
r0934db1 r274f9ef 66 66 # -------------------------------------------------------------------------- 67 67 def __init__(self, filenames): 68 ''' 69 @Description: 70 Initialise an object of GribTools and assign a list 71 of filenames. 72 73 @Input: 74 filenames: list of strings 75 A list of filenames. 76 77 @Return: 78 <nothing> 68 '''Initialise an object of GribTools and assign a list of filenames. 69 70 Parameters 71 ---------- 72 filenames : :obj:`list` of :obj:`strings` 73 A list of filenames. 74 75 Return 76 ------ 77 79 78 ''' 80 79 … … 85 84 86 85 def get_keys(self, keynames, wherekeynames=[], wherekeyvalues=[]): 87 ''' 88 @Description:89 get keyvalues for a given list of keynames 90 a where statement can be given (list of key and list of values)91 92 @Input:93 keynames: list of strings94 List of keynames. 95 96 wherekeynames: list of strings, optional97 Default value is an empty list. 98 99 wherekeyvalues: list of strings, optional100 Default value is an empty list. 101 102 @Return:103 return_list: list of strings104 86 '''Get keyvalues for a given list of keynames a where statement 87 can be given (list of key and list of values) 88 89 Parameters 90 ---------- 91 keynames : :obj:`list` of :obj:`string` 92 List of keynames. 93 94 wherekeynames : :obj:`list` of :obj:`string`, optional 95 Default value is an empty list. 96 97 wherekeyvalues : :obj:`list` of :obj:`string`, optional 98 Default value is an empty list. 99 100 Return 101 ------ 102 return_list : :obj:`list` of :obj:`string` 103 List of keyvalues for given keynames. 105 104 ''' 106 105 … … 144 143 def set_keys(self, fromfile, keynames, keyvalues, wherekeynames=[], 145 144 wherekeyvalues=[], strict=False, filemode='w'): 146 ''' 147 @Description: 148 Opens the file to read the grib messages and then write 149 them to a new output file. By default all messages are 150 written out. Also, the keyvalues of the passed list of 151 keynames are set or only those meeting the where statement. 152 (list of key and list of values). 153 154 @Input: 155 fromfile: string 156 Filename of the input file to read the grib messages from. 157 158 keynames: list of strings 159 List of keynames. Default is an empty list. 160 161 keyvalues: list of strings 162 List of keynames. Default is an empty list. 163 164 wherekeynames: list of strings, optional 165 Default value is an empty list. 166 167 wherekeyvalues: list of strings, optional 168 Default value is an empty list. 169 170 strict: boolean, optional 171 Decides if everything from keynames and keyvalues 172 is written out the grib file (False) or only those 173 meeting the where statement (True). Default is False. 174 175 filemode: string, optional 176 Sets the mode for the output file. Default is "w". 177 178 @Return: 179 <nothing> 145 '''Opens the file to read the grib messages and then write 146 them to a new output file. By default all messages are 147 written out. Also, the keyvalues of the passed list of 148 keynames are set or only those meeting the where statement. 149 (list of key and list of values). 150 151 Parameters 152 ---------- 153 fromfile : :obj:`string` 154 Filename of the input file to read the grib messages from. 155 156 keynames : :obj:`list` of :obj:`string` 157 List of keynames. Default is an empty list. 158 159 keyvalues : :obj:`list` of :obj:`string` 160 List of keynames. Default is an empty list. 161 162 wherekeynames : :obj:`list` of :obj:`string`, optional 163 Default value is an empty list. 164 165 wherekeyvalues : :obj:`list` of :obj:`string`, optional 166 Default value is an empty list. 167 168 strict : :obj:`boolean`, optional 169 Decides if everything from keynames and keyvalues 170 is written out the grib file (False) or only those 171 meeting the where statement (True). Default is False. 172 173 filemode : :obj:`string`, optional 174 Sets the mode for the output file. Default is "w". 175 176 Return 177 ------ 180 178 181 179 ''' … … 219 217 def copy(self, filename_in, selectWhere=True, 220 218 keynames=[], keyvalues=[], filemode='w'): 221 ''' 222 Add the content of another input grib file to the objects file but 219 '''Add the content of another input grib file to the objects file but 223 220 only messages corresponding to keys/values passed to the function. 224 221 The selectWhere switch decides if to copy the keys equal to (True) or 225 222 different to (False) the keynames/keyvalues list passed to the function. 226 223 227 @Input: 228 filename_in: string 229 Filename of the input file to read the grib messages from. 230 231 selectWhere: boolean, optional 232 Decides if to copy the keynames and values equal to (True) or 233 different to (False) the keynames/keyvalues list passed to the 234 function. Default is True. 235 236 keynames: list of strings, optional 237 List of keynames. Default is an empty list. 238 239 keyvalues: list of strings, optional 240 List of keynames. Default is an empty list. 241 242 filemode: string, optional 243 Sets the mode for the output file. Default is "w". 244 245 @Return: 246 <nothing> 224 Parameters 225 ---------- 226 filename_in : :obj:`string` 227 Filename of the input file to read the grib messages from. 228 229 selectWhere : :obj:`boolean`, optional 230 Decides if to copy the keynames and values equal to (True) or 231 different to (False) the keynames/keyvalues list passed to the 232 function. Default is True. 233 234 keynames : :obj:`list` of :obj:`string`, optional 235 List of keynames. Default is an empty list. 236 237 keyvalues : :obj:`list` of :obj:`string`, optional 238 List of keynames. Default is an empty list. 239 240 filemode : :obj:`string`, optional 241 Sets the mode for the output file. Default is "w". 242 243 Return 244 ------ 245 247 246 ''' 248 247 … … 284 283 285 284 def index(self, index_keys=["mars"], index_file="my.idx"): 286 ''' 287 @Description:288 Create index file from a list of files if it does not exist or 289 read an index file.290 291 @Input:292 index_keys: list of strings, optional293 Contains the list of key parameter names from294 which the index is to be created.295 Default is a list with a single entry string "mars". 296 297 index_file: string, optional298 Filename where the indices are stored.299 Default is "my.idx". 300 301 @Return:302 iid: integer303 285 '''Create index file from a list of files if it does not exist or 286 read an index file. 287 288 Parameters 289 ---------- 290 index_keys: :obj:`list` of :obj:`string`, optional 291 Contains the list of key parameter names from 292 which the index is to be created. 293 Default is a list with a single entry string "mars". 294 295 index_file: :obj:`string`, optional 296 Filename where the indices are stored. 297 Default is "my.idx". 298 299 Return 300 ------ 301 iid: :obj:`integer` 302 Grib index id. 304 303 ''' 305 304 print("... index will be done")
Note: See TracChangeset
for help on using the changeset viewer.