Changeset 274f9ef in flex_extract.git for source/python/classes/EcFlexpart.py


Ignore:
Timestamp:
Oct 22, 2018, 11:44:47 AM (6 years ago)
Author:
Anne Philipp <anne.philipp@…>
Branches:
master, ctbto, dev
Children:
db27c09
Parents:
708c667
Message:

Converted docstrings to numpy style and build first structure for sphinxdocumentation (incl API)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • source/python/classes/EcFlexpart.py

    r0934db1 r274f9ef  
    111111    # --------------------------------------------------------------------------
    112112    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
    135130        '''
    136131        # set a counter for the number of mars requests generated
     
    306301
    307302    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: string
    315                 Shortcut name of the type of the field. E.g. AN, FC, PF, ...
    316 
    317             param: string
    318                 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: string
    322                 The date period of the grib data to be stored in this file.
    323 
    324         @Return:
    325             targetname: string
    326                 The target filename for the grib data.
     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.
    327322        '''
    328323        targetname = (self.inputdir + '/' + ftype + param + '.' + date + '.' +
     
    333328
    334329    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
    359351        '''
    360352        # increase number of mars requests
     
    398390
    399391    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: dictionary
    407                 List of parameter names which serves as index.
    408 
    409             inputfiles: instance of UioFiles
    410                 Contains a list of files.
    411 
    412         @Return:
    413             iid: grib_index
    414                 This is a grib specific index structure to access
    415                 messages in a file.
    416 
    417             index_vals: list
    418                 Contains the values from the keys used for a distinct selection
    419                 of grib messages in processing  the grib files.
    420                 Content looks like e.g.:
    421                 index_vals[0]: ('20171106', '20171107', '20171108') ; date
    422                 index_vals[1]: ('0', '1200', '1800', '600') ; time
    423                 index_vals[2]: ('0', '12', '3', '6', '9') ; stepRange
     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
    424416        '''
    425417        iid = None
     
    455447
    456448    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
    491480        '''
    492481        self.dates = dates
     
    665654
    666655    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`
    685668                Name of the namelist file.
    686669
    687         @Return:
    688             <nothing>
     670        Return
     671        ------
     672
    689673        '''
    690674
     
    734718
    735719    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
    759738        '''
    760739
     
    952931
    953932    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
    983959        '''
    984960
     
    11831159
    11841160    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        ------
    12081178
    12091179        '''
     
    12471217
    12481218    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
    12631230        '''
    12641231        # generate AVAILABLE file
Note: See TracChangeset for help on using the changeset viewer.
hosted by ZAMG