Changeset 6f951ca in flex_extract.git for source/python/mods/checks.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/checks.py

    rf2616a3 r6f951ca  
    11#!/usr/bin/env python
    22# -*- coding: utf-8 -*-
    3 ##*******************************************************************************
     3#*******************************************************************************
    44# @Author: Anne Philipp (University of Vienna)
    55#
     
    99#
    1010# @License:
    11 #    (C) Copyright 2014-2018.
     11#    (C) Copyright 2014-2019.
     12#    Anne Philipp, Leopold Haimberger
    1213#
    13 #    This software is licensed under the terms of the Apache Licence Version 2.0
    14 #    which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
    15 #
    16 # @Modul Description:
    17 #
    18 #
    19 # @Module Content:
    20 
    21 #
     14#    This work is licensed under the Creative Commons Attribution 4.0
     15#    International License. To view a copy of this license, visit
     16#    http://creativecommons.org/licenses/by/4.0/ or send a letter to
     17#    Creative Commons, PO Box 1866, Mountain View, CA 94042, USA.
    2218#*******************************************************************************
     19'''This module contains check methods for the CONTROL paramaters.
     20'''
    2321
    2422# ------------------------------------------------------------------------------
     
    2725
    2826import os
     27import sys
    2928import _config
    3029import exceptions
     
    4039    Parameters
    4140    ----------
    42     c : :obj:`ControlFile`
     41    c : ControlFile
    4342        Contains all the parameters of CONTROL file and
    4443        command line.
    4544
    46     logicals : :obj:`list` of (:obj:`string` or :obj:`integer`)
     45    logicals : list of (str or int)
    4746        Names of the switches that are used to control the flow of the
    4847        program.
     
    6766    Parameters
    6867    ----------
    69     grid : :obj:`string`
     68    grid : str
    7069        Contains grid information
    7170
    7271    Return
    7372    ------
    74     grid : :obj:``string`
     73    grid : str
    7574        Contains grid in format Lat/lon. E.g. 0.1/0.1
    7675    '''
     
    108107    Parameters
    109108    ----------
    110     grid : :obj:`string`
     109    grid : str
    111110        Contains grid information.
    112111
    113     area : :obj:`string`
     112    area : str
    114113        Contains area informtion.
    115114
    116     upper : :obj:`string`
     115    upper : str
    117116        The northern most latitude.
    118117
    119     lower : :obj:`string`
     118    lower : str
    120119        The souther most latitude.
    121120
    122     left : :obj:`string`
     121    left : str
    123122        The western most longitude.
    124123
    125     right : :obj:`string`
     124    right : str
    126125        The eastern most longiude.
    127126
    128127    Return
    129128    ------
    130     grid : :obj:``string`
     129    grid : str
    131130        Contains grid in format Lat/lon. E.g. 0.1/0.1
    132131    '''
     
    173172    Parameters
    174173    ----------
    175     levelist : :obj:`string`
     174    levelist : str
    176175        Specifies the level list.
    177176        Examples: model level: 1/to/137, pressure levels: 500/to/1000
    178177
    179     level : :obj:`string`
     178    level : str
    180179        Specifies the maximum level.
    181180
    182181    Return
    183182    ------
    184     levelist : :obj:`string`
     183    levelist : str
    185184        Specifies the required levels. It has to have a valid
    186185        correspondence to the selected levtype.
    187186        Examples: model level: 1/to/137, pressure levels: 500/to/1000
    188187
    189     level : :obj:`string`
     188    level : str
    190189        Specifies the maximum level. It has to be one of the
    191190        available maximum level number as contained in the variable
     
    221220    Parameters
    222221    ----------
    223     c : :obj:`ControlFile`
     222    c : ControlFile
    224223            Contains all the parameters of CONTROL file and
    225224            command line.
    226225
    227     ppid : :obj:`int` or :obj:`None`
     226    ppid : int or None
    228227        Contains the ppid number provided by the command line parameter
    229228        of is None otherwise.
     
    247246    Parameters
    248247    ----------
    249     ftype : :obj:`list` of :obj:`string`
     248    ftype : list of str
    250249        List of field types.
    251250
     
    273272    Parameters
    274273    ----------
    275     step : :obj:`list` of :obj:`string` or :obj:`string`
     274    step : list of str or str
    276275        Specifies the forecast time step from forecast base time.
    277276        Valid values are hours (HH) from forecast base time.
    278277
    279     mailfail : :obj:`list` of :obj:``string`
     278    mailfail : list of str
    280279        Contains all email addresses which should be notified.
    281280        It might also contain just the ecmwf user name which will trigger
     
    284283    Return
    285284    ------
    286     step : :obj:`list` of :obj:`string`
     285    step : list of str
    287286        List of forecast steps in format e.g. [001, 002, ...]
    288287    '''
     
    313312    Parameters
    314313    ----------
    315     ftype : :obj:`list` of :obj:`string` or :obj:`string`
     314    ftype : list of str or str
    316315        List of field types.
    317316
    318     steps : :obj:`string`
     317    steps : str
    319318        Specifies the forecast time step from forecast base time.
    320319        Valid values are hours (HH) from forecast base time.
     
    322321    Return
    323322    ------
    324     ftype : :obj:`list` of :obj:`string`
     323    ftype : list of str
    325324        List of field types.
    326325    '''
     
    340339    Parameters
    341340    ----------
    342     ftime : :obj:`list` of :obj:`string` or :obj:`string`
     341    ftime : list of str or str
    343342        The time in hours of the field.
    344343
    345344    Return
    346345    ------
    347     ftime : :obj:`list` of :obj:`string`
     346    ftime : list of str
    348347        The time in hours of the field.
    349348    '''
     
    358357    Parameters
    359358    ----------
    360     ftype : :obj:`list` of :obj:`string`
     359    ftype : list of str
    361360        List of field types.
    362361
    363     ftime : :obj:`list` of :obj:`string` or :obj:`string`
     362    ftime : list of str or str
    364363        The time in hours of the field.
    365364
    366     steps : :obj:`string`
     365    steps : str
    367366        Specifies the forecast time step from forecast base time.
    368367        Valid values are hours (HH) from forecast base time.
    369368
    370     maxstep : :obj:`integer`
     369    maxstep : int
    371370        The maximum forecast time step in hours from the forecast base time.
    372371        This is the maximum step for non flux (accumulated) forecast data.
    373372
    374     purefc : :obj:`integer`
     373    purefc : int
    375374        Switch for definition of pure forecast mode or not.
    376375
    377376    Return
    378377    ------
    379     ftype : :obj:`list` of :obj:`string`
     378    ftype : list of str
    380379        List of field types.
    381380
    382     ftime : :obj:`list` of :obj:`string`
     381    ftime : list of str
    383382        The time in hours of the field.
    384383
    385     steps : :obj:`string`
     384    steps : str
    386385        Specifies the forecast time step from forecast base time.
    387386        Valid values are hours (HH) from forecast base time.
     
    410409    Parameters
    411410    ----------
    412     mail : :obj:`list` of :obj:`string` or :obj:`string`
     411    mail : list of str or str
    413412        Contains email addresses for notifications.
    414413        It might also contain just the ecmwf user name which will trigger
     
    417416    Return
    418417    ------
    419     mail : :obj:`list` of :obj:``string`
     418    mail : list of str
    420419        Contains email addresses for notifications.
    421420        It might also contain just the ecmwf user name which will trigger
     
    439438    Parameters
    440439    ----------
    441     queue : :obj:`string`
     440    queue : str
    442441        Name of the queue if submitted to the ECMWF servers.
    443442        Used to check if ecuid, ecgid, gateway and destination
    444443        are set correctly and are not empty.
    445444
    446     gateway : :obj:`string`
     445    gateway : str
    447446        The address of the gateway server.
    448447
    449     destination : :obj:`string`
     448    destination : str
    450449        The name of the destination of the gateway server for data
    451450        transfer through ectrans. E.g. name@genericSftp
    452451
    453     ecuid : :obj:`string`
     452    ecuid : str
    454453        ECMWF user id.
    455454
    456     ecgid : :obj:`string`
     455    ecgid : str
    457456        ECMWF group id.
    458457
     
    475474    Parameters
    476475    ----------
    477     idir : :obj:`string`
     476    idir : str
    478477        Path to the temporary directory for MARS retrieval data.
    479478
    480     odir : :obj:`string`
     479    odir : str
    481480        Path to the final output directory where the FLEXPART input files
    482481        will be stored.
    483482
    484     fpdir : :obj:`string`
     483    fpdir : str
    485484        Path to FLEXPART root directory.
    486485
    487     fedir : :obj:`string`
     486    fedir : str
    488487        Path to flex_extract root directory.
    489488
    490489    Return
    491490    ------
    492     odir : :obj:`string`
     491    odir : str
    493492        Path to the final output directory where the FLEXPART input files
    494493        will be stored.
    495494
    496     fpdir : :obj:`string`
     495    fpdir : str
    497496        Path to FLEXPART root directory.
    498497
     
    513512    Parameters
    514513    ----------
    515     start : :obj:`string`
     514    start : str
    516515        The start date of the retrieval job.
    517516
    518     end : :obj:`string`
     517    end : str
    519518        The end date of the retrieval job.
    520519
    521520    Return
    522521    ------
    523     start : :obj:`string`
     522    start : str
    524523        The start date of the retrieval job.
    525524
    526     end : :obj:`string`
     525    end : str
    527526        The end date of the retrieval job.
    528527
     
    555554    Parameters
    556555    ----------
    557     maxstep : :obj:`string`
     556    maxstep : str
    558557        The maximum forecast time step in hours from the forecast base time.
    559558        This is the maximum step for non flux (accumulated) forecast data.
    560559
    561     steps : :obj:`string`
     560    steps : str
    562561        Specifies the forecast time step from forecast base time.
    563562        Valid values are hours (HH) from forecast base time.
     
    565564    Return
    566565    ------
    567     maxstep : :obj:`integer`
     566    maxstep : int
    568567        The maximum forecast time step in hours from the forecast base time.
    569568        This is the maximum step for non flux (accumulated) forecast data.
     
    588587    Parameters
    589588    ----------
    590     basetime : :obj:``
     589    basetime : str
    591590        The time for a half day retrieval. The 12 hours upfront are to be
    592591        retrieved.
     
    607606    Parameters
    608607    ----------
    609     request : :obj:`integer`
     608    request : int
    610609        Selects the mode of retrieval.
    611610        0: Retrieves the data from ECMWF.
     
    613612        2: Retrieves the data and prints the mars request.
    614613
    615     marsfile : :obj:`string`
     614    marsfile : str
    616615        Path to the mars request file.
    617616
     
    631630    Parameters
    632631    ----------
    633     public : :obj:`ìnteger`
     632    public : int
    634633        Specifies if public data are to be retrieved or not.
    635634
    636     dataset : :obj:`string`
     635    dataset : str
    637636        Specific name which identifies the public dataset.
    638637
     
    653652    Parameters
    654653    ----------
    655     acctype : :obj:`string`
     654    acctype : str
    656655        The field type for the accumulated forecast fields.
    657656
    658     ftype : :obj:`list` of :obj:`string`
     657    ftype : list of str
    659658        List of field types.
    660659
    661660    Return
    662661    ------
    663     acctype : :obj:`string`
     662    acctype : str
    664663        The field type for the accumulated forecast fields.
    665664    '''
     
    690689    Parameters
    691690    ----------
    692     acctime : :obj:`string`
     691    acctime : str
    693692        The starting time from the accumulated forecasts.
    694693
    695     acctype : :obj:`string`
     694    acctype : str
    696695        The field type for the accumulated forecast fields.
    697696
    698     purefc : :obj:`integer`
     697    purefc : int
    699698        Switch for definition of pure forecast mode or not.
    700699
    701700    Return
    702701    ------
    703     acctime : :obj:`string`
     702    acctime : str
    704703        The starting time from the accumulated forecasts.
    705704    '''
    706705    if not acctime:
    707706        print('... Control parameter ACCTIME was not defined.')
    708         print('... Value will be set depending on field type: '
     707        print('... Value will be set depending on field type:\n '
    709708              '\t\t EA=06/18\n\t\t EI/OD=00/12\n\t\t  EP=18')
    710709        if acctype.upper() == 'EA': # Era 5
     
    726725    Parameters
    727726    ----------
    728     accmaxstep : :obj:`string`
     727    accmaxstep : str
    729728        The maximum forecast step for the accumulated forecast fields.
    730729
    731     acctype : :obj:`string`
     730    acctype : str
    732731        The field type for the accumulated forecast fields.
    733732
    734     purefc : :obj:`integer`
     733    purefc : int
    735734        Switch for definition of pure forecast mode or not.
    736735
    737     maxstep : :obj:`string`
     736    maxstep : str
    738737        The maximum forecast time step in hours from the forecast base time.
    739738        This is the maximum step for non flux (accumulated) forecast data.
     
    741740    Return
    742741    ------
    743     accmaxstep : :obj:`string`
     742    accmaxstep : str
    744743        The maximum forecast step for the accumulated forecast fields.
    745744    '''
     
    776775    Parameters
    777776    ----------
    778     addpar : :obj:`string` or :obj:'list' of :obj:'string'
     777    addpar : str or list of str
    779778        List of additional parameters to be retrieved.
    780779
    781780    Return
    782781    ------
    783     addpar : :obj:'string'
     782    addpar : str
    784783        List of additional parameters to be retrieved.
    785784    '''
     
    798797
    799798def check_job_chunk(job_chunk):
    800     '''Checks that the job chunk number is positive and non zero.
    801 
    802     Parameters
    803     ----------
    804     job_chunk : :obj:`integer`
     799    '''Checks that if job chunk is set, the number is positive and non zero.
     800
     801    Parameters
     802    ----------
     803    job_chunk : int
    805804        The number of days for a single job script.
    806805
    807806    Return
    808807    ------
    809     job_chunk : :obj:`integer`
     808    job_chunk : int
    810809        The number of days for a single job script.
    811810    '''
     811    if not job_chunk:
     812        return job_chunk
     813
    812814    if job_chunk < 0:
    813815        raise ValueError('ERROR: The number of job chunk is negative!\n'
Note: See TracChangeset for help on using the changeset viewer.
hosted by ZAMG