Changeset 6f951ca in flex_extract.git for source/python/mods/tools.py
- Timestamp:
- Jan 15, 2019, 1:05:10 AM (5 years ago)
- Branches:
- master, ctbto, dev
- Children:
- d4696e0
- Parents:
- 2625ca8
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
source/python/mods/tools.py
rf2616a3 r6f951ca 14 14 # my_error, normal_exit, init128, to_param_id 15 15 # 16 # April 2018 - Anne Philipp (University of Vienna):16 # April - December 2018 - Anne Philipp (University of Vienna): 17 17 # - applied PEP8 style guide 18 18 # - added documentation 19 # - moved all functions from file Flexparttools to this file tools 20 # - added function get_list_as_string 19 # - moved all non class methods from former file Flexparttools in here 21 20 # - seperated args and control interpretation 21 # - added functions get_list_as_string, read_ecenv, send_mail, make_dir, 22 # put_file_to_ecserver, submit_job_to_ecserver, get_informations, 23 # get_dimensions, execute_subprocess, none_or_int, none_or_str 22 24 # 23 25 # @License: 24 # (C) Copyright 2014-2018. 26 # (C) Copyright 2014-2019. 27 # Anne Philipp, Leopold Haimberger 25 28 # 26 # This software is licensed under the terms of the Apache Licence Version 2.0 27 # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 29 # This work is licensed under the Creative Commons Attribution 4.0 30 # International License. To view a copy of this license, visit 31 # http://creativecommons.org/licenses/by/4.0/ or send a letter to 32 # Creative Commons, PO Box 1866, Mountain View, CA 94042, USA. 28 33 # 29 # @Modul Description: 30 # This module contains a couple of helpful functions which are 31 # used in different places in flex_extract. 32 # 33 # @Module Content: 34 # - get_cmdline_args 35 # - clean_up 36 # - my_error 37 # - normal_exit 38 # - product 39 # - silent_remove 40 # - init128 41 # - to_param_id 42 # - get_list_as_string 43 # - make_dir 44 # 34 # @Methods: 35 # none_or_str 36 # none_or_int 37 # get_cmdline_args 38 # read_ecenv 39 # clean_up 40 # my_error 41 # send_mail 42 # normal_exit 43 # product 44 # silent_remove 45 # init128 46 # to_param_id 47 # get_list_as_string 48 # make_dir 49 # put_file_to_ecserver 50 # submit_job_to_ecserver 51 # get_informations 52 # get_dimensions 53 # execute_subprocess 45 54 #******************************************************************************* 55 '''This module contains a collection of diverse tasks within flex_extract. 56 ''' 46 57 47 58 # ------------------------------------------------------------------------------ … … 59 70 60 71 # ------------------------------------------------------------------------------ 61 # FUNCTIONS72 # METHODS 62 73 # ------------------------------------------------------------------------------ 63 74 … … 68 79 Parameters 69 80 ---------- 70 value : :obj:`string`81 value : str 71 82 String to be checked for the "None" word. 72 83 … … 87 98 Parameters 88 99 ---------- 89 value : :obj:`string`100 value : str 90 101 String to be checked for the "None" word. 91 102 … … 110 121 Return 111 122 ------ 112 args : :obj:`Namespace`123 args : Namespace 113 124 Contains the commandline arguments from script/program call. 114 125 ''' … … 201 212 Parameters 202 213 ---------- 203 filepath : :obj:`string`214 filepath : str 204 215 Path to file where the ECMWF environment parameters are stored. 205 216 206 217 Return 207 218 ------ 208 envs : :obj:`dictionary`219 envs : dict 209 220 Contains the environment parameter ecuid, ecgid, gateway 210 221 and destination for ECMWF server environments. … … 233 244 Parameters 234 245 ---------- 235 c : :obj:`ControlFile`246 c : ControlFile 236 247 Contains all the parameters of CONTROL file and 237 248 command line. … … 265 276 Parameters 266 277 ---------- 267 user : :obj:`list` of :obj:`string`278 user : list of str 268 279 Contains all email addresses which should be notified. 269 280 It might also contain just the ecmwf user name which wil trigger 270 281 mailing to the associated email address for this user. 271 282 272 message : :obj:`string`, optional283 message : str, optional 273 284 Error message. Default value is "ERROR". 274 285 … … 295 306 Parameters 296 307 ---------- 297 users : :obj:`list` of :obj:`string`308 users : list of str 298 309 Contains all email addresses which should be notified. 299 310 It might also contain just the ecmwf user name which wil trigger 300 311 mailing to the associated email address for this user. 301 312 302 success_mode : :obj:``string`313 success_mode : str 303 314 States the exit mode of the program to put into 304 315 the mail subject line. 305 316 306 message : :obj:`string`, optional317 message : str, optional 307 318 Message for exiting program. Default value is "Done!". 308 319 … … 341 352 Parameters 342 353 ---------- 343 message : :obj:`string`, optional354 message : str, optional 344 355 Message for exiting program. Default value is "Done!". 345 356 … … 374 385 Parameters 375 386 ---------- 376 \*args : :obj:`list` or :obj:`string`387 \*args : list or str 377 388 Positional arguments (arbitrary number). 378 389 379 \*\*kwds : :obj:`dictionary`390 \*\*kwds : dict 380 391 Contains all the keyword arguments from \*args. 381 392 … … 405 416 Parameters 406 417 ---------- 407 filename : :obj:`string`418 filename : str 408 419 The name of the file to be removed without notification. 409 420 … … 429 440 Parameters 430 441 ---------- 431 filepath : :obj:`string`442 filepath : str 432 443 Path to file of ECMWF grib table number 128. 433 444 434 445 Return 435 446 ------ 436 table128 : :obj:`dictionary`447 table128 : dict 437 448 Contains the ECMWF grib table 128 information. 438 449 The key is the parameter number and the value is the … … 462 473 Parameters 463 474 ---------- 464 pars : :obj:`string`475 pars : str 465 476 Addpar argument from CONTROL file in the format of 466 477 parameter names instead of ids. The parameter short … … 468 479 one single string. 469 480 470 table : :obj:`dictionary`481 table : dict 471 482 Contains the ECMWF grib table 128 information. 472 483 The key is the parameter number and the value is the … … 475 486 Return 476 487 ------ 477 ipar : :obj:`list` of :obj:`integer`488 ipar : list of int 478 489 List of addpar parameters from CONTROL file transformed to 479 490 parameter ids in the format of integer. … … 501 512 Parameters 502 513 ---------- 503 list_obj : :obj:`list`514 list_obj : list of * 504 515 A list with arbitrary content. 505 516 506 concatenate_sign : :obj:`string`, optional517 concatenate_sign : str, optional 507 518 A string which is used to concatenate the single 508 519 list elements. Default value is ", ". … … 510 521 Return 511 522 ------ 512 str_of_list : :obj:`string`523 str_of_list : str 513 524 The content of the list as a single string. 514 525 ''' … … 528 539 Parameters 529 540 ---------- 530 directory : :obj:`string`541 directory : str 531 542 The path to directory which should be created. 532 543 … … 557 568 Parameters 558 569 ---------- 559 ecd : :obj:`string`570 ecd : str 560 571 The path were the file is stored. 561 572 562 filename : :obj:`string`573 filename : str 563 574 The name of the file to send to the ECMWF server. 564 575 565 target : :obj:`string`576 target : str 566 577 The target queue where the file should be sent to. 567 578 568 ecuid : :obj:`string`579 ecuid : str 569 580 The user id on ECMWF server. 570 581 571 ecgid : :obj:`string`582 ecgid : str 572 583 The group id on ECMWF server. 573 584 … … 610 621 Parameters 611 622 ---------- 612 target : :obj:`string`623 target : str 613 624 The target where the file should be sent to, e.g. the queue. 614 625 615 jobname : :obj:`string`626 jobname : str 616 627 The name of the jobfile to be submitted to the ECMWF server. 617 628 618 629 Return 619 630 ------ 620 job_id : :obj:`int`631 job_id : int 621 632 The id number of the job as a reference at the ecmwf server. 622 633 ''' … … 650 661 Parameters 651 662 ---------- 652 filename : :obj:`string`663 filename : str 653 664 Name of the file which will be opened to extract basic information. 654 665 655 666 Return 656 667 ------ 657 data : :obj:`dictionary`668 data : dict 658 669 Contains basic informations of the ECMWF grib files, e.g. 659 670 'Ni', 'Nj', 'latitudeOfFirstGridPointInDegrees', … … 702 713 Parameters 703 714 ---------- 704 info : :obj:`dictionary`715 info : dict 705 716 Contains basic informations of the ECMWF grib files, e.g. 706 717 'Ni', 'Nj', 'latitudeOfFirstGridPointInDegrees', … … 709 720 'iDirectionIncrementInDegrees', 'missingValue' 710 721 711 purefc : :obj:`integer`722 purefc : int 712 723 Switch for definition of pure forecast mode or not. 713 724 714 dtime : :obj:`string`725 dtime : str 715 726 Time step in hours. 716 727 717 index_vals : :obj:`list`728 index_vals : list of list of str 718 729 Contains the values from the keys used for a distinct selection 719 730 of grib messages in processing the grib files. … … 723 734 index_vals[2]: ('0', '12', '3', '6', '9') ; stepRange 724 735 725 start_date : :obj:`string`736 start_date : str 726 737 The start date of the retrieval job. 727 738 728 end_date : :obj:`string`739 end_date : str 729 740 The end date of the retrieval job. 730 741 731 742 Return 732 743 ------ 733 (ix, jy, it) : :obj:`tuple` of :obj:`integer`744 (ix, jy, it) : tuple of int 734 745 Dimension in x-direction, y-direction and in time. 735 746 ''' … … 755 766 Parameters 756 767 ---------- 757 cmd_list : :obj:`list` of `:obj:`string`768 cmd_list : list of str 758 769 A list of the components for the command line execution. Each 759 770 list entry is a single part of the command which is seperated from … … 763 774 Return 764 775 ------ 765 error_msg : :obj:`string`, optional776 error_msg : str, optional 766 777 The possible error message if the subprocess failed. 767 778 By default it will just tell "SUBPROCESS FAILED!".
Note: See TracChangeset
for help on using the changeset viewer.