- Timestamp:
- Oct 22, 2018, 11:44:47 AM (6 years ago)
- Branches:
- master, ctbto, dev
- Children:
- db27c09
- Parents:
- 708c667
- Location:
- source/python
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
source/python/classes/ControlFile.py
r708c667 r274f9ef 71 71 72 72 def __init__(self, filename): 73 ''' 74 @Description: 75 Initialises the instance of ControlFile class and defines 76 all class attributes with default values. Afterwards calls 77 function __read_controlfile__ to read parameter from 78 Control file. 79 80 @Input: 81 self: instance of ControlFile class 82 Description see class documentation. 83 84 filename: string 85 Name of CONTROL file. 86 87 @Return: 88 <nothing> 73 '''Initialises the instance of ControlFile class and defines 74 all class attributes with default values. Afterwards calls 75 function __read_controlfile__ to read parameter from Control file. 76 77 Parameters 78 ---------- 79 filename : :obj:`string` 80 Name of CONTROL file. 81 82 Return 83 ------ 84 89 85 ''' 90 86 … … 162 158 163 159 def __read_controlfile__(self): 164 ''' 165 @Description: 166 Read CONTROL file and assign all CONTROL file variables. 167 168 @Input: 169 self: instance of ControlFile class 170 Description see class documentation. 171 172 @Return: 173 <nothing> 160 '''Read CONTROL file and assign all CONTROL file variables. 161 162 Parameters 163 ---------- 164 165 Return 166 ------ 167 174 168 ''' 175 169 … … 235 229 236 230 def __str__(self): 237 ''' 238 @Description:239 Prepares a string which have all the ControlFile240 class attributes with its associated values. 241 Each attribute is printed in one line and in242 alphabetical order.243 244 Example:245 'age': 10246 'color': 'Spotted'247 'kids': 0248 'legs': 2249 'name': 'Dog' 250 'smell': 'Alot'251 252 @Input: 253 self: instance of ControlFile class254 Description see class documentation.255 256 @Return:257 string of ControlFile class attributeswith their values231 '''Prepares a string which have all the ControlFile class attributes 232 with its associated values. Each attribute is printed in one line and 233 in alphabetical order. 234 235 Example 236 ------- 237 'age': 10 238 'color': 'Spotted' 239 'kids': 0 240 'legs': 2 241 'name': 'Dog' 242 'smell': 'Alot' 243 244 Parameters 245 ---------- 246 247 Return 248 ------ 249 string 250 Single string of concatenated ControlFile class attributes 251 with their values 258 252 ''' 259 253 import collections … … 265 259 266 260 def assign_args_to_control(self, args): 267 ''' 268 @Description: 269 Overwrites the existing ControlFile instance attributes with 270 the command line arguments. 271 272 @Input: 273 self: instance of ControlFile class 274 Description see class documentation. 275 276 args: instance of ArgumentParser 277 Contains the commandline arguments from script/program call. 278 279 @Return: 280 <nothing> 261 '''Overwrites the existing ControlFile instance attributes with 262 the command line arguments. 263 264 Parameters 265 ---------- 266 args : :obj:`Namespace` 267 Contains the commandline arguments from script/program call. 268 269 Return 270 ------ 271 281 272 ''' 282 273 … … 294 285 295 286 def assign_envs_to_control(self, envs): 296 ''' 297 @Description: 298 Assigns the ECMWF environment parameter.299 300 @Input:301 envs: dict of strings302 Contains the ECMWF environment parameternames "ECUID", "ECGID",303 "DESTINATION" and "GATEWAY" with its corresponding values.304 They were read from the file "ECMWF_ENV". 305 306 @Return:307 <nothing> 287 '''Assigns the ECMWF environment parameter. 288 289 Parameters 290 ---------- 291 envs : :obj:`dictionary` of :obj:`strings` 292 Contains the ECMWF environment parameternames "ECUID", "ECGID", 293 "DESTINATION" and "GATEWAY" with its corresponding values. 294 They were read from the file "ECMWF_ENV". 295 296 Return 297 ------ 298 308 299 ''' 309 300 … … 314 305 315 306 def check_conditions(self, queue): 316 ''' 317 @Description: 318 Checks a couple of necessary attributes and conditions, 319 such as if they exist and contain values. 320 Otherwise set default values. 321 322 @Input: 323 self: instance of ControlFile class 324 Description see class documentation. 325 326 queue: string 327 Name of the queue if submitted to the ECMWF servers. 328 Used to check if ecuid, ecgid, gateway and destination 329 are set correctly and are not empty. 330 331 @Return: 332 <nothing> 307 '''Checks a couple of necessary attributes and conditions, 308 such as if they exist and contain values. 309 Otherwise set default values. 310 311 Parameters 312 ---------- 313 queue : :obj:`string` 314 Name of the queue if submitted to the ECMWF servers. 315 Used to check if ecuid, ecgid, gateway and destination 316 are set correctly and are not empty. 317 318 Return 319 ------ 320 333 321 ''' 334 322 from mods.tools import my_error … … 501 489 502 490 def check_install_conditions(self): 503 ''' 504 @Description: 505 Checks a couple of necessary attributes and conditions 506 for the installation such as if they exist and contain values. 507 Otherwise set default values. 508 509 @Input: 510 self: instance of ControlFile class 511 Description see class documentation. 512 513 @Return: 514 <nothing> 491 '''Checks a couple of necessary attributes and conditions 492 for the installation such as if they exist and contain values. 493 Otherwise set default values. 494 495 Parameters 496 ---------- 497 498 Return 499 ------ 500 515 501 ''' 516 502 … … 549 535 550 536 def to_list(self): 551 ''' 552 @Description: 553 Just generates a list of strings containing the attributes and 554 assigned values except the attributes "_expanded", "exedir", 537 '''Just generates a list of strings containing the attributes and 538 assigned values except the attributes "_expanded", "exedir", 539 "ecmwfdatadir" and "flexpart_root_scripts". 540 541 Parameters 542 ---------- 543 544 Return 545 ------ 546 l : :obj:`list` 547 A sorted list of the all ControlFile class attributes with 548 their values except the attributes "_expanded", "exedir", 555 549 "ecmwfdatadir" and "flexpart_root_scripts". 556 557 @Input:558 self: instance of ControlFile class559 Description see class documentation.560 561 @Return:562 l: list563 A sorted list of the all ControlFile class attributes with564 their values except the attributes "_expanded", "exedir",565 "ecmwfdatadir" and "flexpart_root_scripts".566 550 ''' 567 551 -
source/python/classes/EcFlexpart.py
r0934db1 r274f9ef 111 111 # -------------------------------------------------------------------------- 112 112 def __init__(self, c, fluxes=False): 113 ''' 114 @Description: 115 Creates an object/instance of EcFlexpart with the 116 associated settings of its attributes for the retrieval. 117 118 @Input: 119 self: instance of EcFlexpart 120 The current object of the class. 121 122 c: instance of class ControlFile 123 Contains all the parameters of CONTROL file and 124 command line. 125 For more information about format and content of the parameter 126 see documentation. 127 128 fluxes: boolean, optional 129 Decides if the flux parameter settings are stored or 130 the rest of the parameter list. 131 Default value is False. 132 133 @Return: 134 <nothing> 113 '''Creates an object/instance of EcFlexpart with the associated 114 settings of its attributes for the retrieval. 115 116 Parameters: 117 ----------- 118 c : :obj:`ControlFile` 119 Contains all the parameters of CONTROL file and 120 command line. 121 122 fluxes : :obj:`boolean`, optional 123 Decides if the flux parameter settings are stored or 124 the rest of the parameter list. 125 Default value is False. 126 127 Return 128 ------ 129 135 130 ''' 136 131 # set a counter for the number of mars requests generated … … 306 301 307 302 def _mk_targetname(self, ftype, param, date): 308 ''' 309 @Description:310 Creates the filename for the requested grib data to be stored in. 311 This name is passed as the "target" parameter in the request.312 313 @Input:314 ftype: string315 Shortcut name of the type of the field. E.g. AN, FC, PF, ... 316 317 param: string318 Shortcut of the grid type. E.g. SH__ML, SH__SL, GG__ML,319 GG__SL, OG__ML, OG__SL, OG_OROLSM_SL, OG_acc_SL 320 321 date: string322 The date period of the grib data to be stored in this file. 323 324 @Return:325 targetname: string326 303 '''Creates the filename for the requested grib data to be stored in. 304 This name is passed as the "target" parameter in the request. 305 306 Parameters 307 ---------- 308 ftype : :obj:`string` 309 Shortcut name of the type of the field. E.g. AN, FC, PF, ... 310 311 param : :obj:`string` 312 Shortcut of the grid type. E.g. SH__ML, SH__SL, GG__ML, 313 GG__SL, OG__ML, OG__SL, OG_OROLSM_SL, OG_acc_SL 314 315 date : :obj:`string` 316 The date period of the grib data to be stored in this file. 317 318 Return 319 ------ 320 targetname : :obj:`string` 321 The target filename for the grib data. 327 322 ''' 328 323 targetname = (self.inputdir + '/' + ftype + param + '.' + date + '.' + … … 333 328 334 329 def _start_retrievement(self, request, par_dict): 335 ''' 336 @Description: 337 Creates the Mars Retrieval and prints or submits the request 338 depending on the status of the request variable. 339 340 @Input: 341 self: instance of EcFlexpart 342 The current object of the class. 343 344 request: integer 345 Selects the mode of retrieval. 346 0: Retrieves the data from ECMWF. 347 1: Prints the mars requests to an output file. 348 2: Retrieves the data and prints the mars request. 349 350 par_dict: dictionary 351 Contains all parameter which have to be set for creating the 352 Mars Retrievals. The parameter are: 353 marsclass, dataset, stream, type, levtype, levelist, resol, 354 gaussian, accuracy, grid, target, area, date, time, number, 355 step, expver, param 356 357 @Return: 358 <nothing> 330 '''Creates the Mars Retrieval and prints or submits the request 331 depending on the status of the request variable. 332 333 Parameters 334 ---------- 335 request : :obj:`integer` 336 Selects the mode of retrieval. 337 0: Retrieves the data from ECMWF. 338 1: Prints the mars requests to an output file. 339 2: Retrieves the data and prints the mars request. 340 341 par_dict : :obj:`dictionary` 342 Contains all parameter which have to be set for creating the 343 Mars Retrievals. The parameter are: 344 marsclass, dataset, stream, type, levtype, levelist, resol, 345 gaussian, accuracy, grid, target, area, date, time, number, 346 step, expver, param 347 348 Return 349 ------ 350 359 351 ''' 360 352 # increase number of mars requests … … 398 390 399 391 def _mk_index_values(self, inputdir, inputfiles, keys): 400 ''' 401 @Description:402 Creates an index file for a set of grib parameter keys. 403 The values from the index keys are returned in a list.404 405 @Input:406 keys: dictionary407 List of parameter names which serves as index. 408 409 inputfiles: instance of UioFiles410 Contains a list of files. 411 412 @Return:413 iid: grib_index414 415 416 417 index_vals: list418 419 420 421 422 423 392 '''Creates an index file for a set of grib parameter keys. 393 The values from the index keys are returned in a list. 394 395 Parameters 396 ---------- 397 keys : :obj:`dictionary` 398 List of parameter names which serves as index. 399 400 inputfiles : :obj:`UioFiles` 401 Contains a list of files. 402 403 Return 404 ------ 405 iid : :obj:`grib_index` 406 This is a grib specific index structure to access 407 messages in a file. 408 409 index_vals : :obj:`list` 410 Contains the values from the keys used for a distinct selection 411 of grib messages in processing the grib files. 412 Content looks like e.g.: 413 index_vals[0]: ('20171106', '20171107', '20171108') ; date 414 index_vals[1]: ('0', '1200', '1800', '600') ; time 415 index_vals[2]: ('0', '12', '3', '6', '9') ; stepRange 424 416 ''' 425 417 iid = None … … 455 447 456 448 def retrieve(self, server, dates, public, request, inputdir='.'): 457 ''' 458 @Description: 459 Finalizing the retrieval information by setting final details 460 depending on grid type. 461 Prepares MARS retrievals per grid type and submits them. 462 463 @Input: 464 self: instance of EcFlexpart 465 The current object of the class. 466 467 server: instance of ECMWFService or ECMWFDataServer 468 The connection to the ECMWF server. This is different 469 for member state users which have full access and non 470 member state users which have only access to the public 471 data sets. The decision is made from command line argument 472 "public"; for public access its True (ECMWFDataServer) 473 for member state users its False (ECMWFService) 474 475 dates: string 476 Contains start and end date of the retrieval in the format 477 "YYYYMMDD/to/YYYYMMDD" 478 479 request: integer 480 Selects the mode of retrieval. 481 0: Retrieves the data from ECMWF. 482 1: Prints the mars requests to an output file. 483 2: Retrieves the data and prints the mars request. 484 485 inputdir: string, optional 486 Path to the directory where the retrieved data is about 487 to be stored. The default is the current directory ('.'). 488 489 @Return: 490 <nothing> 449 '''Finalizing the retrieval information by setting final details 450 depending on grid type. 451 Prepares MARS retrievals per grid type and submits them. 452 453 Parameters 454 ---------- 455 server : :obj:`ECMWFService` or :obj:`ECMWFDataServer` 456 The connection to the ECMWF server. This is different 457 for member state users which have full access and non 458 member state users which have only access to the public 459 data sets. The decision is made from command line argument 460 "public"; for public access its True (ECMWFDataServer) 461 for member state users its False (ECMWFService) 462 463 dates : :obj:`string` 464 Contains start and end date of the retrieval in the format 465 "YYYYMMDD/to/YYYYMMDD" 466 467 request : :obj:`integer` 468 Selects the mode of retrieval. 469 0: Retrieves the data from ECMWF. 470 1: Prints the mars requests to an output file. 471 2: Retrieves the data and prints the mars request. 472 473 inputdir : :obj:`string`, optional 474 Path to the directory where the retrieved data is about 475 to be stored. The default is the current directory ('.'). 476 477 Return 478 ------ 479 491 480 ''' 492 481 self.dates = dates … … 665 654 666 655 def write_namelist(self, c): 667 ''' 668 @Description: 669 Creates a namelist file in the temporary directory and writes 670 the following values to it: maxl, maxb, mlevel, 671 mlevelist, mnauf, metapar, rlo0, rlo1, rla0, rla1, 672 momega, momegadiff, mgauss, msmooth, meta, metadiff, mdpdeta 673 674 @Input: 675 self: instance of EcFlexpart 676 The current object of the class. 677 678 c: instance of class ControlFile 679 Contains all the parameters of CONTROL file and 680 command line. 681 For more information about format and content of the parameter 682 see documentation. 683 684 filename: string 656 '''Creates a namelist file in the temporary directory and writes 657 the following values to it: maxl, maxb, mlevel, 658 mlevelist, mnauf, metapar, rlo0, rlo1, rla0, rla1, 659 momega, momegadiff, mgauss, msmooth, meta, metadiff, mdpdeta 660 661 Parameters 662 ---------- 663 c : :obj:`ControlFile` 664 Contains all the parameters of CONTROL file and 665 command line. 666 667 filename : :obj:`string` 685 668 Name of the namelist file. 686 669 687 @Return: 688 <nothing> 670 Return 671 ------ 672 689 673 ''' 690 674 … … 734 718 735 719 def deacc_fluxes(self, inputfiles, c): 736 ''' 737 @Description: 738 Goes through all flux fields in ordered time and de-accumulate 739 the fields. Afterwards the fields are disaggregated in time. 740 Different versions of disaggregation is provided for rainfall 741 data (darain, modified linear) and the surface fluxes and 742 stress data (dapoly, cubic polynomial). 743 744 @Input: 745 self: instance of EcFlexpart 746 The current object of the class. 747 748 inputfiles: instance of UioFiles 749 Contains a list of files. 750 751 c: instance of class ControlFile 752 Contains all the parameters of CONTROL file and 753 command line. 754 For more information about format and content of the parameter 755 see documentation. 756 757 @Return: 758 <nothing> 720 '''Goes through all flux fields in ordered time and de-accumulate 721 the fields. Afterwards the fields are disaggregated in time. 722 Different versions of disaggregation is provided for rainfall 723 data (darain, modified linear) and the surface fluxes and 724 stress data (dapoly, cubic polynomial). 725 726 Parameters 727 ---------- 728 inputfiles : :obj:`UioFiles` 729 Contains a list of files. 730 731 c : :obj:`ControlFile` 732 Contains all the parameters of CONTROL file and 733 command line. 734 735 Return 736 ------ 737 759 738 ''' 760 739 … … 952 931 953 932 def create(self, inputfiles, c): 954 ''' 955 @Description: 956 This method is based on the ECMWF example index.py 957 https://software.ecmwf.int/wiki/display/GRIB/index.py 958 959 An index file will be created which depends on the combination 960 of "date", "time" and "stepRange" values. This is used to iterate 961 over all messages in each grib file which were passed through the 962 parameter "inputfiles" to seperate specific parameters into fort.* 963 files. Afterwards the FORTRAN program is called to convert 964 the data fields all to the same grid and put them in one file 965 per unique time step (combination of "date", "time" and 966 "stepRange"). 967 968 @Input: 969 self: instance of EcFlexpart 970 The current object of the class. 971 972 inputfiles: instance of UioFiles 973 Contains a list of files. 974 975 c: instance of class ControlFile 976 Contains all the parameters of CONTROL file and 977 command line. 978 For more information about format and content of the parameter 979 see documentation. 980 981 @Return: 982 <nothing> 933 '''An index file will be created which depends on the combination 934 of "date", "time" and "stepRange" values. This is used to iterate 935 over all messages in each grib file which were passed through the 936 parameter "inputfiles" to seperate specific parameters into fort.* 937 files. Afterwards the FORTRAN program is called to convert 938 the data fields all to the same grid and put them in one file 939 per unique time step (combination of "date", "time" and 940 "stepRange"). 941 942 Note 943 ---- 944 This method is based on the ECMWF example index.py 945 https://software.ecmwf.int/wiki/display/GRIB/index.py 946 947 Parameters 948 ---------- 949 inputfiles : :obj:`UioFiles` 950 Contains a list of files. 951 952 c : :obj:`ControlFile` 953 Contains all the parameters of CONTROL file and 954 command line. 955 956 Return 957 ------ 958 983 959 ''' 984 960 … … 1183 1159 1184 1160 def process_output(self, c): 1185 ''' 1186 @Description: 1187 The grib files are postprocessed depending on the selection in 1188 CONTROL file. The resulting files are moved to the output 1189 directory if its not equal to the input directory. 1190 The following modifications might be done if 1191 properly switched in CONTROL file: 1192 GRIB2 - Conversion to GRIB2 1193 ECTRANS - Transfer of files to gateway server 1194 ECSTORAGE - Storage at ECMWF server 1195 1196 @Input: 1197 self: instance of EcFlexpart 1198 The current object of the class. 1199 1200 c: instance of class ControlFile 1201 Contains all the parameters of CONTROL file and 1202 command line. 1203 For more information about format and content of the parameter 1204 see documentation. 1205 1206 @Return: 1207 <nothing> 1161 '''The grib files are postprocessed depending on the selection in 1162 CONTROL file. The resulting files are moved to the output 1163 directory if its not equal to the input directory. 1164 The following modifications might be done if 1165 properly switched in CONTROL file: 1166 GRIB2 - Conversion to GRIB2 1167 ECTRANS - Transfer of files to gateway server 1168 ECSTORAGE - Storage at ECMWF server 1169 1170 Parameters 1171 ---------- 1172 c : :obj:`ControlFile` 1173 Contains all the parameters of CONTROL file and 1174 command line. 1175 1176 Return 1177 ------ 1208 1178 1209 1179 ''' … … 1247 1217 1248 1218 def prepare_fp_files(self, c): 1249 ''' 1250 @Description: 1251 Conversion of GRIB files to FLEXPART binary format. 1252 1253 @Input: 1254 c: instance of class ControlFile 1255 Contains all the parameters of CONTROL file and 1256 command line. 1257 For more information about format and content of the parameter 1258 see documentation. 1259 1260 1261 @Return: 1262 <nothing> 1219 '''Conversion of GRIB files to FLEXPART binary format. 1220 1221 Parameters 1222 ---------- 1223 c : :obj:`ControlFile` 1224 Contains all the parameters of CONTROL file and 1225 command line. 1226 1227 Return 1228 ------ 1229 1263 1230 ''' 1264 1231 # generate AVAILABLE file -
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") -
source/python/classes/MarsRetrieval.py
r70fee58 r274f9ef 73 73 # ------------------------------------------------------------------------------ 74 74 class MarsRetrieval(object): 75 ''' 76 Class for submitting MARS retrievals. 75 '''Class for submitting MARS retrievals. 77 76 78 77 A description of MARS keywords/arguments and examples of their … … 80 79 https://software.ecmwf.int/wiki/display/UDOC/\ 81 80 Identification+keywords#Identificationkeywords-class 82 83 81 ''' 84 82 … … 88 86 number="", accuracy="", grid="", gaussian="", target="", 89 87 param=""): 90 ''' 91 @Description: 92 Initialises the instance of the MarsRetrieval class and 93 defines and assigns a set of the necessary retrieval parameters 94 for the FLEXPART input data. 95 A description of MARS keywords/arguments, their dependencies 96 on each other and examples of their values can be found here: 97 98 https://software.ecmwf.int/wiki/display/UDOC/MARS+keywords 99 100 @Input: 101 self: instance of MarsRetrieval 102 For description see class documentation. 103 104 server: instance of ECMWFService (from ECMWF Web-API) 105 This is the connection to the ECMWF data servers. 106 It is needed for the pythonic access of ECMWF data. 107 108 public: integer 109 Decides which Web API version is used: 110 0: member-state users and full archive access 111 1: public access and limited access to the public server and 112 datasets. Needs the parameter dataset. 113 Default is "0" and for member-state users. 114 115 marsclass: string, optional 116 Characterisation of dataset. E.g. EI (ERA-Interim), 117 E4 (ERA40), OD (Operational archive), ea (ERA5). 118 Default is the ERA-Interim dataset "ei". 119 120 dataset: string, optional 121 For public datasets there is the specific naming and parameter 122 dataset which has to be used to characterize the type of 123 data. Usually there is less data available, either in times, 124 domain or parameter. 125 Default is an empty string. 126 127 type: string, optional 128 Determines the type of fields to be retrieved. 129 Selects between observations, images or fields. 130 Examples for fields: Analysis (an), Forecast (fc), 131 Perturbed Forecast (pf), Control Forecast (cf) and so on. 132 Default is an empty string. 133 134 levtype: string, optional 135 Denotes type of level. Has a direct implication on valid 136 levelist values! 137 E.g. model level (ml), pressure level (pl), surface (sfc), 138 potential vorticity (pv), potential temperature (pt) 139 and depth (dp). 140 Default is an empty string. 141 142 levelist: string, optional 143 Specifies the required levels. It has to have a valid 144 correspondence to the selected levtype. 145 Examples: model level: 1/to/137, pressure levels: 500/to/1000 146 Default is an empty string. 147 148 repres: string, optional 149 Selects the representation of the archived data. 150 E.g. sh - spherical harmonics, gg - Gaussian grid, 151 ll - latitude/longitude, ... 152 Default is an empty string. 153 154 date: string, optional 155 Specifies the Analysis date, the Forecast base date or 156 Observations date. Valid formats are: 157 Absolute as YYYY-MM-DD or YYYYMMDD. 158 Default is an empty string. 159 160 resol: string, optional 161 Specifies the desired triangular truncation of retrieved data, 162 before carrying out any other selected post-processing. 163 The default is automatic truncation (auto), by which the lowest 164 resolution compatible with the value specified in grid is 165 automatically selected for the retrieval. 166 Users wanting to perform post-processing from full spectral 167 resolution should specify Archived Value (av). 168 The following are examples of existing resolutions found in 169 the archive: 63, 106, 159, 213, 255, 319, 399, 511, 799 or 1279. 170 This keyword has no meaning/effect if the archived data is 171 not in spherical harmonics representation. 172 The best selection can be found here: 173 https://software.ecmwf.int/wiki/display/UDOC/\ 174 Retrieve#Retrieve-Truncationbeforeinterpolation 175 Default is an empty string. 176 177 stream: string, optional 178 Identifies the forecasting system used to generate the data. 179 E.g. oper (Atmospheric model), enfo (Ensemble forecats), ... 180 Default is an empty string. 181 182 area: string, optional 183 Specifies the desired sub-area of data to be extracted. 184 Areas can be defined to wrap around the globe. 185 186 Latitude values must be given as signed numbers, with: 187 north latitudes (i.e. north of the equator) 188 being positive (e.g: 40.5) 189 south latitutes (i.e. south of the equator) 190 being negative (e.g: -50.5) 191 Longtitude values must be given as signed numbers, with: 192 east longitudes (i.e. east of the 0 degree meridian) 193 being positive (e.g: 35.0) 194 west longitudes (i.e. west of the 0 degree meridian) 195 being negative (e.g: -20.5) 196 197 E.g.: North/West/South/East 198 Default is an empty string. 199 200 time: string, optional 201 Specifies the time of the data in hours and minutes. 202 Valid values depend on the type of data: Analysis time, 203 Forecast base time or First guess verification time 204 (all usually at synoptic hours: 00, 06, 12 and 18 ). 205 Observation time (any combination in hours and minutes is valid, 206 subject to data availability in the archive). 207 The syntax is HHMM or HH:MM. If MM is omitted it defaults to 00. 208 Default is an empty string. 209 210 step: string, optional 211 Specifies the forecast time step from forecast base time. 212 Valid values are hours (HH) from forecast base time. It also 213 specifies the length of the forecast which verifies at 214 First Guess time. 215 E.g. 1/3/6-hourly 216 Default is an empty string. 217 218 expver: string, optional 219 The version of the dataset. Each experiment is assigned a 220 unique code (version). Production data is assigned 1 or 2, 221 and experimental data in Operations 11, 12 ,... 222 Research or Member State's experiments have a four letter 223 experiment identifier. 224 Default is "1". 225 226 number: string, optional 227 Selects the member in ensemble forecast run. (Only then it 228 is necessary.) It has a different meaning depending on 229 the type of data. 230 E.g. Perturbed Forecasts: specifies the Ensemble forecast member 231 Default is an empty string. 232 233 accuracy: string, optional 234 Specifies the number of bits per value to be used in the 235 generated GRIB coded fields. 236 A positive integer may be given to specify the preferred number 237 of bits per packed value. This must not be greater than the 238 number of bits normally used for a Fortran integer on the 239 processor handling the request (typically 32 or 64 bit). 240 Within a compute request the accuracy of the original fields 241 can be passed to the result field by specifying accuracy=av. 242 Default is an empty string. 243 244 grid: string, optional 245 Specifies the output grid which can be either a Gaussian grid 246 or a Latitude/Longitude grid. MARS requests specifying 247 grid=av will return the archived model grid. 248 249 Lat/Lon grid: The grid spacing needs to be an integer 250 fraction of 90 degrees e.g. grid = 0.5/0.5 251 252 Gaussian grid: specified by a letter denoting the type of 253 Gaussian grid followed by an integer (the grid number) 254 representing the number of lines between the Pole and Equator, 255 e.g. 256 grid = F160 - full (or regular) Gaussian grid with 257 160 latitude lines between the pole and equator 258 grid = N320 - ECMWF original reduced Gaussian grid with 259 320 latitude lines between the pole and equator, 260 see Reduced Gaussian Grids for grid numbers used at ECMWF 261 grid = O640 - ECMWF octahedral (reduced) Gaussian grid with 262 640 latitude lines between the pole and equator 263 Default is an empty string. 264 265 gaussian: string, optional 266 This parameter is deprecated and should no longer be used. 267 Specifies the desired type of Gaussian grid for the output. 268 Valid Gaussian grids are quasi-regular (reduced) or regular. 269 Keyword gaussian can only be specified together with 270 keyword grid. Gaussian without grid has no effect. 271 Default is an empty string. 272 273 target: string, optional 274 Specifies a file into which data is to be written after 275 retrieval or manipulation. Path names should always be 276 enclosed in double quotes. The MARS client supports automatic 277 generation of multiple target files using MARS keywords 278 enclosed in square brackets [ ]. If the environment variable 279 MARS_MULTITARGET_STRICT_FORMAT is set to 1 before calling mars, 280 the keyword values will be used in the filename as shown by 281 the ecCodes GRIB tool grib_ls -m, e.g. with 282 MARS_MULTITARGET_STRICT_FORMAT set to 1 the keywords time, 283 expver and param will be formatted as 0600, 0001 and 129.128 284 rather than 600, 1 and 129. 285 Default is an empty string. 286 287 param: string, optional 288 Specifies the meteorological parameter. 289 The list of meteorological parameters in MARS is extensive. 290 Their availability is directly related to their meteorological 291 meaning and, therefore, the rest of directives specified 292 in the MARS request. 293 Meteorological parameters can be specified by their 294 GRIB code (param=130), their mnemonic (param=t) or 295 full name (param=temperature). 296 The list of parameter should be seperated by a "/"-sign. 297 E.g. 130/131/133 298 Default is an empty string. 299 300 @Return: 301 <nothing> 88 '''Initialises the instance of the MarsRetrieval class and 89 defines and assigns a set of the necessary retrieval parameters 90 for the FLEXPART input data. 91 A description of MARS keywords/arguments, their dependencies 92 on each other and examples of their values can be found here: 93 94 https://software.ecmwf.int/wiki/display/UDOC/MARS+keywords 95 96 Parameters 97 ---------- 98 server : :obj:`ECMWFService` 99 This is the connection to the ECMWF data servers. 100 It is needed for the pythonic access of ECMWF data. 101 102 public : :obj:`integer` 103 Decides which Web API version is used: 104 0: member-state users and full archive access 105 1: public access and limited access to the public server and 106 datasets. Needs the parameter dataset. 107 Default is "0" and for member-state users. 108 109 marsclass : :obj:`string`, optional 110 Characterisation of dataset. E.g. EI (ERA-Interim), 111 E4 (ERA40), OD (Operational archive), ea (ERA5). 112 Default is the ERA-Interim dataset "ei". 113 114 dataset : :obj:`string`, optional 115 For public datasets there is the specific naming and parameter 116 dataset which has to be used to characterize the type of 117 data. Usually there is less data available, either in times, 118 domain or parameter. 119 Default is an empty string. 120 121 type : :obj:`string`, optional 122 Determines the type of fields to be retrieved. 123 Selects between observations, images or fields. 124 Examples for fields: Analysis (an), Forecast (fc), 125 Perturbed Forecast (pf), Control Forecast (cf) and so on. 126 Default is an empty string. 127 128 levtype : :obj:`string`, optional 129 Denotes type of level. Has a direct implication on valid 130 levelist values! 131 E.g. model level (ml), pressure level (pl), surface (sfc), 132 potential vorticity (pv), potential temperature (pt) 133 and depth (dp). 134 Default is an empty string. 135 136 levelist : :obj:`string`, optional 137 Specifies the required levels. It has to have a valid 138 correspondence to the selected levtype. 139 Examples: model level: 1/to/137, pressure levels: 500/to/1000 140 Default is an empty string. 141 142 repres : :obj:`string`, optional 143 Selects the representation of the archived data. 144 E.g. sh - spherical harmonics, gg - Gaussian grid, 145 ll - latitude/longitude, ... 146 Default is an empty string. 147 148 date : :obj:`string`, optional 149 Specifies the Analysis date, the Forecast base date or 150 Observations date. Valid formats are: 151 Absolute as YYYY-MM-DD or YYYYMMDD. 152 Default is an empty string. 153 154 resol : :obj:`string`, optional 155 Specifies the desired triangular truncation of retrieved data, 156 before carrying out any other selected post-processing. 157 The default is automatic truncation (auto), by which the lowest 158 resolution compatible with the value specified in grid is 159 automatically selected for the retrieval. 160 Users wanting to perform post-processing from full spectral 161 resolution should specify Archived Value (av). 162 The following are examples of existing resolutions found in 163 the archive: 63, 106, 159, 213, 255, 319, 399, 511, 799 or 1279. 164 This keyword has no meaning/effect if the archived data is 165 not in spherical harmonics representation. 166 The best selection can be found here: 167 https://software.ecmwf.int/wiki/display/UDOC/\ 168 Retrieve#Retrieve-Truncationbeforeinterpolation 169 Default is an empty string. 170 171 stream : :obj:`string`, optional 172 Identifies the forecasting system used to generate the data. 173 E.g. oper (Atmospheric model), enfo (Ensemble forecats), ... 174 Default is an empty string. 175 176 area : :obj:`string`, optional 177 Specifies the desired sub-area of data to be extracted. 178 Areas can be defined to wrap around the globe. 179 180 Latitude values must be given as signed numbers, with: 181 north latitudes (i.e. north of the equator) 182 being positive (e.g: 40.5) 183 south latitutes (i.e. south of the equator) 184 being negative (e.g: -50.5) 185 Longtitude values must be given as signed numbers, with: 186 east longitudes (i.e. east of the 0 degree meridian) 187 being positive (e.g: 35.0) 188 west longitudes (i.e. west of the 0 degree meridian) 189 being negative (e.g: -20.5) 190 191 E.g.: North/West/South/East 192 Default is an empty string. 193 194 time : :obj:`string`, optional 195 Specifies the time of the data in hours and minutes. 196 Valid values depend on the type of data: Analysis time, 197 Forecast base time or First guess verification time 198 (all usually at synoptic hours: 00, 06, 12 and 18 ). 199 Observation time (any combination in hours and minutes is valid, 200 subject to data availability in the archive). 201 The syntax is HHMM or HH:MM. If MM is omitted it defaults to 00. 202 Default is an empty string. 203 204 step : :obj:`string`, optional 205 Specifies the forecast time step from forecast base time. 206 Valid values are hours (HH) from forecast base time. It also 207 specifies the length of the forecast which verifies at 208 First Guess time. 209 E.g. 1/3/6-hourly 210 Default is an empty string. 211 212 expver : :obj:`string`, optional 213 The version of the dataset. Each experiment is assigned a 214 unique code (version). Production data is assigned 1 or 2, 215 and experimental data in Operations 11, 12 ,... 216 Research or Member State's experiments have a four letter 217 experiment identifier. 218 Default is "1". 219 220 number : :obj:`string`, optional 221 Selects the member in ensemble forecast run. (Only then it 222 is necessary.) It has a different meaning depending on 223 the type of data. 224 E.g. Perturbed Forecasts: specifies the Ensemble forecast member 225 Default is an empty string. 226 227 accuracy : :obj:`string`, optional 228 Specifies the number of bits per value to be used in the 229 generated GRIB coded fields. 230 A positive integer may be given to specify the preferred number 231 of bits per packed value. This must not be greater than the 232 number of bits normally used for a Fortran integer on the 233 processor handling the request (typically 32 or 64 bit). 234 Within a compute request the accuracy of the original fields 235 can be passed to the result field by specifying accuracy=av. 236 Default is an empty string. 237 238 grid : :obj:`string`, optional 239 Specifies the output grid which can be either a Gaussian grid 240 or a Latitude/Longitude grid. MARS requests specifying 241 grid=av will return the archived model grid. 242 243 Lat/Lon grid: The grid spacing needs to be an integer 244 fraction of 90 degrees e.g. grid = 0.5/0.5 245 246 Gaussian grid: specified by a letter denoting the type of 247 Gaussian grid followed by an integer (the grid number) 248 representing the number of lines between the Pole and Equator, 249 e.g. 250 grid = F160 - full (or regular) Gaussian grid with 251 160 latitude lines between the pole and equator 252 grid = N320 - ECMWF original reduced Gaussian grid with 253 320 latitude lines between the pole and equator, 254 see Reduced Gaussian Grids for grid numbers used at ECMWF 255 grid = O640 - ECMWF octahedral (reduced) Gaussian grid with 256 640 latitude lines between the pole and equator 257 Default is an empty string. 258 259 gaussian : :obj:`string`, optional 260 This parameter is deprecated and should no longer be used. 261 Specifies the desired type of Gaussian grid for the output. 262 Valid Gaussian grids are quasi-regular (reduced) or regular. 263 Keyword gaussian can only be specified together with 264 keyword grid. Gaussian without grid has no effect. 265 Default is an empty string. 266 267 target : :obj:`string`, optional 268 Specifies a file into which data is to be written after 269 retrieval or manipulation. Path names should always be 270 enclosed in double quotes. The MARS client supports automatic 271 generation of multiple target files using MARS keywords 272 enclosed in square brackets [ ]. If the environment variable 273 MARS_MULTITARGET_STRICT_FORMAT is set to 1 before calling mars, 274 the keyword values will be used in the filename as shown by 275 the ecCodes GRIB tool grib_ls -m, e.g. with 276 MARS_MULTITARGET_STRICT_FORMAT set to 1 the keywords time, 277 expver and param will be formatted as 0600, 0001 and 129.128 278 rather than 600, 1 and 129. 279 Default is an empty string. 280 281 param : :obj:`string`, optional 282 Specifies the meteorological parameter. 283 The list of meteorological parameters in MARS is extensive. 284 Their availability is directly related to their meteorological 285 meaning and, therefore, the rest of directives specified 286 in the MARS request. 287 Meteorological parameters can be specified by their 288 GRIB code (param=130), their mnemonic (param=t) or 289 full name (param=temperature). 290 The list of parameter should be seperated by a "/"-sign. 291 E.g. 130/131/133 292 Default is an empty string. 293 294 Return 295 ------ 296 302 297 ''' 303 298 … … 328 323 329 324 def display_info(self): 330 ''' 331 @Description: 332 Prints all class attributes and their values to the 333 standard output. 334 335 @Input: 336 self: instance of MarsRetrieval 337 For description see class documentation. 338 339 @Return: 340 <nothing> 325 '''Prints all class attributes and their values to the 326 standard output. 327 328 Parameters 329 ---------- 330 331 Return 332 ------ 333 341 334 ''' 342 335 # Get all class attributes and their values as a dictionary … … 355 348 356 349 def print_info(self, inputdir, request_number): 357 ''' 358 @Description: 359 Prints all mars requests to an extra file for debugging and 360 information. 361 362 @Input: 363 self: instance of MarsRetrieval 364 For description see class documentation. 365 366 inputdir: string 367 The path where all data from the retrievals are stored. 368 369 request_number: integer 370 Number of mars requests for flux and non-flux data. 371 372 @Return: 373 <nothing> 350 '''Prints all mars requests to an extra file for debugging and 351 information. 352 353 Parameters 354 ---------- 355 inputdir : :obj:`string` 356 The path where all data from the retrievals are stored. 357 358 request_number : :obj:`integer` 359 Number of mars requests for flux and non-flux data. 360 361 Return 362 ------ 363 374 364 ''' 375 365 # Get all class attributes and their values as a dictionary … … 393 383 394 384 def print_infodata_csv(self, inputdir, request_number): 395 ''' 396 @Description: 397 Write all request parameter in alpabetical order into a "csv" file. 398 399 @Input: 400 self: instance of MarsRetrieval 401 For description see class documentation. 402 403 inputdir: string 404 The path where all data from the retrievals are stored. 405 406 request_number: integer 407 Number of mars requests for flux and non-flux data. 408 409 @Return: 410 <nothing> 385 '''Write all request parameter in alpabetical order into a "csv" file. 386 387 Parameters 388 ---------- 389 inputdir : :obj:`string` 390 The path where all data from the retrievals are stored. 391 392 request_number : :obj:`integer` 393 Number of mars requests for flux and non-flux data. 394 395 Return 396 ------ 397 411 398 ''' 412 399 … … 427 414 428 415 def data_retrieve(self): 429 ''' 430 @Description: 431 Submits a MARS retrieval. Depending on the existence of 432 ECMWF Web-API it is submitted via Python or a 433 subprocess in the Shell. The parameter for the mars retrieval 434 are taken from the defined class attributes. 435 436 @Input: 437 self: instance of MarsRetrieval 438 For description see class documentation. 439 440 @Return: 441 <nothing> 416 '''Submits a MARS retrieval. Depending on the existence of 417 ECMWF Web-API it is submitted via Python or a 418 subprocess in the Shell. The parameter for the mars retrieval 419 are taken from the defined class attributes. 420 421 Parameters 422 ---------- 423 424 Return 425 ------ 426 442 427 ''' 443 428 # Get all class attributes and their values as a dictionary -
source/python/classes/UioFiles.py
rca867de r274f9ef 61 61 62 62 class UioFiles(object): 63 ''' 64 Class to manipulate files. At initialisation it has the pattern 63 '''Class to manipulate files. At initialisation it has the pattern 65 64 which stores a regular expression pattern for the files, the path 66 65 to the files and the files already. … … 70 69 # -------------------------------------------------------------------------- 71 70 def __init__(self, path, pattern): 72 ''' 73 @Description: 74 Assignes a specific pattern for these files. 71 '''Assignes a specific pattern for these files. 75 72 76 @Input: 77 self: instance of UioFiles 78 Description see class documentation. 73 Parameters 74 ---------- 75 path : :obj:`string` 76 Directory where to list the files. 79 77 80 path: string81 Directory where to list the files.78 pattern : :obj:`string` 79 Regular expression pattern. For example: '\*.grb' 82 80 83 pattern: string84 Regular expression pattern. For example: '*.grb'81 Return 82 ------ 85 83 86 @Return:87 <nothing>88 84 ''' 89 85 … … 98 94 #@profiling.timefn 99 95 def __list_files__(self, path): 100 ''' 101 @Description: 102 Lists all files in the directory with the matching 103 regular expression pattern. 96 '''Lists all files in the directory with the matching 97 regular expression pattern. 104 98 105 @Input: 106 self: instance of UioFiles 107 Description see class documentation. 99 Parameters 100 ---------- 101 path : :obj:`string` 102 Path to the files. 108 103 109 path: string110 Path to the files.104 Return 105 ------ 111 106 112 @Return:113 <nothing>114 107 ''' 115 108 # Get the absolute path … … 124 117 125 118 def __str__(self): 126 ''' 127 @Description: 128 Converts the list of files into a single string. 129 The entries are sepereated by "," sign. 119 '''Converts the list of files into a single string. 120 The entries are sepereated by "," sign. 130 121 131 @Input: 132 self: instance of UioFiles 133 Description see class documentation. 122 Parameters 123 ---------- 134 124 135 @Return: 136 files_string: string 137 The content of the list as a single string. 125 Return 126 ------ 127 files_string : :obj:`string` 128 The content of the list as a single string. 138 129 ''' 139 130 … … 144 135 145 136 def delete_files(self): 146 ''' 147 @Description: 148 Deletes the files. 137 '''Deletes the files. 149 138 150 @Input: 151 self: instance of UioFiles 152 Description see class documentation. 139 Parameters 140 ---------- 153 141 154 @Return: 155 <nothing> 142 Return 143 ------ 144 156 145 ''' 157 146 -
source/python/install.py
rc5074d2 r274f9ef 66 66 # ------------------------------------------------------------------------------ 67 67 def main(): 68 ''' 69 @Description: 70 Controls the installation process. Calls the installation function 71 if target is specified. 72 73 @Intput: 74 <nothing> 75 76 @Return: 77 <nothing> 68 '''Controls the installation process. Calls the installation function 69 if target is specified. 70 71 Parameters 72 ---------- 73 74 Return 75 ------ 78 76 ''' 79 77 … … 88 86 89 87 def get_install_cmdline_arguments(): 90 ''' 91 @Description: 92 Decomposes the command line arguments and assigns them to variables. 93 Apply default values for non mentioned arguments. 94 95 @Input: 96 <nothing> 97 98 @Return: 99 args: instance of ArgumentParser 100 Contains the commandline arguments from script/program call. 88 '''Decomposes the command line arguments and assigns them to variables. 89 Apply default values for non mentioned arguments. 90 91 Parameters 92 ---------- 93 94 Return 95 ------ 96 args : :obj:`Namespace` 97 Contains the commandline arguments from script/program call. 101 98 ''' 102 99 parser = ArgumentParser(description='Install flex_extract software locally or \ … … 139 136 140 137 def install_via_gateway(c): 141 ''' 142 @Description: 143 Perform the actual installation on local machine or prepare data 144 transfer to remote gate and submit a job script which will 145 install everything on the remote gate. 146 147 @Input: 148 c: instance of class ControlFile 149 Contains all the parameters of CONTROL file and 150 command line. 151 For more information about format and content of the parameter 152 see documentation. 153 154 @Return: 155 <nothing> 138 '''Perform the actual installation on local machine or prepare data 139 transfer to remote gate and submit a job script which will 140 install everything on the remote gate. 141 142 Parameters 143 ---------- 144 c : :obj:`ControlFile` 145 Contains all the parameters of CONTROL file and 146 command line. 147 148 Return 149 ------ 150 156 151 ''' 157 152 import tarfile … … 224 219 225 220 def mk_tarball(tarball_path, target): 226 ''' 227 @Description:228 Creates a tarball with all necessary files which need to be sent to the229 installation directory.230 It does not matter if this is local or remote.231 Collects all python files, the Fortran source and makefiles,232 the ECMWF_ENV file, the CONTROL files as well as the 233 template files.234 235 @Input:236 tarball_path: string237 The complete path to the tar file which will contain all238 relevant data for flex_extract. 239 240 target: string241 The queue where the job is submitted to. 242 243 @Return:244 <nothing> 221 '''Creates a tarball with all necessary files which need to be sent to the 222 installation directory. 223 It does not matter if this is local or remote. 224 Collects all python files, the Fortran source and makefiles, 225 the ECMWF_ENV file, the CONTROL files as well as the 226 template files. 227 228 Parameters 229 ---------- 230 tarball_path : :obj:`string` 231 The complete path to the tar file which will contain all 232 relevant data for flex_extract. 233 234 target : :obj:`string` 235 The queue where the job is submitted to. 236 237 Return 238 ------ 239 245 240 ''' 246 241 import tarfile … … 294 289 295 290 def un_tarball(tarball_path): 296 ''' 297 @Description: 298 Extracts the given tarball into current directory.299 300 @Input:301 tarball_path: string302 The complete path to the tar file which will contain all303 relevant data for flex_extract. 304 305 @Return:306 <nothing> 291 '''Extracts the given tarball into current directory. 292 293 Parameters 294 ---------- 295 tarball_path : :obj:`string` 296 The complete path to the tar file which will contain all 297 relevant data for flex_extract. 298 299 Return 300 ------ 301 307 302 ''' 308 303 import tarfile … … 316 311 317 312 def mk_env_vars(ecuid, ecgid, gateway, destination): 318 ''' 319 @Description:320 Creates a file named ECMWF_ENV which contains the321 necessary environmental variables at ECMWF servers. 322 It is based on the template ECMWF_ENV.template.323 324 @Input:325 ecuid: string326 The user id on ECMWF server. 327 328 ecgid: string329 The group id on ECMWF server. 330 331 gateway: string332 The gateway server the user is using. 333 334 destination: string335 The remote destination which is used to transfer files336 from ECMWF server to local gateway server. 337 338 @Return:339 <nothing> 313 '''Creates a file named ECMWF_ENV which contains the 314 necessary environmental variables at ECMWF servers. 315 It is based on the template ECMWF_ENV.template. 316 317 Parameters 318 ---------- 319 ecuid : :obj:`string` 320 The user id on ECMWF server. 321 322 ecgid : :obj:`string` 323 The group id on ECMWF server. 324 325 gateway : :obj:`string` 326 The gateway server the user is using. 327 328 destination : :obj:`string` 329 The remote destination which is used to transfer files 330 from ECMWF server to local gateway server. 331 332 Return 333 ------ 334 340 335 ''' 341 336 from genshi.template.text import NewTextTemplate … … 358 353 359 354 def mk_compilejob(makefile, target, ecuid, ecgid, fp_root): 360 ''' 361 @Description:362 Modifies the original job template file so that it is specified363 for the user and the environment were it will be applied. Result 364 is stored in a new file "job.temp" in the python directory.365 366 @Input:367 makefile: string368 Name of the makefile which should be used to compile FORTRAN369 CONVERT2 program. 370 371 target: string372 The target where the installation should be done, e.g. the queue. 373 374 ecuid: string375 The user id on ECMWF server. 376 377 ecgid: string378 The group id on ECMWF server. 379 380 fp_root: string381 Path to the root directory of FLEXPART environment or flex_extract382 environment. 383 384 @Return:385 <nothing> 355 '''Modifies the original job template file so that it is specified 356 for the user and the environment were it will be applied. Result 357 is stored in a new file "job.temp" in the python directory. 358 359 Parameters 360 ---------- 361 makefile : :obj:`string` 362 Name of the makefile which should be used to compile FORTRAN 363 CONVERT2 program. 364 365 target : :obj:`string` 366 The target where the installation should be done, e.g. the queue. 367 368 ecuid : :obj:`string` 369 The user id on ECMWF server. 370 371 ecgid : :obj:`string` 372 The group id on ECMWF server. 373 374 fp_root : :obj:`string` 375 Path to the root directory of FLEXPART environment or flex_extract 376 environment. 377 378 Return 379 ------ 380 386 381 ''' 387 382 from genshi.template.text import NewTextTemplate … … 413 408 414 409 def mk_job_template(ecuid, ecgid, gateway, destination, fp_root): 415 ''' 416 @Description:417 Modifies the original job template file so that it is specified418 for the user and the environment were it will be applied. Result 419 is stored in a new file.420 421 @Input:422 ecuid: string423 The user id on ECMWF server. 424 425 ecgid: string426 The group id on ECMWF server. 427 428 gateway: string429 The gateway server the user is using. 430 431 destination: string432 The remote destination which is used to transfer files433 from ECMWF server to local gateway server. 434 435 fp_root: string436 Path to the root directory of FLEXPART environment or flex_extract437 environment. 438 439 @Return:440 <nothing> 410 '''Modifies the original job template file so that it is specified 411 for the user and the environment were it will be applied. Result 412 is stored in a new file. 413 414 Parameters 415 ---------- 416 ecuid : :obj:`string` 417 The user id on ECMWF server. 418 419 ecgid : :obj:`string` 420 The group id on ECMWF server. 421 422 gateway : :obj:`string` 423 The gateway server the user is using. 424 425 destination : :obj:`string` 426 The remote destination which is used to transfer files 427 from ECMWF server to local gateway server. 428 429 fp_root : :obj:`string` 430 Path to the root directory of FLEXPART environment or flex_extract 431 environment. 432 433 Return 434 ------ 435 441 436 ''' 442 437 from genshi.template.text import NewTextTemplate … … 467 462 468 463 def delete_convert_build(src_path): 469 ''' 470 @Description:471 Clean up the Fortran source directory and remove all 472 build files (e.g. *.o, *.mod and CONVERT2)473 474 @Input:475 src_path: string476 Path to the fortran source directory. 477 478 @Return:479 <nothing> 464 '''Clean up the Fortran source directory and remove all 465 build files (e.g. \*.o, \*.mod and CONVERT2) 466 467 Parameters 468 ---------- 469 src_path : :obj:`string` 470 Path to the fortran source directory. 471 472 Return 473 ------ 474 480 475 ''' 481 476 … … 491 486 492 487 def make_convert_build(src_path, makefile): 493 ''' 494 @Description: 495 Compiles the Fortran code and generates the executable.496 497 @Input:498 src_path: string499 Path to the fortran source directory. 500 501 makefile: string502 The name of the makefile which should be used. 503 504 @Return:505 <nothing> 488 '''Compiles the Fortran code and generates the executable. 489 490 Parameters 491 ---------- 492 src_path : :obj:`string` 493 Path to the fortran source directory. 494 495 makefile : :obj:`string` 496 The name of the makefile which should be used. 497 498 Return 499 ------ 500 506 501 ''' 507 502 -
source/python/mods/get_mars_data.py
r70fee58 r274f9ef 69 69 # ------------------------------------------------------------------------------ 70 70 def main(): 71 ''' 72 @Description: 73 If get_mars_data is called directly from command line, 74 75 the program flow and calls the argumentparser function and 76 the get_mars_data function for retrieving EC data. 77 78 @Input: 79 <nothing> 80 81 @Return: 82 <nothing> 71 '''Controls the program to get data out of mars. 72 73 This is done if it is called directly from command line. 74 Then it also takes program call arguments and control file input. 75 76 Parameters 77 ---------- 78 79 Return 80 ------ 81 83 82 ''' 84 83 … … 97 96 98 97 def get_mars_data(c): 99 ''' 100 @Description: 101 Retrieves the EC data needed for a FLEXPART simulation. 102 Start and end dates for retrieval period is set. Retrievals 103 are divided into smaller periods if necessary and datechunk parameter 104 is set. 105 106 @Input: 107 c: instance of class ControlFile 108 Contains all the parameters of CONTROL file and 109 command line. 110 For more information about format and content of the parameter 111 see documentation. 112 113 @Return: 114 <nothing> 98 '''Retrieves the EC data needed for a FLEXPART simulation. 99 100 Start and end dates for retrieval period is set. Retrievals 101 are divided into smaller periods if necessary and datechunk parameter 102 is set. 103 104 Parameters 105 ---------- 106 c : :obj:`ControlFile` 107 Contains all the parameters of CONTROL file and 108 command line. 109 110 Return 111 ------ 112 115 113 ''' 116 114 … … 206 204 207 205 def do_retrievement(c, server, start, end, delta_t, fluxes=False): 208 ''' 209 @Description: 210 Divides the complete retrieval period in smaller chunks and 211 retrieves the data from MARS. 212 213 @Input: 214 c: instance of class ControlFile 215 Contains all the parameters of CONTROL file and 216 command line. 217 For more information about format and content of the parameter 218 see documentation. 219 220 server: instance of ECMWFService 221 The server connection to ECMWF 222 223 start: instance of datetime 224 The start date of the retrieval. 225 226 end: instance of datetime 227 The end date of the retrieval. 228 229 delta_t: instance of datetime 230 Delta_t +1 is the maximal time period of a single 231 retrieval. 232 233 fluxes: boolean, optional 234 Decides if the flux parameters are to be retrieved or 235 the rest of the parameter list. 236 Default value is False. 237 238 @Return: 239 <nothing> 206 '''Divides the complete retrieval period in smaller chunks and 207 retrieves the data from MARS. 208 209 Parameters 210 ---------- 211 c : :obj:`ControlFile` 212 Contains all the parameters of CONTROL file and 213 command line. 214 215 server : :obj:`ECMWFService` 216 The server connection to ECMWF. 217 218 start : :obj:`datetime` 219 The start date of the retrieval. 220 221 end : :obj:`datetime` 222 The end date of the retrieval. 223 224 delta_t : :obj:`datetime` 225 Delta_t + 1 is the maximal time period of a single 226 retrieval. 227 228 fluxes : :obj:`boolean`, optional 229 Decides if the flux parameters are to be retrieved or 230 the rest of the parameter list. 231 Default value is False. 232 233 Return 234 ------ 235 240 236 ''' 241 237 -
source/python/mods/prepare_flexpart.py
r70fee58 r274f9ef 79 79 # ------------------------------------------------------------------------------ 80 80 def main(): 81 ''' 82 @Description: 83 If prepare_flexpart is called from command line, this function controls 84 the program flow and calls the argumentparser function and 85 the prepare_flexpart function for preparation of GRIB data for FLEXPART. 81 '''Controls the program to prepare flexpart input files from mars data. 86 82 87 @Input:88 <nothing>83 This is done if it is called directly from command line. 84 Then it also takes program call arguments and control file input. 89 85 90 @Return: 91 <nothing> 86 Parameters 87 ---------- 88 89 Return 90 ------ 91 92 92 ''' 93 93 … … 105 105 106 106 def prepare_flexpart(ppid, c): 107 ''' 108 @Description: 109 Lists all grib files retrieved from MARS with get_mars_data and 110 uses prepares data for the use in FLEXPART. Specific data fields 111 are converted to a different grid and the flux data are going to be 112 disaggregated. The data fields are collected by hour and stored in 113 a file with a specific FLEXPART relevant naming convention. 107 '''Converts the mars data into flexpart ready input files. 114 108 115 @Input:116 ppid: int117 Contains the ppid number of the current ECMWF job. If it is called118 from this script, it is "None".109 Specific data fields are converted to a different grid and the flux 110 data are going to be disaggregated. The data fields are collected by 111 hour and stored in a file with a specific FLEXPART relevant naming 112 convention. 119 113 120 c: instance of class ControlFile121 Contains all the parameters of CONTROL file and122 command line.123 For more information about format and content of the parameter124 see documentation.114 Parameters 115 ---------- 116 ppid : :obj:`int` 117 Contains the ppid number of the current ECMWF job. It will be None if 118 the method was called within this module. 125 119 126 @Return: 127 <nothing> 120 c : :obj:`ControlFile` 121 Contains all the parameters of CONTROL file and 122 command line. 123 124 Return 125 ------ 126 128 127 ''' 129 128 -
source/python/mods/tools.py
r5bad6ec r274f9ef 61 61 62 62 def none_or_str(value): 63 ''' 64 @Description:65 Converts the input string into pythons None-type if the string 66 contains "None".67 68 @Input:69 value: string70 String to be checked for the "None" word. 71 72 @Return:73 74 75 63 '''Converts the input string into pythons None-type if the string 64 contains string "None". 65 66 Parameters 67 ---------- 68 value : :obj:`string` 69 String to be checked for the "None" word. 70 71 Return 72 ------ 73 None or value: 74 Return depends on the content of the input value. If it was "None", 75 then the python type None is returned. Otherwise the string itself. 76 76 ''' 77 77 if value == 'None': … … 80 80 81 81 def none_or_int(value): 82 ''' 83 @Description:84 Converts the input string into pythons None-type if the string 85 contains "None". Otherwise it is converted to an integer value.86 87 @Input:88 value: string89 String to be checked for the "None" word. 90 91 @Return:92 93 94 95 82 '''Converts the input string into pythons None-type if the string 83 contains string "None". Otherwise it is converted to an integer value. 84 85 Parameters 86 ---------- 87 value : :obj:`string` 88 String to be checked for the "None" word. 89 90 Return 91 ------ 92 None or int(value): 93 Return depends on the content of the input value. If it was "None", 94 then the python type None is returned. Otherwise the string is 95 converted into an integer value. 96 96 ''' 97 97 if value == 'None': … … 100 100 101 101 def get_cmdline_arguments(): 102 ''' 103 @Description: 104 Decomposes the command line arguments and assigns them to variables. 105 Apply default values for non mentioned arguments. 106 107 @Input: 108 <nothing> 109 110 @Return: 111 args: instance of ArgumentParser 112 Contains the commandline arguments from script/program call. 102 '''Decomposes the command line arguments and assigns them to variables. 103 Apply default values for non mentioned arguments. 104 105 Parameters 106 ---------- 107 108 Return 109 ------ 110 args : :obj:`Namespace` 111 Contains the commandline arguments from script/program call. 113 112 ''' 114 113 … … 190 189 191 190 def read_ecenv(filename): 192 ''' 193 @Description:194 Reads the file into a dictionary where the key values are the parameter 195 names.196 197 @Input:198 filename: string199 Path to file where the ECMWV environment parameters are stored. 200 201 @Return:202 envs: dict203 204 191 '''Reads the file into a dictionary where the key values are the parameter 192 names. 193 194 Parameters 195 ---------- 196 filename : :obj:`string` 197 Path to file where the ECMWF environment parameters are stored. 198 199 Return 200 ------ 201 envs : :obj:`dictionary` 202 Contains the environment parameter ecuid, ecgid, gateway 203 and destination for ECMWF server environments. 205 204 ''' 206 205 envs= {} … … 214 213 215 214 def clean_up(c): 216 ''' 217 @Description: 218 Remove all files from intermediate directory 219 (inputdir from CONTROL file). 220 221 @Input: 222 c: instance of class ControlFile 223 Contains all the parameters of CONTROL file and 224 command line. 225 For more information about format and content of the parameter 226 see documentation. 227 228 @Return: 229 <nothing> 215 '''Remove all files from intermediate directory (inputdir). 216 217 Parameters 218 ---------- 219 c : :obj:`ControlFile` 220 Contains all the parameters of CONTROL file and 221 command line. 222 223 Return 224 ------ 225 230 226 ''' 231 227 … … 245 241 246 242 def my_error(users, message='ERROR'): 247 ''' 248 @Description:249 Prints a specified error message which can be passed to the function 250 before exiting the program.251 252 @Input:253 user: list of strings254 Contains all email addresses which should be notified.255 It might also contain just the ecmwf user name which wil trigger256 mailing to the associated email address for this user. 257 258 message: string, optional259 Error message. Default value is "ERROR". 260 261 @Return:262 <nothing> 243 '''Prints a specified error message which can be passed to the function 244 before exiting the program. 245 246 Parameters 247 ---------- 248 user : :obj:`list` of :obj:`string` 249 Contains all email addresses which should be notified. 250 It might also contain just the ecmwf user name which wil trigger 251 mailing to the associated email address for this user. 252 253 message : :obj:`string`, optional 254 Error message. Default value is "ERROR". 255 256 Return 257 ------ 258 263 259 ''' 264 260 … … 291 287 292 288 def normal_exit(users, message='Done!'): 293 ''' 294 @Description: 295 Prints a specific exit message which can be passed to the function. 296 297 @Input: 298 user: list of strings 299 Contains all email addresses which should be notified. 300 It might also contain just the ecmwf user name which wil trigger 301 mailing to the associated email address for this user. 302 303 message: string, optional 304 Message for exiting program. Default value is "Done!". 305 306 @Return: 307 <nothing> 289 '''Prints a specific exit message which can be passed to the function. 290 291 Parameters 292 ---------- 293 user : :obj:`list` of :obj:`string` 294 Contains all email addresses which should be notified. 295 It might also contain just the ecmwf user name which wil trigger 296 mailing to the associated email address for this user. 297 298 message : :obj:`string`, optional 299 Message for exiting program. Default value is "Done!". 300 301 Return 302 ------ 308 303 309 304 ''' … … 333 328 334 329 def product(*args, **kwds): 335 ''' 336 @Description: 337 This method is taken from an example at the ECMWF wiki website. 338 https://software.ecmwf.int/wiki/display/GRIB/index.py; 2018-03-16 339 340 This method combines the single characters of the passed arguments 341 with each other. So that each character of each argument value 342 will be combined with each character of the other arguments as a tuple. 343 344 Example: 345 product('ABCD', 'xy') --> Ax Ay Bx By Cx Cy Dx Dy 346 product(range(2), repeat = 3) --> 000 001 010 011 100 101 110 111 347 348 @Input: 349 *args: tuple 350 Positional arguments (arbitrary number). 351 352 **kwds: dictionary 353 Contains all the keyword arguments from *args. 354 355 @Return: 356 prod: tuple 357 Return will be done with "yield". A tuple of combined arguments. 358 See example in description above. 330 '''This method combines the single characters of the passed arguments 331 with each other. So that each character of each argument value 332 will be combined with each character of the other arguments as a tuple. 333 334 Note 335 ---- 336 This method is taken from an example at the ECMWF wiki website. 337 https://software.ecmwf.int/wiki/display/GRIB/index.py; 2018-03-16 338 339 Example 340 ------- 341 product('ABCD', 'xy') --> Ax Ay Bx By Cx Cy Dx Dy 342 343 product(range(2), repeat = 3) --> 000 001 010 011 100 101 110 111 344 345 Parameters 346 ---------- 347 \*args : :obj:`tuple` 348 Positional arguments (arbitrary number). 349 350 \*\*kwds : :obj:`dictionary` 351 Contains all the keyword arguments from \*args. 352 353 Return 354 ------ 355 prod : :obj:`tuple` 356 Return will be done with "yield". A tuple of combined arguments. 357 See example in description above. 359 358 ''' 360 359 pools = map(tuple, args) * kwds.get('repeat', 1) … … 369 368 370 369 def silent_remove(filename): 371 ''' 372 @Description:373 Remove file if it exists. 374 The function does not fail if the file does not exist.375 376 @Input:377 filename: string378 The name of the file to be removed without notification. 379 380 @Return:381 <nothing> 370 '''Remove file if it exists. 371 The function does not fail if the file does not exist. 372 373 Parameters 374 ---------- 375 filename : :obj:`string` 376 The name of the file to be removed without notification. 377 378 Return 379 ------ 380 382 381 ''' 383 382 try: … … 392 391 393 392 def init128(filepath): 394 ''' 395 @Description: 396 Opens and reads the grib file with table 128 information.397 398 @Input:399 filepath: string400 Path to file of ECMWF grib table number 128. 401 402 @Return:403 table128: dictionary404 405 406 393 '''Opens and reads the grib file with table 128 information. 394 395 Parameters 396 ---------- 397 filepath : :obj:`string` 398 Path to file of ECMWF grib table number 128. 399 400 Return 401 ------ 402 table128 : :obj:`dictionary` 403 Contains the ECMWF grib table 128 information. 404 The key is the parameter number and the value is the 405 short name of the parameter. 407 406 ''' 408 407 table128 = dict() … … 417 416 418 417 def to_param_id(pars, table): 419 ''' 420 @Description: 421 Transform parameter names to parameter ids 422 with ECMWF grib table 128. 423 424 @Input: 425 pars: string 426 Addpar argument from CONTROL file in the format of 427 parameter names instead of ids. The parameter short 428 names are sepearted with "/" and they are passed as 429 one single string. 430 431 table: dictionary 432 Contains the ECMWF grib table 128 information. 433 The key is the parameter number and the value is the 434 short name of the parameter. 435 436 @Return: 437 ipar: list of integer 438 List of addpar parameters from CONTROL file transformed to 439 parameter ids in the format of integer. 418 '''Transform parameter names to parameter ids with ECMWF grib table 128. 419 420 Parameters 421 ---------- 422 pars : :obj:`string` 423 Addpar argument from CONTROL file in the format of 424 parameter names instead of ids. The parameter short 425 names are sepearted with "/" and they are passed as 426 one single string. 427 428 table : :obj:`dictionary` 429 Contains the ECMWF grib table 128 information. 430 The key is the parameter number and the value is the 431 short name of the parameter. 432 433 Return 434 ------ 435 ipar : :obj:`list` of :obj:`integer` 436 List of addpar parameters from CONTROL file transformed to 437 parameter ids in the format of integer. 440 438 ''' 441 439 cpar = pars.upper().split('/') … … 452 450 453 451 def get_list_as_string(list_obj, concatenate_sign=', '): 454 ''' 455 @Description: 456 Converts a list of arbitrary content into a single string.457 458 @Input:459 list_obj: list460 A list with arbitrary content. 461 462 concatenate_sign: string, optional463 A string which is used to concatenate the single464 list elements. Default value is ", ". 465 466 @Return:467 str_of_list: string468 452 '''Converts a list of arbitrary content into a single string. 453 454 Parameters 455 ---------- 456 list_obj : :obj:`list` 457 A list with arbitrary content. 458 459 concatenate_sign : :obj:`string`, optional 460 A string which is used to concatenate the single 461 list elements. Default value is ", ". 462 463 Return 464 ------ 465 str_of_list : :obj:`string` 466 The content of the list as a single string. 469 467 ''' 470 468 … … 474 472 475 473 def make_dir(directory): 476 ''' 477 @Description:478 Creates a directory and gives a warning if the directory 479 already exists. The program stops only if there is another problem.480 481 @Input:482 directory: string483 The directory name including the path which should be created. 484 485 @Return:486 <nothing> 474 '''Creates a directory and gives a warning if the directory 475 already exists. The program stops only if there is another problem. 476 477 Parameters 478 ---------- 479 directory : :obj:`string` 480 The directory name including the path which should be created. 481 482 Return 483 ------ 484 487 485 ''' 488 486 try: … … 498 496 499 497 def put_file_to_ecserver(ecd, filename, target, ecuid, ecgid): 500 ''' 501 @Description: 502 Uses the ecaccess-file-put command to send a file to the ECMWF servers. 503 504 NOTE: 505 The return value is just for testing reasons. It does not have 506 to be used from the calling function since the whole error handling 507 is done in here. 508 509 @Input: 510 ecd: string 511 The path were the file is stored. 512 513 filename: string 514 The name of the file to send to the ECMWF server. 515 516 target: string 517 The target queue where the file should be sent to. 518 519 ecuid: string 520 The user id on ECMWF server. 521 522 ecgid: string 523 The group id on ECMWF server. 524 525 @Return: 526 rcode: string 527 Resulting code of command execution. If successful the string 528 will be empty. 498 '''Uses the ecaccess-file-put command to send a file to the ECMWF servers. 499 500 Note 501 ---- 502 The return value is just for testing reasons. It does not have 503 to be used from the calling function since the whole error handling 504 is done in here. 505 506 Parameters 507 ---------- 508 ecd : :obj:`string` 509 The path were the file is stored. 510 511 filename : :obj:`string` 512 The name of the file to send to the ECMWF server. 513 514 target : :obj:`string` 515 The target queue where the file should be sent to. 516 517 ecuid : :obj:`string` 518 The user id on ECMWF server. 519 520 ecgid : :obj:`string` 521 The group id on ECMWF server. 522 523 Return 524 ------ 525 rcode : :obj:`string` 526 Resulting code of command execution. If successful the string 527 will be empty. 529 528 ''' 530 529 … … 546 545 547 546 def submit_job_to_ecserver(target, jobname): 548 ''' 549 @Description: 550 Uses ecaccess-job-submit command to submit a job to the ECMWF server. 551 552 NOTE: 553 The return value is just for testing reasons. It does not have 554 to be used from the calling function since the whole error handling 555 is done in here. 556 557 @Input: 558 target: string 559 The target where the file should be sent to, e.g. the queue. 560 561 jobname: string 562 The name of the jobfile to be submitted to the ECMWF server. 563 564 @Return: 565 rcode: string 566 Resulting code of command execution. If successful the string 567 will contain an integer number, representing the id of the job 568 at the ecmwf server. 547 '''Uses ecaccess-job-submit command to submit a job to the ECMWF server. 548 549 Note 550 ---- 551 The return value is just for testing reasons. It does not have 552 to be used from the calling function since the whole error handling 553 is done in here. 554 555 Parameters 556 ---------- 557 target : :obj:`string` 558 The target where the file should be sent to, e.g. the queue. 559 560 jobname : :obj:`string` 561 The name of the jobfile to be submitted to the ECMWF server. 562 563 Return 564 ------ 565 rcode : :obj:`string` 566 Resulting code of command execution. If successful the string 567 will contain an integer number, representing the id of the job 568 at the ecmwf server. 569 569 ''' 570 570 -
source/python/submit.py
r27fe969 r274f9ef 62 62 63 63 def main(): 64 ''' 65 @Description: 66 Get the arguments from script call and from CONTROL file. 67 Decides from the argument "queue" if the local version 68 is done "queue=None" or the gateway version with "queue=ecgate" 69 or "queue=cca". 64 '''Get the arguments from script call and from CONTROL file. 65 Decides from the argument "queue" if the local version 66 is done "queue=None" or the gateway version with "queue=ecgate" 67 or "queue=cca". 70 68 71 @Input:72 <nothing>69 Parameters 70 ---------- 73 71 74 @Return: 75 <nothing> 72 Return 73 ------ 74 76 75 ''' 77 76 … … 105 104 106 105 def submit(jtemplate, c, queue): 107 ''' 108 @Description: 109 Prepares the job script and submit it to the specified queue. 106 '''Prepares the job script and submit it to the specified queue. 110 107 111 @Input: 112 jtemplate: string 113 Job template file from sub-directory "_templates" for 114 submission to ECMWF. It contains all necessary 115 module and variable settings for the ECMWF environment as well as 116 the job call and mail report instructions. 117 Default is "job.temp". 108 Parameters 109 ---------- 110 jtemplate : :obj:`string` 111 Job template file from sub-directory "_templates" for 112 submission to ECMWF. It contains all necessary 113 module and variable settings for the ECMWF environment as well as 114 the job call and mail report instructions. 115 Default is "job.temp". 118 116 119 c: instance of class ControlFile 120 Contains all the parameters of CONTROL file and 121 command line. 122 For more information about format and content of the parameter 123 see documentation. 117 c : :obj:`ControlFile` 118 Contains all the parameters of CONTROL file and 119 command line. 124 120 125 queue: string126 121 queue : :obj:`string` 122 Name of queue for submission to ECMWF (e.g. ecgate or cca ) 127 123 128 @Return: 129 <nothing> 124 Return 125 ------ 126 130 127 ''' 131 128
Note: See TracChangeset
for help on using the changeset viewer.