Changeset 6f951ca in flex_extract.git for source/python/mods/tools.py


Ignore:
Timestamp:
Jan 15, 2019, 1:05:10 AM (5 years ago)
Author:
Anne Philipp <anne.philipp@…>
Branches:
master, ctbto, dev
Children:
d4696e0
Parents:
2625ca8
Message:

new style of docstring params and updates in docstrings

File:
1 edited

Legend:

Unmodified
Added
Removed
  • source/python/mods/tools.py

    rf2616a3 r6f951ca  
    1414#          my_error, normal_exit, init128, to_param_id
    1515#
    16 #    April 2018 - Anne Philipp (University of Vienna):
     16#    April - December 2018 - Anne Philipp (University of Vienna):
    1717#        - applied PEP8 style guide
    1818#        - 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
    2120#        - 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
    2224#
    2325# @License:
    24 #    (C) Copyright 2014-2018.
     26#    (C) Copyright 2014-2019.
     27#    Anne Philipp, Leopold Haimberger
    2528#
    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.
    2833#
    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
    4554#*******************************************************************************
     55'''This module contains a collection of diverse tasks within flex_extract.
     56'''
    4657
    4758# ------------------------------------------------------------------------------
     
    5970
    6071# ------------------------------------------------------------------------------
    61 # FUNCTIONS
     72# METHODS
    6273# ------------------------------------------------------------------------------
    6374
     
    6879    Parameters
    6980    ----------
    70     value : :obj:`string`
     81    value : str
    7182        String to be checked for the "None" word.
    7283
     
    8798    Parameters
    8899    ----------
    89     value : :obj:`string`
     100    value : str
    90101        String to be checked for the "None" word.
    91102
     
    110121    Return
    111122    ------
    112     args : :obj:`Namespace`
     123    args : Namespace
    113124        Contains the commandline arguments from script/program call.
    114125    '''
     
    201212    Parameters
    202213    ----------
    203     filepath : :obj:`string`
     214    filepath : str
    204215        Path to file where the ECMWF environment parameters are stored.
    205216
    206217    Return
    207218    ------
    208     envs : :obj:`dictionary`
     219    envs : dict
    209220        Contains the environment parameter ecuid, ecgid, gateway
    210221        and destination for ECMWF server environments.
     
    233244    Parameters
    234245    ----------
    235     c : :obj:`ControlFile`
     246    c : ControlFile
    236247        Contains all the parameters of CONTROL file and
    237248        command line.
     
    265276    Parameters
    266277    ----------
    267     user : :obj:`list` of :obj:`string`
     278    user : list of str
    268279        Contains all email addresses which should be notified.
    269280        It might also contain just the ecmwf user name which wil trigger
    270281        mailing to the associated email address for this user.
    271282
    272     message : :obj:`string`, optional
     283    message : str, optional
    273284        Error message. Default value is "ERROR".
    274285
     
    295306    Parameters
    296307    ----------
    297     users : :obj:`list` of :obj:`string`
     308    users : list of str
    298309        Contains all email addresses which should be notified.
    299310        It might also contain just the ecmwf user name which wil trigger
    300311        mailing to the associated email address for this user.
    301312
    302     success_mode : :obj:``string`
     313    success_mode : str
    303314        States the exit mode of the program to put into
    304315        the mail subject line.
    305316
    306     message : :obj:`string`, optional
     317    message : str, optional
    307318        Message for exiting program. Default value is "Done!".
    308319
     
    341352    Parameters
    342353    ----------
    343     message : :obj:`string`, optional
     354    message : str, optional
    344355        Message for exiting program. Default value is "Done!".
    345356
     
    374385    Parameters
    375386    ----------
    376     \*args : :obj:`list` or :obj:`string`
     387    \*args : list or str
    377388        Positional arguments (arbitrary number).
    378389
    379     \*\*kwds : :obj:`dictionary`
     390    \*\*kwds : dict
    380391        Contains all the keyword arguments from \*args.
    381392
     
    405416    Parameters
    406417    ----------
    407     filename : :obj:`string`
     418    filename : str
    408419        The name of the file to be removed without notification.
    409420
     
    429440    Parameters
    430441    ----------
    431     filepath : :obj:`string`
     442    filepath : str
    432443        Path to file of ECMWF grib table number 128.
    433444
    434445    Return
    435446    ------
    436     table128 : :obj:`dictionary`
     447    table128 : dict
    437448        Contains the ECMWF grib table 128 information.
    438449        The key is the parameter number and the value is the
     
    462473    Parameters
    463474    ----------
    464     pars : :obj:`string`
     475    pars : str
    465476        Addpar argument from CONTROL file in the format of
    466477        parameter names instead of ids. The parameter short
     
    468479        one single string.
    469480
    470     table : :obj:`dictionary`
     481    table : dict
    471482        Contains the ECMWF grib table 128 information.
    472483        The key is the parameter number and the value is the
     
    475486    Return
    476487    ------
    477     ipar : :obj:`list` of :obj:`integer`
     488    ipar : list of int
    478489        List of addpar parameters from CONTROL file transformed to
    479490        parameter ids in the format of integer.
     
    501512    Parameters
    502513    ----------
    503     list_obj : :obj:`list`
     514    list_obj : list of *
    504515        A list with arbitrary content.
    505516
    506     concatenate_sign : :obj:`string`, optional
     517    concatenate_sign : str, optional
    507518        A string which is used to concatenate the single
    508519        list elements. Default value is ", ".
     
    510521    Return
    511522    ------
    512     str_of_list : :obj:`string`
     523    str_of_list : str
    513524        The content of the list as a single string.
    514525    '''
     
    528539    Parameters
    529540    ----------
    530     directory : :obj:`string`
     541    directory : str
    531542        The path to directory which should be created.
    532543
     
    557568    Parameters
    558569    ----------
    559     ecd : :obj:`string`
     570    ecd : str
    560571        The path were the file is stored.
    561572
    562     filename : :obj:`string`
     573    filename : str
    563574        The name of the file to send to the ECMWF server.
    564575
    565     target : :obj:`string`
     576    target : str
    566577        The target queue where the file should be sent to.
    567578
    568     ecuid : :obj:`string`
     579    ecuid : str
    569580        The user id on ECMWF server.
    570581
    571     ecgid : :obj:`string`
     582    ecgid : str
    572583        The group id on ECMWF server.
    573584
     
    610621    Parameters
    611622    ----------
    612     target : :obj:`string`
     623    target : str
    613624        The target where the file should be sent to, e.g. the queue.
    614625
    615     jobname : :obj:`string`
     626    jobname : str
    616627        The name of the jobfile to be submitted to the ECMWF server.
    617628
    618629    Return
    619630    ------
    620     job_id : :obj:`int`
     631    job_id : int
    621632        The id number of the job as a reference at the ecmwf server.
    622633    '''
     
    650661    Parameters
    651662    ----------
    652     filename : :obj:`string`
     663    filename : str
    653664            Name of the file which will be opened to extract basic information.
    654665
    655666    Return
    656667    ------
    657     data : :obj:`dictionary`
     668    data : dict
    658669        Contains basic informations of the ECMWF grib files, e.g.
    659670        'Ni', 'Nj', 'latitudeOfFirstGridPointInDegrees',
     
    702713    Parameters
    703714    ----------
    704     info : :obj:`dictionary`
     715    info : dict
    705716        Contains basic informations of the ECMWF grib files, e.g.
    706717        'Ni', 'Nj', 'latitudeOfFirstGridPointInDegrees',
     
    709720        'iDirectionIncrementInDegrees', 'missingValue'
    710721
    711     purefc : :obj:`integer`
     722    purefc : int
    712723        Switch for definition of pure forecast mode or not.
    713724
    714     dtime : :obj:`string`
     725    dtime : str
    715726        Time step in hours.
    716727
    717     index_vals : :obj:`list`
     728    index_vals : list of list of str
    718729        Contains the values from the keys used for a distinct selection
    719730        of grib messages in processing  the grib files.
     
    723734        index_vals[2]: ('0', '12', '3', '6', '9') ; stepRange
    724735
    725     start_date : :obj:`string`
     736    start_date : str
    726737        The start date of the retrieval job.
    727738
    728     end_date : :obj:`string`
     739    end_date : str
    729740        The end date of the retrieval job.
    730741
    731742    Return
    732743    ------
    733     (ix, jy, it) : :obj:`tuple` of :obj:`integer`
     744    (ix, jy, it) : tuple of int
    734745        Dimension in x-direction, y-direction and in time.
    735746    '''
     
    755766    Parameters
    756767    ----------
    757     cmd_list : :obj:`list` of `:obj:`string`
     768    cmd_list : list of str
    758769        A list of the components for the command line execution. Each
    759770        list entry is a single part of the command which is seperated from
     
    763774    Return
    764775    ------
    765     error_msg : :obj:`string`, optional
     776    error_msg : str, optional
    766777        The possible error message if the subprocess failed.
    767778        By default it will just tell "SUBPROCESS FAILED!".
Note: See TracChangeset for help on using the changeset viewer.
hosted by ZAMG