Changeset 2625ca8 in flex_extract.git


Ignore:
Timestamp:
Jan 15, 2019, 1:03:37 AM (2 months ago)
Author:
Anne Philipp <anne.philipp@…>
Branches:
dev
Children:
6f951ca
Parents:
0629ba8
Message:

new build of sphinx for updated api

Location:
documentation/Sphinx
Files:
2 added
71 edited

Legend:

Unmodified
Added
Removed
  • documentation/Sphinx/build/html/.buildinfo

    r708c667 r2625ca8  
    11# Sphinx build info version 1
    22# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
    3 config: 02e87e48403e699e19326e64e41ebe7d
     3config: 329a9aafadcc8557df76a3756510535e
    44tags: 645f666f9bcd5a90fca523b33c5a78b7
  • documentation/Sphinx/build/html/_modules/ControlFile.html

    r274f9ef r2625ca8  
    174174<span class="c1">#</span>
    175175<span class="c1"># @License:</span>
    176 <span class="c1">#    (C) Copyright 2015-2018.</span>
     176<span class="c1">#    (C) Copyright 2014-2019.</span>
     177<span class="c1">#    Anne Philipp, Leopold Haimberger</span>
    177178<span class="c1">#</span>
    178 <span class="c1">#    This software is licensed under the terms of the Apache Licence Version 2.0</span>
    179 <span class="c1">#    which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.</span>
     179<span class="c1">#    This work is licensed under the Creative Commons Attribution 4.0</span>
     180<span class="c1">#    International License. To view a copy of this license, visit</span>
     181<span class="c1">#    http://creativecommons.org/licenses/by/4.0/ or send a letter to</span>
     182<span class="c1">#    Creative Commons, PO Box 1866, Mountain View, CA 94042, USA.</span>
    180183<span class="c1">#</span>
    181 <span class="c1"># @Class Description:</span>
    182 <span class="c1">#    The CONTROL file is the steering part of the FLEXPART extraction</span>
    183 <span class="c1">#    software. All necessary parameters needed to retrieve the data fields</span>
    184 <span class="c1">#    from the MARS archive for driving FLEXPART are set in a CONTROL file.</span>
    185 <span class="c1">#    Some specific parameters like the start and end dates can be overwritten</span>
    186 <span class="c1">#    by the command line parameters, but in generel all parameters needed</span>
    187 <span class="c1">#    for a complete set of fields for FLEXPART can be set in the CONTROL file.</span>
    188 <span class="c1">#</span>
    189 <span class="c1"># @Class Content:</span>
    190 <span class="c1">#    - __init__</span>
    191 <span class="c1">#    - __read_controlfile__</span>
    192 <span class="c1">#    - __str__</span>
    193 <span class="c1">#    - assign_args_to_control</span>
    194 <span class="c1">#    - assign_envs_to_control</span>
    195 <span class="c1">#    - check_conditions</span>
    196 <span class="c1">#    - check_install_conditions</span>
    197 <span class="c1">#    - to_list</span>
    198 <span class="c1">#</span>
    199 <span class="c1"># @Class Attributes:</span>
    200 <span class="c1">#</span>
    201 <span class="c1">#</span>
     184<span class="c1"># @Class Methods:</span>
     185<span class="c1">#    __init__</span>
     186<span class="c1">#    _read_controlfile</span>
     187<span class="c1">#    __str__</span>
     188<span class="c1">#    assign_args_to_control</span>
     189<span class="c1">#    assign_envs_to_control</span>
     190<span class="c1">#    check_conditions</span>
     191<span class="c1">#    check_install_conditions</span>
     192<span class="c1">#    to_list</span>
    202193<span class="c1">#*******************************************************************************</span>
    203194
     
    209200<span class="kn">import</span> <span class="nn">sys</span>
    210201<span class="kn">import</span> <span class="nn">inspect</span>
     202<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
    211203
    212204<span class="c1"># software specific classes and modules from flex_extract</span>
     
    214206<span class="kn">import</span> <span class="nn">_config</span>
    215207<span class="kn">from</span> <span class="nn">mods.tools</span> <span class="k">import</span> <span class="n">my_error</span><span class="p">,</span> <span class="n">silent_remove</span>
     208<span class="kn">from</span> <span class="nn">mods.checks</span> <span class="k">import</span> <span class="p">(</span><span class="n">check_grid</span><span class="p">,</span> <span class="n">check_area</span><span class="p">,</span> <span class="n">check_levels</span><span class="p">,</span> <span class="n">check_purefc</span><span class="p">,</span>
     209                         <span class="n">check_step</span><span class="p">,</span> <span class="n">check_mail</span><span class="p">,</span> <span class="n">check_queue</span><span class="p">,</span> <span class="n">check_pathes</span><span class="p">,</span>
     210                         <span class="n">check_dates</span><span class="p">,</span> <span class="n">check_maxstep</span><span class="p">,</span> <span class="n">check_type</span><span class="p">,</span> <span class="n">check_request</span><span class="p">,</span>
     211                         <span class="n">check_basetime</span><span class="p">,</span> <span class="n">check_public</span><span class="p">,</span> <span class="n">check_acctype</span><span class="p">,</span>
     212                         <span class="n">check_acctime</span><span class="p">,</span> <span class="n">check_accmaxstep</span><span class="p">,</span> <span class="n">check_time</span><span class="p">,</span>
     213                         <span class="n">check_logicals_type</span><span class="p">,</span> <span class="n">check_len_type_time_step</span><span class="p">,</span>
     214                         <span class="n">check_addpar</span><span class="p">,</span> <span class="n">check_job_chunk</span><span class="p">)</span>
    216215
    217216<span class="c1"># ------------------------------------------------------------------------------</span>
     
    221220    <span class="sd">&#39;&#39;&#39;</span>
    222221<span class="sd">    Contains the information which are stored in the CONTROL files.</span>
     222
     223<span class="sd">    The CONTROL file is the steering part of the FLEXPART extraction</span>
     224<span class="sd">    software. All necessary parameters needed to retrieve the data fields</span>
     225<span class="sd">    from the MARS archive for driving FLEXPART are set in a CONTROL file.</span>
     226<span class="sd">    Some specific parameters like the start and end dates can be overwritten</span>
     227<span class="sd">    by the command line parameters, but in generel all parameters needed</span>
     228<span class="sd">    for a complete set of fields for FLEXPART can be set in the CONTROL file.</span>
     229
     230<span class="sd">    Attributes</span>
     231<span class="sd">    ----------</span>
     232<span class="sd">    controlfile : str</span>
     233<span class="sd">        The name of the control file to be processed. Default value is the</span>
     234<span class="sd">        filename passed to the init function when initialised.</span>
     235
     236<span class="sd">    start_date : str</span>
     237<span class="sd">        The first day of the retrieval period. Default value is None.</span>
     238
     239<span class="sd">    end_date :str</span>
     240<span class="sd">        The last day of the retrieval period. Default value is None.</span>
     241
     242<span class="sd">    date_chunk : int</span>
     243<span class="sd">        Length of period for a single mars retrieval. Default value is 3.</span>
     244
     245<span class="sd">    dtime :str</span>
     246<span class="sd">        The time step in hours. Default value is None.</span>
     247
     248<span class="sd">    basetime : str</span>
     249<span class="sd">        The time for a half day retrieval. The 12 hours upfront are to be</span>
     250<span class="sd">        retrieved. Default value is None.</span>
     251
     252<span class="sd">    maxstep : int</span>
     253<span class="sd">        The maximum forecast step for non flux data. Default value is None.</span>
     254
     255<span class="sd">    type : list of str</span>
     256<span class="sd">        List of field type per retrieving hour. Default value is None.</span>
     257
     258<span class="sd">    time : list of str</span>
     259<span class="sd">        List of retrieving times in hours. Default valuer is None.</span>
     260
     261<span class="sd">    step : list of str or str</span>
     262<span class="sd">        List of forecast time steps in hours for non flux data.</span>
     263<span class="sd">        Default value is None.</span>
     264
     265<span class="sd">    acctype : str</span>
     266<span class="sd">        The field type for the accumulated forecast fields.</span>
     267<span class="sd">        Default value is None.</span>
     268
     269<span class="sd">    acctime : str</span>
     270<span class="sd">        The starting time of the accumulated forecasts. Default value is None.</span>
     271
     272<span class="sd">    accmaxstep : int</span>
     273<span class="sd">        The maximum forecast step for the accumulated forecast fields</span>
     274<span class="sd">        (flux data). Default value is None.</span>
     275
     276<span class="sd">    marsclass : str</span>
     277<span class="sd">        Characterisation of dataset. Default value is None.</span>
     278
     279<span class="sd">    dataset : str</span>
     280<span class="sd">        For public datasets there is the specific naming and parameter</span>
     281<span class="sd">        dataset which has to be used to characterize the type of</span>
     282<span class="sd">        data. Default value is None.</span>
     283
     284<span class="sd">    stream : str</span>
     285<span class="sd">        Identifies the forecasting system used to generate the data.</span>
     286<span class="sd">        Default value is None.</span>
     287
     288<span class="sd">    number : str</span>
     289<span class="sd">        Selects the member in ensemble forecast run. Default value is &#39;OFF&#39;.</span>
     290
     291<span class="sd">    expver : str</span>
     292<span class="sd">        The version number of the dataset. Default value is &#39;1&#39;.</span>
     293
     294<span class="sd">    gaussian : str</span>
     295<span class="sd">        This parameter is deprecated and should no longer be used.</span>
     296<span class="sd">        Specifies the desired type of Gaussian grid for the output.</span>
     297<span class="sd">        Default value is an empty string &#39;&#39;.</span>
     298
     299<span class="sd">    grid : str</span>
     300<span class="sd">        Specifies the output grid which can be either a Gaussian grid</span>
     301<span class="sd">        or a Latitude/Longitude grid. Default value is None.</span>
     302
     303<span class="sd">    area : str</span>
     304<span class="sd">        Specifies the desired sub-area of data to be extracted.</span>
     305<span class="sd">        Default value is None.</span>
     306
     307<span class="sd">    left : str</span>
     308<span class="sd">        The western most longitude of the area to be extracted.</span>
     309<span class="sd">        Default value is None.</span>
     310
     311<span class="sd">    lower : str</span>
     312<span class="sd">        The southern most latitude of the area to be extracted.</span>
     313<span class="sd">        Default value is None.</span>
     314
     315<span class="sd">    upper : str</span>
     316<span class="sd">        The northern most latitued of the area to be extracted.</span>
     317<span class="sd">        Default value is None.</span>
     318
     319<span class="sd">    right : str</span>
     320<span class="sd">        The eastern most longitude of the area to be extracted.</span>
     321<span class="sd">        Default value is None.</span>
     322
     323<span class="sd">    level : str</span>
     324<span class="sd">        Specifies the maximum level. Default value is None.</span>
     325
     326<span class="sd">    levelist : str</span>
     327<span class="sd">        Specifies the required level list. Default value is None.</span>
     328
     329<span class="sd">    resol : str</span>
     330<span class="sd">        Specifies the desired triangular truncation of retrieved data,</span>
     331<span class="sd">        before carrying out any other selected post-processing.</span>
     332<span class="sd">        Default value is None.</span>
     333
     334<span class="sd">    gauss : int</span>
     335<span class="sd">        Switch to select gaussian fields (1) or regular lat/lon (0).</span>
     336<span class="sd">        Default value is 0.</span>
     337
     338<span class="sd">    accuracy : int</span>
     339<span class="sd">        Specifies the number of bits per value to be used in the</span>
     340<span class="sd">        generated GRIB coded fields. Default value is 24.</span>
     341
     342<span class="sd">    omega : int</span>
     343<span class="sd">       Switch to select omega retrieval (1) or not (0). Default value is 0.</span>
     344
     345<span class="sd">    omegadiff : int</span>
     346<span class="sd">        Switch to decide to calculate Omega and Dps/Dt from continuity</span>
     347<span class="sd">        equation for diagnostic purposes (1) or not (0). Default value is 0.</span>
     348
     349<span class="sd">    eta : int</span>
     350<span class="sd">        Switch to select direct retrieval of etadot from MARS (1) or</span>
     351<span class="sd">        wether it has to be calculated (0). Then Default value is 0.</span>
     352
     353<span class="sd">    etadiff : int</span>
     354<span class="sd">        Switch to select calculation of etadot and Dps/Dt from continuity</span>
     355<span class="sd">        equation for diagnostic purposes (1) or not (0). Default value is 0.</span>
     356
     357<span class="sd">    etapar : int</span>
     358<span class="sd">        GRIB parameter Id for etadot fields. Default value is 77.</span>
     359
     360<span class="sd">    dpdeta : int</span>
     361<span class="sd">        Switch to select multiplication of etadot with dpdeta.</span>
     362<span class="sd">        Default value is 1.</span>
     363
     364<span class="sd">    smooth : int</span>
     365<span class="sd">        Spectral truncation of ETADOT after calculation on Gaussian grid.</span>
     366<span class="sd">        Default value is 0.</span>
     367
     368<span class="sd">    format : str</span>
     369<span class="sd">        The format of the GRIB data. Default value is &#39;GRIB1&#39;.</span>
     370
     371<span class="sd">    addpar : str</span>
     372<span class="sd">        List of additional surface level ECMWF parameter to be retrieved.</span>
     373<span class="sd">        Default value is None.</span>
     374
     375<span class="sd">    prefix : str</span>
     376<span class="sd">        Prefix string for the final FLEXPART/FLEXTRA ready input files.</span>
     377<span class="sd">        Default value is &#39;EN&#39;.</span>
     378
     379<span class="sd">    cwc : int</span>
     380<span class="sd">        Switch to select wether the sum of cloud liquid water content and</span>
     381<span class="sd">        cloud ice water content should be retrieved. Default value is 0.</span>
     382
     383<span class="sd">    wrf : int</span>
     384<span class="sd">        Switch to select further parameters for retrievment to support</span>
     385<span class="sd">        WRF simulations. Default value is 0.</span>
     386
     387<span class="sd">    ecfsdir : str</span>
     388<span class="sd">        Path to the ECMWF storage  &#39;ectmp:/${USER}/econdemand/&#39;</span>
     389
     390<span class="sd">    mailfail : list of str</span>
     391<span class="sd">        Email list for sending error log files from ECMWF servers.</span>
     392<span class="sd">        The email addresses should be seperated by a comma.</span>
     393<span class="sd">        Default value is [&#39;${USER}&#39;].</span>
     394
     395<span class="sd">    mailops : list of str</span>
     396<span class="sd">        Email list for sending operational log files from ECMWF servers.</span>
     397<span class="sd">        The email addresses should be seperated by a comma.</span>
     398<span class="sd">        Default value is [&#39;${USER}&#39;].</span>
     399
     400<span class="sd">    grib2flexpart : int 0</span>
     401<span class="sd">        Switch to select generation of preprocessed FLEXPART files &quot;.fp&quot;.</span>
     402<span class="sd">        If it is selected, the program grib2flexpart will try</span>
     403<span class="sd">        to convert the flex_extract output files into &quot;.fp&quot; format.</span>
     404
     405<span class="sd">    ecstorage : int</span>
     406<span class="sd">        Switch to select storage of FLEXPART ready output files</span>
     407<span class="sd">        in the ECFS file system. Default value is 0.</span>
     408
     409<span class="sd">    ectrans : int</span>
     410<span class="sd">        Switch to select the transfer of FLEXPART ready output files</span>
     411<span class="sd">        to the gateway server. Default value is 0.</span>
     412
     413<span class="sd">    inputdir : str</span>
     414<span class="sd">        Path to the temporary directory for the retrieval grib files and</span>
     415<span class="sd">        other processing files. Default value is _config.PATH_INPUT_DIR.</span>
     416
     417<span class="sd">    outputdir : str</span>
     418<span class="sd">        Path to the final directory where the final FLEXPART ready input</span>
     419<span class="sd">        files are stored. Default value is None.</span>
     420
     421<span class="sd">    flexextractdir : str</span>
     422<span class="sd">        Path to the flex_extract root directory. Default value is</span>
     423<span class="sd">        _config.PATH_FLEXEXTRACT_DIR.</span>
     424
     425<span class="sd">    exedir : str</span>
     426<span class="sd">        Path to the FORTRAN executable file. Default value is</span>
     427<span class="sd">        _config.PATH_FORTRAN_SRC.</span>
     428
     429<span class="sd">    flexpartdir : str</span>
     430<span class="sd">        Path to a FLEXPART root directory. Default value is None.</span>
     431
     432<span class="sd">    makefile : str</span>
     433<span class="sd">        Name of the makefile to be used for the Fortran program.</span>
     434<span class="sd">        Default value is &#39;Makefile.gfortran&#39;.</span>
     435
     436<span class="sd">    destination : str</span>
     437<span class="sd">        The remote destination which is used to transfer files</span>
     438<span class="sd">        from ECMWF server to local gateway server. Default value is None.</span>
     439
     440<span class="sd">    gateway : str</span>
     441<span class="sd">        The gateway server the user is using. Default value is None.</span>
     442
     443<span class="sd">    ecuid : str</span>
     444<span class="sd">        The user id on ECMWF server. Default value is None.</span>
     445
     446<span class="sd">    ecgid : str</span>
     447<span class="sd">        The group id on ECMWF server. Default value is None.</span>
     448
     449<span class="sd">    install_target : str</span>
     450<span class="sd">        Defines the location where the installation is to be done.</span>
     451<span class="sd">        Default value is None.</span>
     452
     453<span class="sd">    debug : int</span>
     454<span class="sd">        Switch to keep temporary files at the end of postprocessing (1) or</span>
     455<span class="sd">        to delete all temporary files except the final output files (0).</span>
     456<span class="sd">        Default value is 0.</span>
     457
     458<span class="sd">    request : int</span>
     459<span class="sd">        Switch to select between just retrieving the data (0), writing the mars</span>
     460<span class="sd">        parameter values to a csv file (1) or doing both (2).</span>
     461<span class="sd">        Default value is 0.</span>
     462
     463<span class="sd">    public : int</span>
     464<span class="sd">        Switch to select kind of ECMWF Web Api access and the</span>
     465<span class="sd">        possible data sets. Public data sets (1) and Memberstate data sets (0).</span>
     466<span class="sd">        Default value is 0.</span>
     467
     468<span class="sd">    ecapi : boolean</span>
     469<span class="sd">        Tells wether the ECMWF Web APi was able to load or not.</span>
     470<span class="sd">        Default value is None.</span>
     471
     472<span class="sd">    purefc : int</span>
     473<span class="sd">        Switch to decide wether the job is a pure forecast retrieval or</span>
     474<span class="sd">        coupled with analysis data. Default value is 0.</span>
     475
     476<span class="sd">    rrint: int</span>
     477<span class="sd">        Switch to select between old precipitation disaggregation method (0)</span>
     478<span class="sd">        or the new IA3 disaggegration method (1). Default value is 0.</span>
     479
     480<span class="sd">    logicals : list of str</span>
     481<span class="sd">        List of the names of logical switches which controls the flow</span>
     482<span class="sd">        of the program. Default list is [&#39;gauss&#39;, &#39;omega&#39;, &#39;omegadiff&#39;, &#39;eta&#39;,</span>
     483<span class="sd">        &#39;etadiff&#39;, &#39;dpdeta&#39;, &#39;cwc&#39;, &#39;wrf&#39;, &#39;grib2flexpart&#39;, &#39;ecstorage&#39;,</span>
     484<span class="sd">        &#39;ectrans&#39;, &#39;debug&#39;, &#39;request&#39;, &#39;public&#39;, &#39;purefc&#39;, &#39;rrint&#39;]</span>
    223485<span class="sd">    &#39;&#39;&#39;</span>
    224486
     
    230492<span class="sd">        Parameters</span>
    231493<span class="sd">        ----------</span>
    232 <span class="sd">        filename : :obj:`string`</span>
     494<span class="sd">        filename : str</span>
    233495<span class="sd">            Name of CONTROL file.</span>
    234496
     
    243505        <span class="bp">self</span><span class="o">.</span><span class="n">end_date</span> <span class="o">=</span> <span class="kc">None</span>
    244506        <span class="bp">self</span><span class="o">.</span><span class="n">date_chunk</span> <span class="o">=</span> <span class="mi">3</span>
     507        <span class="bp">self</span><span class="o">.</span><span class="n">job_chunk</span> <span class="o">=</span> <span class="kc">None</span>
    245508        <span class="bp">self</span><span class="o">.</span><span class="n">dtime</span> <span class="o">=</span> <span class="kc">None</span>
    246509        <span class="bp">self</span><span class="o">.</span><span class="n">basetime</span> <span class="o">=</span> <span class="kc">None</span>
     
    289552        <span class="bp">self</span><span class="o">.</span><span class="n">inputdir</span> <span class="o">=</span> <span class="n">_config</span><span class="o">.</span><span class="n">PATH_INPUT_DIR</span>
    290553        <span class="bp">self</span><span class="o">.</span><span class="n">outputdir</span> <span class="o">=</span> <span class="kc">None</span>
    291         <span class="bp">self</span><span class="o">.</span><span class="n">ecmwfdatadir</span> <span class="o">=</span> <span class="n">_config</span><span class="o">.</span><span class="n">PATH_FLEXEXTRACT_DIR</span>
     554        <span class="bp">self</span><span class="o">.</span><span class="n">flexextractdir</span> <span class="o">=</span> <span class="n">_config</span><span class="o">.</span><span class="n">PATH_FLEXEXTRACT_DIR</span>
    292555        <span class="bp">self</span><span class="o">.</span><span class="n">exedir</span> <span class="o">=</span> <span class="n">_config</span><span class="o">.</span><span class="n">PATH_FORTRAN_SRC</span>
    293         <span class="bp">self</span><span class="o">.</span><span class="n">flexpart_root_scripts</span> <span class="o">=</span> <span class="kc">None</span>
     556        <span class="bp">self</span><span class="o">.</span><span class="n">flexpartdir</span> <span class="o">=</span> <span class="kc">None</span>
    294557        <span class="bp">self</span><span class="o">.</span><span class="n">makefile</span> <span class="o">=</span> <span class="s1">&#39;Makefile.gfortran&#39;</span>
    295558        <span class="bp">self</span><span class="o">.</span><span class="n">destination</span> <span class="o">=</span> <span class="kc">None</span>
     
    301564        <span class="bp">self</span><span class="o">.</span><span class="n">request</span> <span class="o">=</span> <span class="mi">0</span>
    302565        <span class="bp">self</span><span class="o">.</span><span class="n">public</span> <span class="o">=</span> <span class="mi">0</span>
     566        <span class="bp">self</span><span class="o">.</span><span class="n">ecapi</span> <span class="o">=</span> <span class="kc">None</span>
     567        <span class="bp">self</span><span class="o">.</span><span class="n">purefc</span> <span class="o">=</span> <span class="mi">0</span>
     568        <span class="bp">self</span><span class="o">.</span><span class="n">rrint</span> <span class="o">=</span> <span class="mi">0</span>
    303569
    304570        <span class="bp">self</span><span class="o">.</span><span class="n">logicals</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;gauss&#39;</span><span class="p">,</span> <span class="s1">&#39;omega&#39;</span><span class="p">,</span> <span class="s1">&#39;omegadiff&#39;</span><span class="p">,</span> <span class="s1">&#39;eta&#39;</span><span class="p">,</span> <span class="s1">&#39;etadiff&#39;</span><span class="p">,</span>
    305571                         <span class="s1">&#39;dpdeta&#39;</span><span class="p">,</span> <span class="s1">&#39;cwc&#39;</span><span class="p">,</span> <span class="s1">&#39;wrf&#39;</span><span class="p">,</span> <span class="s1">&#39;grib2flexpart&#39;</span><span class="p">,</span> <span class="s1">&#39;ecstorage&#39;</span><span class="p">,</span>
    306                          <span class="s1">&#39;ectrans&#39;</span><span class="p">,</span> <span class="s1">&#39;debug&#39;</span><span class="p">,</span> <span class="s1">&#39;request&#39;</span><span class="p">,</span> <span class="s1">&#39;public&#39;</span><span class="p">]</span>
    307 
    308         <span class="bp">self</span><span class="o">.</span><span class="n">__read_controlfile__</span><span class="p">()</span>
     572                         <span class="s1">&#39;ectrans&#39;</span><span class="p">,</span> <span class="s1">&#39;debug&#39;</span><span class="p">,</span> <span class="s1">&#39;request&#39;</span><span class="p">,</span> <span class="s1">&#39;public&#39;</span><span class="p">,</span> <span class="s1">&#39;purefc&#39;</span><span class="p">,</span>
     573                         <span class="s1">&#39;rrint&#39;</span><span class="p">]</span>
     574
     575        <span class="bp">self</span><span class="o">.</span><span class="n">_read_controlfile</span><span class="p">()</span>
    309576
    310577        <span class="k">return</span>
    311578
    312     <span class="k">def</span> <span class="nf">__read_controlfile__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
     579    <span class="k">def</span> <span class="nf">_read_controlfile</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
    313580        <span class="sd">&#39;&#39;&#39;Read CONTROL file and assign all CONTROL file variables.</span>
    314581
     
    334601        <span class="c1"># go through every line and store parameter</span>
    335602        <span class="k">for</span> <span class="n">ldata</span> <span class="ow">in</span> <span class="n">fdata</span><span class="p">:</span>
     603            <span class="k">if</span> <span class="n">ldata</span> <span class="ow">and</span> <span class="n">ldata</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">==</span> <span class="s1">&#39;#&#39;</span><span class="p">:</span>
     604                <span class="c1"># ignore comment line in control file</span>
     605                <span class="k">continue</span>
     606            <span class="k">if</span> <span class="s1">&#39;#&#39;</span> <span class="ow">in</span> <span class="n">ldata</span><span class="p">:</span>
     607                <span class="c1"># cut off comment</span>
     608                <span class="n">ldata</span> <span class="o">=</span> <span class="n">ldata</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s1">&#39;#&#39;</span><span class="p">)[</span><span class="mi">0</span><span class="p">]</span>
    336609            <span class="n">data</span> <span class="o">=</span> <span class="n">ldata</span><span class="o">.</span><span class="n">split</span><span class="p">()</span>
    337610            <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">data</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">1</span><span class="p">:</span>
     
    344617                <span class="k">if</span> <span class="n">data</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="o">==</span> <span class="s1">&#39;day2&#39;</span><span class="p">:</span>
    345618                    <span class="n">data</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="s1">&#39;end_date&#39;</span>
    346                 <span class="k">if</span> <span class="n">data</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="o">==</span> <span class="s1">&#39;addpar&#39;</span><span class="p">:</span>
    347                     <span class="k">if</span> <span class="s1">&#39;/&#39;</span> <span class="ow">in</span> <span class="n">data</span><span class="p">[</span><span class="mi">1</span><span class="p">]:</span>
    348                         <span class="c1"># remove leading &#39;/&#39; sign from addpar content</span>
    349                         <span class="k">if</span> <span class="n">data</span><span class="p">[</span><span class="mi">1</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> <span class="o">==</span> <span class="s1">&#39;/&#39;</span><span class="p">:</span>
    350                             <span class="n">data</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">=</span> <span class="n">data</span><span class="p">[</span><span class="mi">1</span><span class="p">][</span><span class="mi">1</span><span class="p">:]</span>
    351                         <span class="n">dd</span> <span class="o">=</span> <span class="n">data</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s1">&#39;/&#39;</span><span class="p">)</span>
    352                         <span class="n">data</span> <span class="o">=</span> <span class="p">[</span><span class="n">data</span><span class="p">[</span><span class="mi">0</span><span class="p">]]</span>
    353                         <span class="k">for</span> <span class="n">d</span> <span class="ow">in</span> <span class="n">dd</span><span class="p">:</span>
    354                             <span class="n">data</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">d</span><span class="p">)</span>
    355619                <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">data</span><span class="p">)</span> <span class="o">==</span> <span class="mi">2</span><span class="p">:</span>
    356620                    <span class="k">if</span> <span class="s1">&#39;$&#39;</span> <span class="ow">in</span> <span class="n">data</span><span class="p">[</span><span class="mi">1</span><span class="p">]:</span>
     
    417681<span class="sd">        Parameters</span>
    418682<span class="sd">        ----------</span>
    419 <span class="sd">        args : :obj:`Namespace`</span>
     683<span class="sd">        args : Namespace</span>
    420684<span class="sd">            Contains the commandline arguments from script/program call.</span>
    421685
     
    442706<span class="sd">        Parameters</span>
    443707<span class="sd">        ----------</span>
    444 <span class="sd">        envs : :obj:`dictionary` of :obj:`strings`</span>
     708<span class="sd">        envs : dict of str</span>
    445709<span class="sd">            Contains the ECMWF environment parameternames &quot;ECUID&quot;, &quot;ECGID&quot;,</span>
    446710<span class="sd">            &quot;DESTINATION&quot; and &quot;GATEWAY&quot; with its corresponding values.</span>
     
    464728<span class="sd">        Parameters</span>
    465729<span class="sd">        ----------</span>
    466 <span class="sd">        queue : :obj:`string`</span>
     730<span class="sd">        queue : str</span>
    467731<span class="sd">            Name of the queue if submitted to the ECMWF servers.</span>
    468732<span class="sd">            Used to check if ecuid, ecgid, gateway and destination</span>
     
    473737
    474738<span class="sd">        &#39;&#39;&#39;</span>
    475         <span class="kn">from</span> <span class="nn">mods.tools</span> <span class="k">import</span> <span class="n">my_error</span>
    476         <span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
    477 
    478         <span class="c1"># check for having at least a starting date</span>
    479         <span class="c1"># otherwise program is not allowed to run</span>
    480         <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">start_date</span><span class="p">:</span>
    481             <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;start_date specified neither in command line nor </span><span class="se">\</span>
    482 <span class="s1">                   in CONTROL file &#39;</span> <span class="o">+</span>  <span class="bp">self</span><span class="o">.</span><span class="n">controlfile</span><span class="p">)</span>
    483             <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;Try &quot;&#39;</span> <span class="o">+</span> <span class="n">sys</span><span class="o">.</span><span class="n">argv</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s1">&#39;/&#39;</span><span class="p">)[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span> <span class="o">+</span>
    484                   <span class="s1">&#39; -h&quot; to print usage information&#39;</span><span class="p">)</span>
    485             <span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
    486 
    487         <span class="c1"># retrieve just one day if end_date isn&#39;t set</span>
    488         <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">end_date</span><span class="p">:</span>
    489             <span class="bp">self</span><span class="o">.</span><span class="n">end_date</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">start_date</span>
    490 
    491         <span class="c1"># basetime has only two possible values</span>
    492         <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">basetime</span><span class="p">:</span>
    493             <span class="k">if</span> <span class="nb">int</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">basetime</span><span class="p">)</span> <span class="o">!=</span> <span class="mi">0</span> <span class="ow">and</span> <span class="nb">int</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">basetime</span><span class="p">)</span> <span class="o">!=</span> <span class="mi">12</span><span class="p">:</span>
    494                 <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;Basetime has an invalid value!&#39;</span><span class="p">)</span>
    495                 <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;Basetime = &#39;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">basetime</span><span class="p">))</span>
    496                 <span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
    497 
    498         <span class="c1"># assure consistency of levelist and level</span>
    499         <span class="c1"># up-to-date available maximum level numbers at ECMWF, 05.10.2018</span>
    500         <span class="n">max_level_list</span> <span class="o">=</span> <span class="p">[</span><span class="mi">16</span><span class="p">,</span> <span class="mi">19</span><span class="p">,</span> <span class="mi">31</span><span class="p">,</span> <span class="mi">40</span><span class="p">,</span> <span class="mi">50</span><span class="p">,</span> <span class="mi">60</span><span class="p">,</span> <span class="mi">62</span><span class="p">,</span> <span class="mi">91</span><span class="p">,</span> <span class="mi">137</span><span class="p">]</span>
    501         <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">levelist</span> <span class="ow">and</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">level</span><span class="p">:</span>
    502             <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;Warning: neither levelist nor level </span><span class="se">\</span>
    503 <span class="s1">                               specified in CONTROL file&#39;</span><span class="p">)</span>
    504             <span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
    505         <span class="k">elif</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">levelist</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">level</span><span class="p">:</span>
    506             <span class="bp">self</span><span class="o">.</span><span class="n">levelist</span> <span class="o">=</span> <span class="s1">&#39;1/to/&#39;</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">level</span>
    507         <span class="k">elif</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">levelist</span> <span class="ow">and</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">level</span><span class="p">)</span> <span class="ow">or</span> \
    508              <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">levelist</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span> <span class="o">!=</span> <span class="bp">self</span><span class="o">.</span><span class="n">level</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]):</span>
    509             <span class="bp">self</span><span class="o">.</span><span class="n">level</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">levelist</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s1">&#39;/&#39;</span><span class="p">)[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span>
    510         <span class="k">else</span><span class="p">:</span>
    511             <span class="k">pass</span>
    512 
    513         <span class="c1"># check if max level is a valid level</span>
    514         <span class="k">if</span> <span class="nb">int</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">level</span><span class="p">)</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">max_level_list</span><span class="p">:</span>
    515             <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;ERROR: &#39;</span><span class="p">)</span>
    516             <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;LEVEL must be the maximum level of a specified &#39;</span>
    517                   <span class="s1">&#39;level list from ECMWF, e.g.&#39;</span><span class="p">)</span>
    518             <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;[16, 19, 31, 40, 50, 60, 62, 91 or 137]&#39;</span><span class="p">)</span>
    519             <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;Check parameter &quot;LEVEL&quot; or the max level of &quot;LEVELIST&quot;!&#39;</span><span class="p">)</span>
    520             <span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
    521 
    522         <span class="c1"># if area was provided (only from commandline)</span>
    523         <span class="c1"># decompose area into its 4 components</span>
    524         <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">area</span><span class="p">:</span>
    525             <span class="n">components</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">area</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s1">&#39;/&#39;</span><span class="p">)</span>
    526             <span class="c1"># convert float to integer coordinates</span>
    527             <span class="k">if</span> <span class="s1">&#39;.&#39;</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">area</span><span class="p">:</span>
    528                 <span class="n">components</span> <span class="o">=</span> <span class="p">[</span><span class="nb">str</span><span class="p">(</span><span class="nb">int</span><span class="p">(</span><span class="nb">float</span><span class="p">(</span><span class="n">item</span><span class="p">)</span> <span class="o">*</span> <span class="mi">1000</span><span class="p">))</span>
    529                               <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">item</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">components</span><span class="p">)]</span>
    530             <span class="bp">self</span><span class="o">.</span><span class="n">upper</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">left</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">lower</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">right</span> <span class="o">=</span> <span class="n">components</span>
    531 
    532         <span class="c1"># prepare step list if &quot;/&quot; signs are found</span>
    533         <span class="k">if</span> <span class="s1">&#39;/&#39;</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">step</span><span class="p">:</span>
    534             <span class="n">steps</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">step</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s1">&#39;/&#39;</span><span class="p">)</span>
    535             <span class="k">if</span> <span class="s1">&#39;to&#39;</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">step</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="ow">and</span> <span class="s1">&#39;by&#39;</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">step</span><span class="o">.</span><span class="n">lower</span><span class="p">():</span>
    536                 <span class="n">ilist</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="nb">int</span><span class="p">(</span><span class="n">steps</span><span class="p">[</span><span class="mi">0</span><span class="p">]),</span>
    537                                   <span class="nb">int</span><span class="p">(</span><span class="n">steps</span><span class="p">[</span><span class="mi">2</span><span class="p">])</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span>
    538                                   <span class="nb">int</span><span class="p">(</span><span class="n">steps</span><span class="p">[</span><span class="mi">4</span><span class="p">]))</span>
    539                 <span class="bp">self</span><span class="o">.</span><span class="n">step</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;</span><span class="si">{:0&gt;3}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">i</span><span class="p">)</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">ilist</span><span class="p">]</span>
    540             <span class="k">elif</span> <span class="s1">&#39;to&#39;</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">step</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="ow">and</span> <span class="s1">&#39;by&#39;</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">step</span><span class="o">.</span><span class="n">lower</span><span class="p">():</span>
    541                 <span class="n">my_error</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">mailfail</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">step</span> <span class="o">+</span> <span class="s1">&#39;:</span><span class="se">\n</span><span class="s1">&#39;</span> <span class="o">+</span>
    542                          <span class="s1">&#39;if &quot;to&quot; is used in steps parameter, </span><span class="se">\</span>
    543 <span class="s1">                         please use &quot;by&quot; as well&#39;</span><span class="p">)</span>
    544             <span class="k">else</span><span class="p">:</span>
    545                 <span class="bp">self</span><span class="o">.</span><span class="n">step</span> <span class="o">=</span> <span class="n">steps</span>
    546 
    547         <span class="c1"># if maxstep wasn&#39;t provided</span>
    548         <span class="c1"># search for it in the &quot;step&quot; parameter</span>
    549         <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">maxstep</span><span class="p">:</span>
    550             <span class="bp">self</span><span class="o">.</span><span class="n">maxstep</span> <span class="o">=</span> <span class="mi">0</span>
    551             <span class="k">for</span> <span class="n">s</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">step</span><span class="p">:</span>
    552                 <span class="k">if</span> <span class="nb">int</span><span class="p">(</span><span class="n">s</span><span class="p">)</span> <span class="o">&gt;</span> <span class="bp">self</span><span class="o">.</span><span class="n">maxstep</span><span class="p">:</span>
    553                     <span class="bp">self</span><span class="o">.</span><span class="n">maxstep</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">s</span><span class="p">)</span>
    554         <span class="k">else</span><span class="p">:</span>
    555             <span class="bp">self</span><span class="o">.</span><span class="n">maxstep</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">maxstep</span><span class="p">)</span>
    556 
    557         <span class="c1"># set root scripts since it is needed later on</span>
    558         <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">flexpart_root_scripts</span><span class="p">:</span>
    559             <span class="bp">self</span><span class="o">.</span><span class="n">flexpart_root_scripts</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">ecmwfdatadir</span>
    560 
    561         <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">outputdir</span><span class="p">:</span>
    562             <span class="bp">self</span><span class="o">.</span><span class="n">outputdir</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">inputdir</span>
    563 
    564         <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">mailfail</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span>
    565             <span class="k">if</span> <span class="s1">&#39;,&#39;</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">mailfail</span><span class="p">:</span>
    566                 <span class="bp">self</span><span class="o">.</span><span class="n">mailfail</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">mailfail</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s1">&#39;,&#39;</span><span class="p">)</span>
    567             <span class="k">elif</span> <span class="s1">&#39; &#39;</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">mailfail</span><span class="p">:</span>
    568                 <span class="bp">self</span><span class="o">.</span><span class="n">mailfail</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">mailfail</span><span class="o">.</span><span class="n">split</span><span class="p">()</span>
    569             <span class="k">else</span><span class="p">:</span>
    570                 <span class="bp">self</span><span class="o">.</span><span class="n">mailfail</span> <span class="o">=</span> <span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">mailfail</span><span class="p">]</span>
    571 
    572         <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">mailops</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span>
    573             <span class="k">if</span> <span class="s1">&#39;,&#39;</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">mailops</span><span class="p">:</span>
    574                 <span class="bp">self</span><span class="o">.</span><span class="n">mailops</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">mailops</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s1">&#39;,&#39;</span><span class="p">)</span>
    575             <span class="k">elif</span> <span class="s1">&#39; &#39;</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">mailops</span><span class="p">:</span>
    576                 <span class="bp">self</span><span class="o">.</span><span class="n">mailops</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">mailops</span><span class="o">.</span><span class="n">split</span><span class="p">()</span>
    577             <span class="k">else</span><span class="p">:</span>
    578                 <span class="bp">self</span><span class="o">.</span><span class="n">mailops</span> <span class="o">=</span> <span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">mailops</span><span class="p">]</span>
    579 
    580         <span class="k">if</span> <span class="n">queue</span> <span class="ow">in</span> <span class="n">_config</span><span class="o">.</span><span class="n">QUEUES_LIST</span> <span class="ow">and</span> \
    581            <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">gateway</span> <span class="ow">or</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">destination</span> <span class="ow">or</span> \
    582            <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">ecuid</span> <span class="ow">or</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">ecgid</span><span class="p">:</span>
    583             <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;</span><span class="se">\n</span><span class="s1">Environment variables GATEWAY, DESTINATION, ECUID and </span><span class="se">\</span>
    584 <span class="s1">                   ECGID were not set properly!&#39;</span><span class="p">)</span>
    585             <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;Please check for existence of file &quot;ECMWF_ENV&quot; in the </span><span class="se">\</span>
    586 <span class="s1">                   python directory!&#39;</span><span class="p">)</span>
    587             <span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
    588 
    589         <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">request</span> <span class="o">!=</span> <span class="mi">0</span><span class="p">:</span>
    590             <span class="n">marsfile</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">inputdir</span><span class="p">,</span>
    591                                     <span class="n">_config</span><span class="o">.</span><span class="n">FILE_MARS_REQUESTS</span><span class="p">)</span>
    592             <span class="k">if</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isfile</span><span class="p">(</span><span class="n">marsfile</span><span class="p">):</span>
    593                 <span class="n">silent_remove</span><span class="p">(</span><span class="n">marsfile</span><span class="p">)</span>
    594 
    595         <span class="c1"># check all logical variables for data type</span>
    596         <span class="c1"># if its a string change to integer</span>
    597         <span class="k">for</span> <span class="n">var</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">logicals</span><span class="p">:</span>
    598             <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="nb">getattr</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">var</span><span class="p">),</span> <span class="nb">int</span><span class="p">):</span>
    599                 <span class="nb">setattr</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">var</span><span class="p">,</span> <span class="nb">int</span><span class="p">(</span><span class="nb">getattr</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">var</span><span class="p">)))</span>
    600 
    601         <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">public</span> <span class="ow">and</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">dataset</span><span class="p">:</span>
    602             <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;ERROR: &#39;</span><span class="p">)</span>
    603             <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;If public mars data wants to be retrieved, &#39;</span>
    604                   <span class="s1">&#39;the &quot;dataset&quot;-parameter has to be set in the control file!&#39;</span><span class="p">)</span>
    605             <span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
    606 
    607         <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">type</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span>
    608             <span class="bp">self</span><span class="o">.</span><span class="n">type</span> <span class="o">=</span> <span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">type</span><span class="p">]</span>
    609 
    610         <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">val</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">type</span><span class="p">):</span>
    611             <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">type</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">==</span> <span class="s1">&#39;AN&#39;</span> <span class="ow">and</span> <span class="nb">int</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">step</span><span class="p">[</span><span class="n">i</span><span class="p">])</span> <span class="o">!=</span> <span class="mi">0</span><span class="p">:</span>
    612                 <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;Analysis retrievals must have STEP = 0 (is set to 0)&#39;</span><span class="p">)</span>
    613                 <span class="bp">self</span><span class="o">.</span><span class="n">type</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">=</span> <span class="mi">0</span>
    614 
    615         <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">time</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span>
    616             <span class="bp">self</span><span class="o">.</span><span class="n">time</span> <span class="o">=</span> <span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">time</span><span class="p">]</span>
    617 
    618         <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">step</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span>
    619             <span class="bp">self</span><span class="o">.</span><span class="n">step</span> <span class="o">=</span> <span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">step</span><span class="p">]</span>
    620 
    621         <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">acctype</span><span class="p">:</span>
    622             <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;... Control paramter ACCTYPE was not defined.&#39;</span><span class="p">)</span>
    623             <span class="k">try</span><span class="p">:</span>
    624                 <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">type</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">1</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">type</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">!=</span> <span class="s1">&#39;AN&#39;</span><span class="p">:</span>
    625                     <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;Use old setting by using TYPE[1] for flux forecast!&#39;</span><span class="p">)</span>
    626                     <span class="bp">self</span><span class="o">.</span><span class="n">acctype</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">type</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>
    627             <span class="k">except</span><span class="p">:</span>
    628                 <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;Use default value &quot;FC&quot; for flux forecast!&#39;</span><span class="p">)</span>
    629                 <span class="bp">self</span><span class="o">.</span><span class="n">acctype</span><span class="o">=</span><span class="s1">&#39;FC&#39;</span>
    630 
    631         <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">acctime</span><span class="p">:</span>
    632             <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;... Control paramter ACCTIME was not defined.&#39;</span><span class="p">)</span>
    633             <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;Use default value &quot;00/12&quot; for flux forecast!&#39;</span><span class="p">)</span>
    634             <span class="bp">self</span><span class="o">.</span><span class="n">acctime</span><span class="o">=</span><span class="s1">&#39;00/12&#39;</span>
    635 
    636         <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">accmaxstep</span><span class="p">:</span>
    637             <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;... Control paramter ACCMAXSTEP was not defined.&#39;</span><span class="p">)</span>
    638             <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;Use default value &quot;12&quot; for flux forecast!&#39;</span><span class="p">)</span>
    639             <span class="bp">self</span><span class="o">.</span><span class="n">accmaxstep</span><span class="o">=</span><span class="s1">&#39;12&#39;</span>
    640 
    641         <span class="k">return</span></div>
    642 
    643 <div class="viewcode-block" id="ControlFile.check_install_conditions"><a class="viewcode-back" href="../api.html#ControlFile.ControlFile.check_install_conditions">[docs]</a>    <span class="k">def</span> <span class="nf">check_install_conditions</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
    644         <span class="sd">&#39;&#39;&#39;Checks a couple of necessary attributes and conditions</span>
    645 <span class="sd">        for the installation such as if they exist and contain values.</span>
    646 <span class="sd">        Otherwise set default values.</span>
    647 
    648 <span class="sd">        Parameters</span>
    649 <span class="sd">        ----------</span>
    650 
    651 <span class="sd">        Return</span>
    652 <span class="sd">        ------</span>
    653 
    654 <span class="sd">        &#39;&#39;&#39;</span>
    655 
    656         <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">install_target</span> <span class="ow">and</span> \
    657            <span class="bp">self</span><span class="o">.</span><span class="n">install_target</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">[</span><span class="s1">&#39;local&#39;</span><span class="p">,</span> <span class="s1">&#39;ecgate&#39;</span><span class="p">,</span> <span class="s1">&#39;cca&#39;</span><span class="p">]:</span>
    658             <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;ERROR: unknown or missing installation target &#39;</span><span class="p">)</span>
    659             <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;target: &#39;</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">install_target</span><span class="p">)</span>
    660             <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;please specify correct installation target &#39;</span> <span class="o">+</span>
    661                   <span class="s1">&#39;(local | ecgate | cca)&#39;</span><span class="p">)</span>
    662             <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;use -h or --help for help&#39;</span><span class="p">)</span>
    663             <span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
    664 
    665         <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">install_target</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">install_target</span> <span class="o">!=</span> <span class="s1">&#39;local&#39;</span><span class="p">:</span>
    666             <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">ecgid</span> <span class="ow">or</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">ecuid</span> <span class="ow">or</span> \
    667                <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">gateway</span> <span class="ow">or</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">destination</span><span class="p">:</span>
    668                 <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;Please enter your ECMWF user id and group id as well &#39;</span> <span class="o">+</span>
    669                       <span class="s1">&#39;as the </span><span class="se">\n</span><span class="s1">name of the local gateway and the ectrans &#39;</span> <span class="o">+</span>
    670                       <span class="s1">&#39;destination &#39;</span><span class="p">)</span>
    671                 <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;with command line options --ecuid --ecgid </span><span class="se">\</span>
    672 <span class="s1">                       --gateway --destination&#39;</span><span class="p">)</span>
    673                 <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;Try &quot;&#39;</span> <span class="o">+</span> <span class="n">sys</span><span class="o">.</span><span class="n">argv</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s1">&#39;/&#39;</span><span class="p">)[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span> <span class="o">+</span> \
    674                       <span class="s1">&#39; -h&quot; to print usage information&#39;</span><span class="p">)</span>
    675                 <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;Please consult ecaccess documentation or ECMWF user </span><span class="se">\</span>
    676 <span class="s1">                       support for further details&#39;</span><span class="p">)</span>
    677                 <span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
    678 
    679             <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">flexpart_root_scripts</span><span class="p">:</span>
    680                 <span class="bp">self</span><span class="o">.</span><span class="n">flexpart_root_scripts</span> <span class="o">=</span> <span class="s1">&#39;$</span><span class="si">{HOME}</span><span class="s1">&#39;</span>
    681             <span class="k">else</span><span class="p">:</span>
    682                 <span class="bp">self</span><span class="o">.</span><span class="n">flexpart_root_scripts</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">flexpart_root_scripts</span>
    683         <span class="k">else</span><span class="p">:</span> <span class="c1"># local</span>
    684             <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">flexpart_root_scripts</span><span class="p">:</span>
    685                 <span class="bp">self</span><span class="o">.</span><span class="n">flexpart_root_scripts</span> <span class="o">=</span> <span class="n">_config</span><span class="o">.</span><span class="n">PATH_FLEXEXTRACT_DIR</span>
     739        <span class="n">check_logicals_type</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">logicals</span><span class="p">)</span>
     740
     741        <span class="bp">self</span><span class="o">.</span><span class="n">mailfail</span> <span class="o">=</span> <span class="n">check_mail</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">mailfail</span><span class="p">)</span>
     742
     743        <span class="bp">self</span><span class="o">.</span><span class="n">mailops</span> <span class="o">=</span> <span class="n">check_mail</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">mailops</span><span class="p">)</span>
     744
     745        <span class="n">check_queue</span><span class="p">(</span><span class="n">queue</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">gateway</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">destination</span><span class="p">,</span>
     746                    <span class="bp">self</span><span class="o">.</span><span class="n">ecuid</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">ecgid</span><span class="p">)</span>
     747
     748        <span class="bp">self</span><span class="o">.</span><span class="n">outputdir</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">flexpartdir</span> <span class="o">=</span> <span class="n">check_pathes</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">inputdir</span><span class="p">,</span>
     749             <span class="bp">self</span><span class="o">.</span><span class="n">outputdir</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">flexpartdir</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">flexextractdir</span><span class="p">)</span>
     750
     751        <span class="bp">self</span><span class="o">.</span><span class="n">start_date</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">end_date</span> <span class="o">=</span> <span class="n">check_dates</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">start_date</span><span class="p">,</span>
     752                                                     <span class="bp">self</span><span class="o">.</span><span class="n">end_date</span><span class="p">)</span>
     753
     754        <span class="n">check_basetime</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">basetime</span><span class="p">)</span>
     755
     756        <span class="bp">self</span><span class="o">.</span><span class="n">levelist</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">level</span> <span class="o">=</span> <span class="n">check_levels</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">levelist</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">level</span><span class="p">)</span>
     757
     758        <span class="bp">self</span><span class="o">.</span><span class="n">step</span> <span class="o">=</span> <span class="n">check_step</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">step</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">mailfail</span><span class="p">)</span>
     759
     760        <span class="bp">self</span><span class="o">.</span><span class="n">maxstep</span> <span class="o">=</span> <span class="n">check_maxstep</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">maxstep</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">step</span><span class="p">)</span>
     761
     762        <span class="n">check_request</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">request</span><span class="p">,</span>
     763                      <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">inputdir</span><span class="p">,</span> <span class="n">_config</span><span class="o">.</span><span class="n">FILE_MARS_REQUESTS</span><span class="p">))</span>
     764
     765        <span class="n">check_public</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">public</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">dataset</span><span class="p">)</span>
     766
     767        <span class="bp">self</span><span class="o">.</span><span class="n">type</span> <span class="o">=</span> <span class="n">check_type</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">type</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">step</span><span class="p">)</span>
     768
     769        <span class="bp">self</span><span class="o">.</span><span class="n">time</span> <span class="o">=</span> <span class="n">check_time</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">time</span><span class="p">)</span>
     770
     771        <span class="bp">self</span><span class="o">.</span><span class="n">type</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">time</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">step</span> <span class="o">=</span> <span class="n">check_len_type_time_step</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">type</span><span class="p">,</span>
     772                                                                   <span class="bp">self</span><span class="o">.</span><span class="n">time</span><span class="p">,</span>
     773                                                                   <span class="bp">self</span><span class="o">.</span><span class="n">step</span><span class="p">,</span>
     774                                                                   <span class="bp">self</span><span class="o">.</span><span class="n">maxstep</span><span class="p">,</span>
     775                                                                   <span class="bp">self</span><span class="o">.</span><span class="n">purefc</span><span class="p">)</span>
     776
     777        <span class="bp">self</span><span class="o">.</span><span class="n">acctype</span> <span class="o">=</span> <span class="n">check_acctype</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">acctype</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">type</span><span class="p">)</span>
     778
     779        <span class="bp">self</span><span class="o">.</span><span class="n">acctime</span> <span class="o">=</span> <span class="n">check_acctime</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">acctime</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">acctype</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">purefc</span><span class="p">)</span>
     780
     781        <span class="bp">self</span><span class="o">.</span><span class="n">accmaxstep</span> <span class="o">=</span> <span class="n">check_accmaxstep</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">accmaxstep</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">acctype</span><span class="p">,</span>
     782                                           <span class="bp">self</span><span class="o">.</span><span class="n">purefc</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">maxstep</span><span class="p">)</span>
     783
     784        <span class="bp">self</span><span class="o">.</span><span class="n">purefc</span> <span class="o">=</span> <span class="n">check_purefc</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">type</span><span class="p">)</span>
     785
     786        <span class="bp">self</span><span class="o">.</span><span class="n">grid</span> <span class="o">=</span> <span class="n">check_grid</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid</span><span class="p">)</span>
     787
     788        <span class="bp">self</span><span class="o">.</span><span class="n">area</span> <span class="o">=</span> <span class="n">check_area</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">area</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">upper</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">lower</span><span class="p">,</span>
     789                               <span class="bp">self</span><span class="o">.</span><span class="n">left</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">right</span><span class="p">)</span>
     790
     791        <span class="bp">self</span><span class="o">.</span><span class="n">addpar</span> <span class="o">=</span> <span class="n">check_addpar</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">addpar</span><span class="p">)</span>
     792
     793        <span class="bp">self</span><span class="o">.</span><span class="n">job_chunk</span> <span class="o">=</span> <span class="n">check_job_chunk</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">job_chunk</span><span class="p">)</span>
    686794
    687795        <span class="k">return</span></div>
     
    690798        <span class="sd">&#39;&#39;&#39;Just generates a list of strings containing the attributes and</span>
    691799<span class="sd">        assigned values except the attributes &quot;_expanded&quot;, &quot;exedir&quot;,</span>
    692 <span class="sd">        &quot;ecmwfdatadir&quot; and &quot;flexpart_root_scripts&quot;.</span>
     800<span class="sd">        &quot;flexextractdir&quot; and &quot;flexpartdir&quot;.</span>
    693801
    694802<span class="sd">        Parameters</span>
     
    697805<span class="sd">        Return</span>
    698806<span class="sd">        ------</span>
    699 <span class="sd">        l : :obj:`list`</span>
     807<span class="sd">        l : list of *</span>
    700808<span class="sd">            A sorted list of the all ControlFile class attributes with</span>
    701809<span class="sd">            their values except the attributes &quot;_expanded&quot;, &quot;exedir&quot;,</span>
    702 <span class="sd">            &quot;ecmwfdatadir&quot; and &quot;flexpart_root_scripts&quot;.</span>
     810<span class="sd">            &quot;flexextractdir&quot; and &quot;flexpartdir&quot;.</span>
    703811<span class="sd">        &#39;&#39;&#39;</span>
    704812
     
    714822            <span class="k">elif</span> <span class="s1">&#39;exedir&#39;</span> <span class="ow">in</span> <span class="n">item</span><span class="p">[</span><span class="mi">0</span><span class="p">]:</span>
    715823                <span class="k">pass</span>
    716             <span class="k">elif</span> <span class="s1">&#39;flexpart_root_scripts&#39;</span> <span class="ow">in</span> <span class="n">item</span><span class="p">[</span><span class="mi">0</span><span class="p">]:</span>
     824            <span class="k">elif</span> <span class="s1">&#39;flexpartdir&#39;</span> <span class="ow">in</span> <span class="n">item</span><span class="p">[</span><span class="mi">0</span><span class="p">]:</span>
    717825                <span class="k">pass</span>
    718             <span class="k">elif</span> <span class="s1">&#39;ecmwfdatadir&#39;</span> <span class="ow">in</span> <span class="n">item</span><span class="p">[</span><span class="mi">0</span><span class="p">]:</span>
     826            <span class="k">elif</span> <span class="s1">&#39;flexextractdir&#39;</span> <span class="ow">in</span> <span class="n">item</span><span class="p">[</span><span class="mi">0</span><span class="p">]:</span>
    719827                <span class="k">pass</span>
    720828            <span class="k">else</span><span class="p">:</span>
     
    724832                        <span class="n">stot</span> <span class="o">+=</span> <span class="n">s</span> <span class="o">+</span> <span class="s1">&#39; &#39;</span>
    725833
    726                     <span class="n">l</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">&quot;</span><span class="si">%s</span><span class="s2"> </span><span class="si">%s</span><span class="s2">&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="n">item</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">stot</span><span class="p">))</span>
     834                    <span class="n">l</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">&quot;</span><span class="si">%s</span><span class="s2"> </span><span class="si">%s</span><span class="se">\n</span><span class="s2">&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="n">item</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">stot</span><span class="p">))</span>
    727835                <span class="k">else</span><span class="p">:</span>
    728                     <span class="n">l</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">&quot;</span><span class="si">%s</span><span class="s2"> </span><span class="si">%s</span><span class="s2">&quot;</span> <span class="o">%</span> <span class="n">item</span><span class="p">)</span>
     836                    <span class="n">l</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">&quot;</span><span class="si">%s</span><span class="s2"> </span><span class="si">%s</span><span class="se">\n</span><span class="s2">&quot;</span> <span class="o">%</span> <span class="n">item</span><span class="p">)</span>
    729837
    730838        <span class="k">return</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">l</span><span class="p">)</span></div></div>
     
    742850  <div role="contentinfo">
    743851    <p>
    744         &copy; Copyright 2018, Anne Philipp and Leopold Haimberger.
     852        &copy; Copyright 2018, Anne Philipp and Leopold Haimberger
    745853
    746854    </p>
     
    761869 
    762870
    763     <script type="text/javascript">
    764         var DOCUMENTATION_OPTIONS = {
    765             URL_ROOT:'../',
    766             VERSION:'7.1 alpha',
    767             LANGUAGE:'None',
    768             COLLAPSE_INDEX:false,
    769             FILE_SUFFIX:'.html',
    770             HAS_SOURCE:  true,
    771             SOURCELINK_SUFFIX: '.txt'
    772         };
    773     </script>
    774       <script type="text/javascript" src="../_static/jquery.js"></script>
    775       <script type="text/javascript" src="../_static/underscore.js"></script>
    776       <script type="text/javascript" src="../_static/doctools.js"></script>
    777       <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
     871   
     872   
     873      <script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
     874        <script type="text/javascript" src="../_static/jquery.js"></script>
     875        <script type="text/javascript" src="../_static/underscore.js"></script>
     876        <script type="text/javascript" src="../_static/doctools.js"></script>
     877   
    778878
    779879 
  • documentation/Sphinx/build/html/_modules/EcFlexpart.html

    r274f9ef r2625ca8  
    194194<span class="c1">#</span>
    195195<span class="c1"># @License:</span>
    196 <span class="c1">#    (C) Copyright 2014-2018.</span>
     196<span class="c1">#    (C) Copyright 2014-2019.</span>
     197<span class="c1">#    Anne Philipp, Leopold Haimberger</span>
    197198<span class="c1">#</span>
    198 <span class="c1">#    This software is licensed under the terms of the Apache Licence Version 2.0</span>
    199 <span class="c1">#    which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.</span>
    200 <span class="c1">#</span>
    201 <span class="c1"># @Class Description:</span>
    202 <span class="c1">#    FLEXPART needs grib files in a specifc format. All necessary data fields</span>
    203 <span class="c1">#    for one time step are stored in a single file. The class represents an</span>
    204 <span class="c1">#    instance with all the parameter and settings necessary for retrieving</span>
    205 <span class="c1">#    MARS data and modifing them so they are fitting FLEXPART need. The class</span>
    206 <span class="c1">#    is able to disaggregate the fluxes and convert grid types to the one needed</span>
    207 <span class="c1">#    by FLEXPART, therefore using the FORTRAN program.</span>
    208 <span class="c1">#</span>
    209 <span class="c1"># @Class Content:</span>
    210 <span class="c1">#    - __init__</span>
    211 <span class="c1">#    - write_namelist</span>
    212 <span class="c1">#    - retrieve</span>
    213 <span class="c1">#    - process_output</span>
    214 <span class="c1">#    - create</span>
    215 <span class="c1">#    - deacc_fluxes</span>
    216 <span class="c1">#</span>
    217 <span class="c1"># @Class Attributes:</span>
    218 <span class="c1">#</span>
    219 <span class="c1">#  TODO</span>
    220 <span class="c1">#</span>
     199<span class="c1">#    This work is licensed under the Creative Commons Attribution 4.0</span>
     200<span class="c1">#    International License. To view a copy of this license, visit</span>
     201<span class="c1">#    http://creativecommons.org/licenses/by/4.0/ or send a letter to</span>
     202<span class="c1">#    Creative Commons, PO Box 1866, Mountain View, CA 94042, USA.</span>
    221203<span class="c1">#*******************************************************************************</span>
    222204<span class="c1">#pylint: disable=unsupported-assignment-operation</span>
     
    235217<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
    236218
    237 <span class="kn">from</span> <span class="nn">gribapi</span> <span class="k">import</span> <span class="p">(</span><span class="n">grib_set</span><span class="p">,</span> <span class="n">grib_index_select</span><span class="p">,</span> <span class="n">grib_new_from_index</span><span class="p">,</span> <span class="n">grib_get</span><span class="p">,</span>
    238                      <span class="n">grib_write</span><span class="p">,</span> <span class="n">grib_get_values</span><span class="p">,</span> <span class="n">grib_set_values</span><span class="p">,</span> <span class="n">grib_release</span><span class="p">,</span>
    239                      <span class="n">grib_index_release</span><span class="p">,</span> <span class="n">grib_index_get</span><span class="p">)</span>
    240 
    241 <span class="c1"># from eccodes import (codes_index_select, codes_new_from_index, codes_get,</span>
    242                      <span class="c1"># codes_get_values, codes_set_values, codes_set,</span>
    243                      <span class="c1"># codes_write, codes_release, codes_new_from_index,</span>
    244                      <span class="c1"># codes_index_release, codes_index_get)</span>
     219<span class="kn">from</span> <span class="nn">eccodes</span> <span class="k">import</span> <span class="p">(</span><span class="n">codes_index_select</span><span class="p">,</span> <span class="n">codes_new_from_index</span><span class="p">,</span> <span class="n">codes_get</span><span class="p">,</span>
     220                     <span class="n">codes_get_values</span><span class="p">,</span> <span class="n">codes_set_values</span><span class="p">,</span> <span class="n">codes_set</span><span class="p">,</span>
     221                     <span class="n">codes_write</span><span class="p">,</span> <span class="n">codes_release</span><span class="p">,</span> <span class="n">codes_new_from_index</span><span class="p">,</span>
     222                     <span class="n">codes_index_release</span><span class="p">,</span> <span class="n">codes_index_get</span><span class="p">)</span>
    245223
    246224<span class="c1"># software specific classes and modules from flex_extract</span>
    247225<span class="n">sys</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;../&#39;</span><span class="p">)</span>
    248226<span class="kn">import</span> <span class="nn">_config</span>
    249 <span class="kn">from</span> <span class="nn">GribTools</span> <span class="k">import</span> <span class="n">GribTools</span>
     227<span class="kn">from</span> <span class="nn">GribUtil</span> <span class="k">import</span> <span class="n">GribUtil</span>
    250228<span class="kn">from</span> <span class="nn">mods.tools</span> <span class="k">import</span> <span class="p">(</span><span class="n">init128</span><span class="p">,</span> <span class="n">to_param_id</span><span class="p">,</span> <span class="n">silent_remove</span><span class="p">,</span> <span class="n">product</span><span class="p">,</span>
    251                         <span class="n">my_error</span><span class="p">,</span> <span class="n">make_dir</span><span class="p">)</span>
     229                        <span class="n">my_error</span><span class="p">,</span> <span class="n">make_dir</span><span class="p">,</span> <span class="n">get_informations</span><span class="p">,</span> <span class="n">get_dimensions</span><span class="p">,</span>
     230                        <span class="n">execute_subprocess</span><span class="p">)</span>
    252231<span class="kn">from</span> <span class="nn">MarsRetrieval</span> <span class="k">import</span> <span class="n">MarsRetrieval</span>
    253232<span class="kn">import</span> <span class="nn">mods.disaggregation</span> <span class="k">as</span> <span class="nn">disaggregation</span>
     
    258237<div class="viewcode-block" id="EcFlexpart"><a class="viewcode-back" href="../api.html#EcFlexpart.EcFlexpart">[docs]</a><span class="k">class</span> <span class="nc">EcFlexpart</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
    259238    <span class="sd">&#39;&#39;&#39;</span>
    260 <span class="sd">    Class to retrieve FLEXPART specific ECMWF data.</span>
     239<span class="sd">    Class to represent FLEXPART specific ECMWF data.</span>
     240
     241<span class="sd">    FLEXPART needs grib files in a specifc format. All necessary data fields</span>
     242<span class="sd">    for one time step are stored in a single file. The class represents an</span>
     243<span class="sd">    instance with all the parameter and settings necessary for retrieving</span>
     244<span class="sd">    MARS data and modifing them so they are fitting FLEXPART needs. The class</span>
     245<span class="sd">    is able to disaggregate the fluxes and convert grid types to the one needed</span>
     246<span class="sd">    by FLEXPART, therefore using the FORTRAN program.</span>
     247
     248<span class="sd">    Attributes</span>
     249<span class="sd">    ----------</span>
     250<span class="sd">    mreq_count : int</span>
     251<span class="sd">        Counter for the number of generated mars requests.</span>
     252
     253<span class="sd">    inputdir : str</span>
     254<span class="sd">        Path to the directory where the retrieved data is stored.</span>
     255
     256<span class="sd">    dataset : str</span>
     257<span class="sd">        For public datasets there is the specific naming and parameter</span>
     258<span class="sd">        dataset which has to be used to characterize the type of</span>
     259<span class="sd">        data.</span>
     260
     261<span class="sd">    basetime : str</span>
     262<span class="sd">        The time for a half day retrieval. The 12 hours upfront are to be</span>
     263<span class="sd">        retrieved.</span>
     264
     265<span class="sd">    dtime : str</span>
     266<span class="sd">        Time step in hours.</span>
     267
     268<span class="sd">    acctype : str</span>
     269<span class="sd">        The field type for the accumulated forecast fields.</span>
     270
     271<span class="sd">    acctime : str</span>
     272<span class="sd">        The starting time from the accumulated forecasts.</span>
     273
     274<span class="sd">    accmaxstep : str</span>
     275<span class="sd">        The maximum forecast step for the accumulated forecast fields.</span>
     276
     277<span class="sd">    marsclass : str</span>
     278<span class="sd">        Characterisation of dataset.</span>
     279
     280<span class="sd">    stream : str</span>
     281<span class="sd">        Identifies the forecasting system used to generate the data.</span>
     282
     283<span class="sd">    number : str</span>
     284<span class="sd">        Selects the member in ensemble forecast run.</span>
     285
     286<span class="sd">    resol : str</span>
     287<span class="sd">        Specifies the desired triangular truncation of retrieved data,</span>
     288<span class="sd">        before carrying out any other selected post-processing.</span>
     289
     290<span class="sd">    accuracy : str</span>
     291<span class="sd">        Specifies the number of bits per value to be used in the</span>
     292<span class="sd">        generated GRIB coded fields.</span>
     293
     294<span class="sd">    addpar : str</span>
     295<span class="sd">        List of additional parameters to be retrieved.</span>
     296
     297<span class="sd">    level : str</span>
     298<span class="sd">        Specifies the maximum level.</span>
     299
     300<span class="sd">    expver : str</span>
     301<span class="sd">        The version of the dataset.</span>
     302
     303<span class="sd">    levelist : str</span>
     304<span class="sd">        Specifies the required levels.</span>
     305
     306<span class="sd">    glevelist : str</span>
     307<span class="sd">        Specifies the required levels for gaussian grids.</span>
     308
     309<span class="sd">    gaussian : str</span>
     310<span class="sd">        This parameter is deprecated and should no longer be used.</span>
     311<span class="sd">        Specifies the desired type of Gaussian grid for the output.</span>
     312
     313<span class="sd">    grid : str</span>
     314<span class="sd">        Specifies the output grid which can be either a Gaussian grid</span>
     315<span class="sd">        or a Latitude/Longitude grid.</span>
     316
     317<span class="sd">    area : str</span>
     318<span class="sd">        Specifies the desired sub-area of data to be extracted.</span>
     319
     320<span class="sd">    purefc : int</span>
     321<span class="sd">        Switch for definition of pure forecast mode or not.</span>
     322
     323<span class="sd">    outputfilelist : list of str</span>
     324<span class="sd">        The final list of FLEXPART ready input files.</span>
     325
     326<span class="sd">    types : dictionary</span>
     327<span class="sd">        Determines the combination of type of fields, time and forecast step</span>
     328<span class="sd">        to be retrieved.</span>
     329
     330<span class="sd">    params : dictionary</span>
     331<span class="sd">        Collection of grid types and their corresponding parameters,</span>
     332<span class="sd">        levels, level types and the grid definition.</span>
     333
     334<span class="sd">    server : ECMWFService or ECMWFDataServer</span>
     335<span class="sd">        This is the connection to the ECMWF data servers.</span>
     336
     337<span class="sd">    public : int</span>
     338<span class="sd">        Decides which Web API Server version is used.</span>
     339
     340<span class="sd">    dates : str</span>
     341<span class="sd">        Contains start and end date of the retrieval in the format</span>
     342<span class="sd">        &quot;YYYYMMDD/to/YYYYMMDD&quot;</span>
    261343<span class="sd">    &#39;&#39;&#39;</span>
     344
    262345    <span class="c1"># --------------------------------------------------------------------------</span>
    263346    <span class="c1"># CLASS FUNCTIONS</span>
     
    269352<span class="sd">        Parameters:</span>
    270353<span class="sd">        -----------</span>
    271 <span class="sd">        c : :obj:`ControlFile`</span>
     354<span class="sd">        c : ControlFile</span>
    272355<span class="sd">            Contains all the parameters of CONTROL file and</span>
    273356<span class="sd">            command line.</span>
    274357
    275 <span class="sd">        fluxes : :obj:`boolean`, optional</span>
     358<span class="sd">        fluxes : boolean, optional</span>
    276359<span class="sd">            Decides if the flux parameter settings are stored or</span>
    277360<span class="sd">            the rest of the parameter list.</span>
     
    282365
    283366<span class="sd">        &#39;&#39;&#39;</span>
    284         <span class="c1"># set a counter for the number of mars requests generated</span>
     367        <span class="c1"># set a counter for the number of generated mars requests</span>
    285368        <span class="bp">self</span><span class="o">.</span><span class="n">mreq_count</span> <span class="o">=</span> <span class="mi">0</span>
    286 
    287         <span class="c1"># different mars types for retrieving data for flexpart</span>
    288         <span class="bp">self</span><span class="o">.</span><span class="n">types</span> <span class="o">=</span> <span class="nb">dict</span><span class="p">()</span>
    289 
    290         <span class="c1"># Pure forecast mode</span>
    291         <span class="k">if</span> <span class="n">c</span><span class="o">.</span><span class="n">maxstep</span> <span class="o">&gt;</span> <span class="nb">len</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">type</span><span class="p">)</span> <span class="ow">and</span> <span class="s1">&#39;AN&#39;</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">c</span><span class="o">.</span><span class="n">type</span><span class="p">:</span>
    292             <span class="n">c</span><span class="o">.</span><span class="n">type</span> <span class="o">=</span> <span class="p">[</span><span class="n">c</span><span class="o">.</span><span class="n">type</span><span class="p">[</span><span class="mi">0</span><span class="p">]]</span>
    293             <span class="n">c</span><span class="o">.</span><span class="n">step</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;</span><span class="si">{:0&gt;3}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="nb">int</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">step</span><span class="p">[</span><span class="mi">0</span><span class="p">]))]</span>
    294             <span class="n">c</span><span class="o">.</span><span class="n">time</span> <span class="o">=</span> <span class="p">[</span><span class="n">c</span><span class="o">.</span><span class="n">time</span><span class="p">[</span><span class="mi">0</span><span class="p">]]</span>
    295             <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="n">c</span><span class="o">.</span><span class="n">maxstep</span> <span class="o">+</span> <span class="mi">1</span><span class="p">):</span>
    296                 <span class="n">c</span><span class="o">.</span><span class="n">type</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">type</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
    297                 <span class="n">c</span><span class="o">.</span><span class="n">step</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;</span><span class="si">{:0&gt;3}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">i</span><span class="p">))</span>
    298                 <span class="n">c</span><span class="o">.</span><span class="n">time</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">time</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
    299369
    300370        <span class="bp">self</span><span class="o">.</span><span class="n">inputdir</span> <span class="o">=</span> <span class="n">c</span><span class="o">.</span><span class="n">inputdir</span>
     
    302372        <span class="bp">self</span><span class="o">.</span><span class="n">basetime</span> <span class="o">=</span> <span class="n">c</span><span class="o">.</span><span class="n">basetime</span>
    303373        <span class="bp">self</span><span class="o">.</span><span class="n">dtime</span> <span class="o">=</span> <span class="n">c</span><span class="o">.</span><span class="n">dtime</span>
    304         <span class="n">i</span> <span class="o">=</span> <span class="mi">0</span>
    305         <span class="k">if</span> <span class="n">fluxes</span> <span class="ow">and</span> <span class="n">c</span><span class="o">.</span><span class="n">maxstep</span> <span class="o">&lt;=</span> <span class="mi">24</span><span class="p">:</span>
    306             <span class="c1"># no forecast beyond one day is needed!</span>
    307             <span class="c1"># Thus, prepare flux data manually as usual</span>
    308             <span class="c1"># with only forecast fields with start times at 00/12</span>
    309             <span class="c1"># (but without 00/12 fields since these are</span>
    310             <span class="c1"># the initialisation times of the flux fields</span>
    311             <span class="c1"># and therefore are zero all the time)</span>
    312             <span class="bp">self</span><span class="o">.</span><span class="n">types</span><span class="p">[</span><span class="nb">str</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">acctype</span><span class="p">)]</span> <span class="o">=</span> <span class="p">{</span><span class="s1">&#39;times&#39;</span><span class="p">:</span> <span class="nb">str</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">acctime</span><span class="p">),</span>
    313                                           <span class="s1">&#39;steps&#39;</span><span class="p">:</span> <span class="s1">&#39;</span><span class="si">{}</span><span class="s1">/to/</span><span class="si">{}</span><span class="s1">/by/</span><span class="si">{}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
    314                                               <span class="n">c</span><span class="o">.</span><span class="n">dtime</span><span class="p">,</span> <span class="n">c</span><span class="o">.</span><span class="n">accmaxstep</span><span class="p">,</span> <span class="n">c</span><span class="o">.</span><span class="n">dtime</span><span class="p">)}</span>
    315         <span class="k">else</span><span class="p">:</span>
    316             <span class="k">for</span> <span class="n">ty</span><span class="p">,</span> <span class="n">st</span><span class="p">,</span> <span class="n">ti</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">type</span><span class="p">,</span> <span class="n">c</span><span class="o">.</span><span class="n">step</span><span class="p">,</span> <span class="n">c</span><span class="o">.</span><span class="n">time</span><span class="p">):</span>
    317                 <span class="n">btlist</span> <span class="o">=</span> <span class="nb">range</span><span class="p">(</span><span class="mi">24</span><span class="p">)</span>
    318                 <span class="k">if</span> <span class="n">c</span><span class="o">.</span><span class="n">basetime</span> <span class="o">==</span> <span class="s1">&#39;12&#39;</span><span class="p">:</span>
    319                     <span class="n">btlist</span> <span class="o">=</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">8</span><span class="p">,</span> <span class="mi">9</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="mi">11</span><span class="p">,</span> <span class="mi">12</span><span class="p">]</span>
    320                 <span class="k">if</span> <span class="n">c</span><span class="o">.</span><span class="n">basetime</span> <span class="o">==</span> <span class="s1">&#39;00&#39;</span><span class="p">:</span>
    321                     <span class="n">btlist</span> <span class="o">=</span> <span class="p">[</span><span class="mi">13</span><span class="p">,</span> <span class="mi">14</span><span class="p">,</span> <span class="mi">15</span><span class="p">,</span> <span class="mi">16</span><span class="p">,</span> <span class="mi">17</span><span class="p">,</span> <span class="mi">18</span><span class="p">,</span> <span class="mi">19</span><span class="p">,</span> <span class="mi">20</span><span class="p">,</span> <span class="mi">21</span><span class="p">,</span> <span class="mi">22</span><span class="p">,</span> <span class="mi">23</span><span class="p">,</span> <span class="mi">0</span><span class="p">]</span>
    322 
    323                 <span class="k">if</span> <span class="p">((</span><span class="n">ty</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> <span class="o">==</span> <span class="s1">&#39;AN&#39;</span> <span class="ow">and</span> <span class="p">(</span><span class="nb">int</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">time</span><span class="p">[</span><span class="n">i</span><span class="p">])</span> <span class="o">%</span> <span class="nb">int</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">dtime</span><span class="p">))</span> <span class="o">==</span> <span class="mi">0</span><span class="p">)</span> <span class="ow">or</span>
    324                     <span class="p">(</span><span class="n">ty</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> <span class="o">!=</span> <span class="s1">&#39;AN&#39;</span> <span class="ow">and</span> <span class="p">(</span><span class="nb">int</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">step</span><span class="p">[</span><span class="n">i</span><span class="p">])</span> <span class="o">%</span> <span class="nb">int</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">dtime</span><span class="p">))</span> <span class="o">==</span> <span class="mi">0</span> <span class="ow">and</span>
    325                      <span class="p">(</span><span class="nb">int</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">step</span><span class="p">[</span><span class="n">i</span><span class="p">])</span> <span class="o">%</span> <span class="nb">int</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">dtime</span><span class="p">)</span> <span class="o">==</span> <span class="mi">0</span><span class="p">))</span> <span class="p">)</span> <span class="ow">and</span> \
    326                     <span class="p">(</span><span class="nb">int</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">time</span><span class="p">[</span><span class="n">i</span><span class="p">])</span> <span class="ow">in</span> <span class="n">btlist</span> <span class="ow">or</span> <span class="n">c</span><span class="o">.</span><span class="n">maxstep</span> <span class="o">&gt;</span> <span class="mi">24</span><span class="p">):</span>
    327 
    328                     <span class="k">if</span> <span class="n">ty</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">types</span><span class="o">.</span><span class="n">keys</span><span class="p">():</span>
    329                         <span class="bp">self</span><span class="o">.</span><span class="n">types</span><span class="p">[</span><span class="n">ty</span><span class="p">]</span> <span class="o">=</span> <span class="p">{</span><span class="s1">&#39;times&#39;</span><span class="p">:</span> <span class="s1">&#39;&#39;</span><span class="p">,</span> <span class="s1">&#39;steps&#39;</span><span class="p">:</span> <span class="s1">&#39;&#39;</span><span class="p">}</span>
    330 
    331                     <span class="k">if</span> <span class="n">ti</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">types</span><span class="p">[</span><span class="n">ty</span><span class="p">][</span><span class="s1">&#39;times&#39;</span><span class="p">]:</span>
    332                         <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">types</span><span class="p">[</span><span class="n">ty</span><span class="p">][</span><span class="s1">&#39;times&#39;</span><span class="p">]:</span>
    333                             <span class="bp">self</span><span class="o">.</span><span class="n">types</span><span class="p">[</span><span class="n">ty</span><span class="p">][</span><span class="s1">&#39;times&#39;</span><span class="p">]</span> <span class="o">+=</span> <span class="s1">&#39;/&#39;</span>
    334                         <span class="bp">self</span><span class="o">.</span><span class="n">types</span><span class="p">[</span><span class="n">ty</span><span class="p">][</span><span class="s1">&#39;times&#39;</span><span class="p">]</span> <span class="o">+=</span> <span class="n">ti</span>
    335 
    336                     <span class="k">if</span> <span class="n">st</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">types</span><span class="p">[</span><span class="n">ty</span><span class="p">][</span><span class="s1">&#39;steps&#39;</span><span class="p">]:</span>
    337                         <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">types</span><span class="p">[</span><span class="n">ty</span><span class="p">][</span><span class="s1">&#39;steps&#39;</span><span class="p">]:</span>
    338                             <span class="bp">self</span><span class="o">.</span><span class="n">types</span><span class="p">[</span><span class="n">ty</span><span class="p">][</span><span class="s1">&#39;steps&#39;</span><span class="p">]</span> <span class="o">+=</span> <span class="s1">&#39;/&#39;</span>
    339                         <span class="bp">self</span><span class="o">.</span><span class="n">types</span><span class="p">[</span><span class="n">ty</span><span class="p">][</span><span class="s1">&#39;steps&#39;</span><span class="p">]</span> <span class="o">+=</span> <span class="n">st</span>
    340                 <span class="n">i</span> <span class="o">+=</span> <span class="mi">1</span>
    341 
     374        <span class="bp">self</span><span class="o">.</span><span class="n">acctype</span> <span class="o">=</span> <span class="n">c</span><span class="o">.</span><span class="n">acctype</span>
     375        <span class="bp">self</span><span class="o">.</span><span class="n">acctime</span> <span class="o">=</span> <span class="n">c</span><span class="o">.</span><span class="n">acctime</span>
     376        <span class="bp">self</span><span class="o">.</span><span class="n">accmaxstep</span> <span class="o">=</span> <span class="n">c</span><span class="o">.</span><span class="n">accmaxstep</span>
    342377        <span class="bp">self</span><span class="o">.</span><span class="n">marsclass</span> <span class="o">=</span> <span class="n">c</span><span class="o">.</span><span class="n">marsclass</span>
    343378        <span class="bp">self</span><span class="o">.</span><span class="n">stream</span> <span class="o">=</span> <span class="n">c</span><span class="o">.</span><span class="n">stream</span>
     
    345380        <span class="bp">self</span><span class="o">.</span><span class="n">resol</span> <span class="o">=</span> <span class="n">c</span><span class="o">.</span><span class="n">resol</span>
    346381        <span class="bp">self</span><span class="o">.</span><span class="n">accuracy</span> <span class="o">=</span> <span class="n">c</span><span class="o">.</span><span class="n">accuracy</span>
     382        <span class="bp">self</span><span class="o">.</span><span class="n">addpar</span> <span class="o">=</span> <span class="n">c</span><span class="o">.</span><span class="n">addpar</span>
    347383        <span class="bp">self</span><span class="o">.</span><span class="n">level</span> <span class="o">=</span> <span class="n">c</span><span class="o">.</span><span class="n">level</span>
    348384        <span class="bp">self</span><span class="o">.</span><span class="n">expver</span> <span class="o">=</span> <span class="n">c</span><span class="o">.</span><span class="n">expver</span>
    349385        <span class="bp">self</span><span class="o">.</span><span class="n">levelist</span> <span class="o">=</span> <span class="n">c</span><span class="o">.</span><span class="n">levelist</span>
    350         <span class="c1"># for gaussian grid retrieval</span>
    351         <span class="bp">self</span><span class="o">.</span><span class="n">glevelist</span> <span class="o">=</span> <span class="s1">&#39;1/to/&#39;</span> <span class="o">+</span> <span class="n">c</span><span class="o">.</span><span class="n">level</span>
     386        <span class="bp">self</span><span class="o">.</span><span class="n">glevelist</span> <span class="o">=</span> <span class="s1">&#39;1/to/&#39;</span> <span class="o">+</span> <span class="n">c</span><span class="o">.</span><span class="n">level</span> <span class="c1"># in case of gaussian grid</span>
    352387        <span class="bp">self</span><span class="o">.</span><span class="n">gaussian</span> <span class="o">=</span> <span class="n">c</span><span class="o">.</span><span class="n">gaussian</span>
    353 
    354         <span class="k">if</span> <span class="s1">&#39;N&#39;</span> <span class="ow">in</span> <span class="n">c</span><span class="o">.</span><span class="n">grid</span><span class="p">:</span>  <span class="c1"># Gaussian output grid</span>
    355             <span class="bp">self</span><span class="o">.</span><span class="n">grid</span> <span class="o">=</span> <span class="n">c</span><span class="o">.</span><span class="n">grid</span>
    356             <span class="bp">self</span><span class="o">.</span><span class="n">area</span> <span class="o">=</span> <span class="s1">&#39;G&#39;</span>
     388        <span class="bp">self</span><span class="o">.</span><span class="n">grid</span> <span class="o">=</span> <span class="n">c</span><span class="o">.</span><span class="n">grid</span>
     389        <span class="bp">self</span><span class="o">.</span><span class="n">area</span> <span class="o">=</span> <span class="n">c</span><span class="o">.</span><span class="n">area</span>
     390        <span class="bp">self</span><span class="o">.</span><span class="n">purefc</span> <span class="o">=</span> <span class="n">c</span><span class="o">.</span><span class="n">purefc</span>
     391        <span class="bp">self</span><span class="o">.</span><span class="n">outputfilelist</span> <span class="o">=</span> <span class="p">[]</span>
     392
     393        <span class="c1"># Define the different types of field combinations (type, time, step)</span>
     394        <span class="bp">self</span><span class="o">.</span><span class="n">types</span> <span class="o">=</span> <span class="p">{}</span>
     395        <span class="c1"># Define the parameters and their level types, level list and</span>
     396        <span class="c1"># grid resolution for the retrieval job</span>
     397        <span class="bp">self</span><span class="o">.</span><span class="n">params</span> <span class="o">=</span> <span class="p">{}</span>
     398
     399        <span class="k">if</span> <span class="n">fluxes</span><span class="p">:</span>
     400            <span class="bp">self</span><span class="o">.</span><span class="n">_create_params_fluxes</span><span class="p">()</span>
    357401        <span class="k">else</span><span class="p">:</span>
    358             <span class="bp">self</span><span class="o">.</span><span class="n">grid</span> <span class="o">=</span> <span class="s1">&#39;</span><span class="si">{}</span><span class="s1">/</span><span class="si">{}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="nb">int</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">grid</span><span class="p">)</span> <span class="o">/</span> <span class="mf">1000.</span><span class="p">,</span> <span class="nb">int</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">grid</span><span class="p">)</span> <span class="o">/</span> <span class="mf">1000.</span><span class="p">)</span>
    359             <span class="bp">self</span><span class="o">.</span><span class="n">area</span> <span class="o">=</span> <span class="s1">&#39;</span><span class="si">{}</span><span class="s1">/</span><span class="si">{}</span><span class="s1">/</span><span class="si">{}</span><span class="s1">/</span><span class="si">{}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="nb">int</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">upper</span><span class="p">)</span> <span class="o">/</span> <span class="mf">1000.</span><span class="p">,</span>
    360                                              <span class="nb">int</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">left</span><span class="p">)</span> <span class="o">/</span> <span class="mf">1000.</span><span class="p">,</span>
    361                                              <span class="nb">int</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">lower</span><span class="p">)</span> <span class="o">/</span> <span class="mf">1000.</span><span class="p">,</span>
    362                                              <span class="nb">int</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">right</span><span class="p">)</span> <span class="o">/</span> <span class="mf">1000.</span><span class="p">)</span>
    363 
    364         <span class="bp">self</span><span class="o">.</span><span class="n">outputfilelist</span> <span class="o">=</span> <span class="p">[]</span>
    365 
    366 
    367         <span class="c1"># Now comes the nasty part that deals with the different</span>
    368         <span class="c1"># scenarios we have:</span>
    369         <span class="c1"># 1) Calculation of etadot on</span>
    370         <span class="c1">#    a) Gaussian grid</span>
    371         <span class="c1">#    b) Output grid</span>
    372         <span class="c1">#    c) Output grid using parameter 77 retrieved from MARS</span>
    373         <span class="c1"># 3) Calculation/Retrieval of omega</span>
    374         <span class="c1"># 4) Download also data for WRF</span>
    375 
    376         <span class="c1"># Different grids need different retrievals</span>
    377         <span class="c1"># SH = Spherical Harmonics, GG = Gaussian Grid,</span>
    378         <span class="c1"># OG = Output Grid, ML = MultiLevel, SL = SingleLevel</span>
    379         <span class="bp">self</span><span class="o">.</span><span class="n">params</span> <span class="o">=</span> <span class="p">{</span><span class="s1">&#39;SH__ML&#39;</span><span class="p">:</span> <span class="s1">&#39;&#39;</span><span class="p">,</span> <span class="s1">&#39;SH__SL&#39;</span><span class="p">:</span> <span class="s1">&#39;&#39;</span><span class="p">,</span>
    380                        <span class="s1">&#39;GG__ML&#39;</span><span class="p">:</span> <span class="s1">&#39;&#39;</span><span class="p">,</span> <span class="s1">&#39;GG__SL&#39;</span><span class="p">:</span> <span class="s1">&#39;&#39;</span><span class="p">,</span>
    381                        <span class="s1">&#39;OG__ML&#39;</span><span class="p">:</span> <span class="s1">&#39;&#39;</span><span class="p">,</span> <span class="s1">&#39;OG__SL&#39;</span><span class="p">:</span> <span class="s1">&#39;&#39;</span><span class="p">,</span>
    382                        <span class="s1">&#39;OG_OROLSM_SL&#39;</span><span class="p">:</span> <span class="s1">&#39;&#39;</span><span class="p">,</span> <span class="s1">&#39;OG_acc_SL&#39;</span><span class="p">:</span> <span class="s1">&#39;&#39;</span><span class="p">}</span>
    383         <span class="c1"># the self.params dictionary stores a list of</span>
    384         <span class="c1"># [param, levtype, levelist, grid] per key</span>
    385 
    386         <span class="k">if</span> <span class="n">fluxes</span> <span class="ow">is</span> <span class="kc">False</span><span class="p">:</span>
    387             <span class="bp">self</span><span class="o">.</span><span class="n">params</span><span class="p">[</span><span class="s1">&#39;SH__SL&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;LNSP&#39;</span><span class="p">,</span> <span class="s1">&#39;ML&#39;</span><span class="p">,</span> <span class="s1">&#39;1&#39;</span><span class="p">,</span> <span class="s1">&#39;OFF&#39;</span><span class="p">]</span>
    388             <span class="c1">#                        &quot;SD/MSL/TCC/10U/10V/2T/2D/129/172&quot;</span>
    389             <span class="bp">self</span><span class="o">.</span><span class="n">params</span><span class="p">[</span><span class="s1">&#39;OG__SL&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="p">[</span><span class="s2">&quot;141/151/164/165/166/167/168/129/172&quot;</span><span class="p">,</span> \
    390                                      <span class="s1">&#39;SFC&#39;</span><span class="p">,</span> <span class="s1">&#39;1&#39;</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid</span><span class="p">]</span>
    391             <span class="k">if</span> <span class="n">c</span><span class="o">.</span><span class="n">addpar</span><span class="p">:</span>
    392                 <span class="k">if</span> <span class="n">c</span><span class="o">.</span><span class="n">addpar</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">==</span> <span class="s1">&#39;/&#39;</span><span class="p">:</span>
    393                     <span class="n">c</span><span class="o">.</span><span class="n">addpar</span> <span class="o">=</span> <span class="n">c</span><span class="o">.</span><span class="n">addpar</span><span class="p">[</span><span class="mi">1</span><span class="p">:]</span>
    394                 <span class="bp">self</span><span class="o">.</span><span class="n">params</span><span class="p">[</span><span class="s1">&#39;OG__SL&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> <span class="o">+=</span> <span class="s1">&#39;/&#39;</span> <span class="o">+</span> <span class="s1">&#39;/&#39;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">addpar</span><span class="p">)</span>
    395 
    396             <span class="k">if</span> <span class="n">c</span><span class="o">.</span><span class="n">marsclass</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> <span class="o">==</span> <span class="s1">&#39;EA&#39;</span> <span class="ow">or</span> <span class="n">c</span><span class="o">.</span><span class="n">marsclass</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> <span class="o">==</span> <span class="s1">&#39;EP&#39;</span><span class="p">:</span>
    397                 <span class="bp">self</span><span class="o">.</span><span class="n">params</span><span class="p">[</span><span class="s1">&#39;OG_OROLSM__SL&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="p">[</span><span class="s2">&quot;160/27/28/244&quot;</span><span class="p">,</span>
    398                                                 <span class="s1">&#39;SFC&#39;</span><span class="p">,</span> <span class="s1">&#39;1&#39;</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid</span><span class="p">]</span>
    399             <span class="k">else</span><span class="p">:</span>
    400                 <span class="bp">self</span><span class="o">.</span><span class="n">params</span><span class="p">[</span><span class="s1">&#39;OG_OROLSM__SL&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="p">[</span><span class="s2">&quot;160/27/28/173&quot;</span><span class="p">,</span> \
    401                                                 <span class="s1">&#39;SFC&#39;</span><span class="p">,</span> <span class="s1">&#39;1&#39;</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid</span><span class="p">]</span>
    402 
    403             <span class="bp">self</span><span class="o">.</span><span class="n">params</span><span class="p">[</span><span class="s1">&#39;OG__ML&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;T/Q&#39;</span><span class="p">,</span> <span class="s1">&#39;ML&#39;</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">levelist</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid</span><span class="p">]</span>
    404 
    405             <span class="c1">#if c.gauss == &#39;0&#39; and c.eta == &#39;1&#39;:</span>
    406             <span class="k">if</span> <span class="ow">not</span> <span class="n">c</span><span class="o">.</span><span class="n">gauss</span> <span class="ow">and</span> <span class="n">c</span><span class="o">.</span><span class="n">eta</span><span class="p">:</span>
    407                 <span class="c1"># the simplest case</span>
    408                 <span class="bp">self</span><span class="o">.</span><span class="n">params</span><span class="p">[</span><span class="s1">&#39;OG__ML&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> <span class="o">+=</span> <span class="s1">&#39;/U/V/77&#39;</span>
    409             <span class="c1">#elif c.gauss == &#39;0&#39; and c.eta == &#39;0&#39;:</span>
    410             <span class="k">elif</span> <span class="ow">not</span> <span class="n">c</span><span class="o">.</span><span class="n">gauss</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">c</span><span class="o">.</span><span class="n">eta</span><span class="p">:</span>
    411             <span class="c1"># this is not recommended (inaccurate)</span>
    412                 <span class="bp">self</span><span class="o">.</span><span class="n">params</span><span class="p">[</span><span class="s1">&#39;OG__ML&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> <span class="o">+=</span> <span class="s1">&#39;/U/V&#39;</span>
    413             <span class="c1">#elif c.gauss == &#39;1&#39; and c.eta == &#39;0&#39;:</span>
    414             <span class="k">elif</span> <span class="n">c</span><span class="o">.</span><span class="n">gauss</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">c</span><span class="o">.</span><span class="n">eta</span><span class="p">:</span>
    415                 <span class="c1"># this is needed for data before 2008, or for reanalysis data</span>
    416                 <span class="bp">self</span><span class="o">.</span><span class="n">params</span><span class="p">[</span><span class="s1">&#39;GG__SL&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;Q&#39;</span><span class="p">,</span> <span class="s1">&#39;ML&#39;</span><span class="p">,</span> <span class="s1">&#39;1&#39;</span><span class="p">,</span> \
    417                                          <span class="s1">&#39;</span><span class="si">{}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">((</span><span class="nb">int</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">resol</span><span class="p">)</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span> <span class="o">/</span> <span class="mi">2</span><span class="p">)]</span>
    418                 <span class="bp">self</span><span class="o">.</span><span class="n">params</span><span class="p">[</span><span class="s1">&#39;SH__ML&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;U/V/D&#39;</span><span class="p">,</span> <span class="s1">&#39;ML&#39;</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">glevelist</span><span class="p">,</span> <span class="s1">&#39;OFF&#39;</span><span class="p">]</span>
    419             <span class="k">else</span><span class="p">:</span>
    420                 <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;Warning: This is a very costly parameter combination, </span><span class="se">\</span>
    421 <span class="s1">                      use only for debugging!&#39;</span><span class="p">)</span>
    422                 <span class="bp">self</span><span class="o">.</span><span class="n">params</span><span class="p">[</span><span class="s1">&#39;GG__SL&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;Q&#39;</span><span class="p">,</span> <span class="s1">&#39;ML&#39;</span><span class="p">,</span> <span class="s1">&#39;1&#39;</span><span class="p">,</span> \
    423                                          <span class="s1">&#39;</span><span class="si">{}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">((</span><span class="nb">int</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">resol</span><span class="p">)</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span> <span class="o">/</span> <span class="mi">2</span><span class="p">)]</span>
    424                 <span class="bp">self</span><span class="o">.</span><span class="n">params</span><span class="p">[</span><span class="s1">&#39;GG__ML&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;U/V/D/77&#39;</span><span class="p">,</span> <span class="s1">&#39;ML&#39;</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">glevelist</span><span class="p">,</span> \
    425                                          <span class="s1">&#39;</span><span class="si">{}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">((</span><span class="nb">int</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">resol</span><span class="p">)</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span> <span class="o">/</span> <span class="mi">2</span><span class="p">)]</span>
    426 
    427             <span class="k">if</span> <span class="n">c</span><span class="o">.</span><span class="n">omega</span><span class="p">:</span>
    428                 <span class="bp">self</span><span class="o">.</span><span class="n">params</span><span class="p">[</span><span class="s1">&#39;OG__ML&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> <span class="o">+=</span> <span class="s1">&#39;/W&#39;</span>
    429 
    430             <span class="c1"># add cloud water content if necessary</span>
    431             <span class="k">if</span> <span class="n">c</span><span class="o">.</span><span class="n">cwc</span><span class="p">:</span>
    432                 <span class="bp">self</span><span class="o">.</span><span class="n">params</span><span class="p">[</span><span class="s1">&#39;OG__ML&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> <span class="o">+=</span> <span class="s1">&#39;/CLWC/CIWC&#39;</span>
    433 
    434             <span class="c1"># add vorticity and geopotential height for WRF if necessary</span>
    435             <span class="k">if</span> <span class="n">c</span><span class="o">.</span><span class="n">wrf</span><span class="p">:</span>
    436                 <span class="bp">self</span><span class="o">.</span><span class="n">params</span><span class="p">[</span><span class="s1">&#39;OG__ML&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> <span class="o">+=</span> <span class="s1">&#39;/Z/VO&#39;</span>
    437                 <span class="k">if</span> <span class="s1">&#39;/D&#39;</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">params</span><span class="p">[</span><span class="s1">&#39;OG__ML&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">]:</span>
    438                     <span class="bp">self</span><span class="o">.</span><span class="n">params</span><span class="p">[</span><span class="s1">&#39;OG__ML&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> <span class="o">+=</span> <span class="s1">&#39;/D&#39;</span>
    439                 <span class="c1">#wrf_sfc = &#39;sp/msl/skt/2t/10u/10v/2d/z/lsm/sst/ci/sd/stl1/ /</span>
    440                 <span class="c1">#           stl2/stl3/stl4/swvl1/swvl2/swvl3/swvl4&#39;.upper()</span>
    441                 <span class="n">wrf_sfc</span> <span class="o">=</span> <span class="s1">&#39;134/235/167/165/166/168/129/172/34/31/141/ </span><span class="se">\</span>
    442 <span class="s1">                           139/170/183/236/39/40/41/42&#39;</span>
    443                 <span class="n">lwrt_sfc</span> <span class="o">=</span> <span class="n">wrf_sfc</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s1">&#39;/&#39;</span><span class="p">)</span>
    444                 <span class="k">for</span> <span class="n">par</span> <span class="ow">in</span> <span class="n">lwrt_sfc</span><span class="p">:</span>
    445                     <span class="k">if</span> <span class="n">par</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">params</span><span class="p">[</span><span class="s1">&#39;OG__SL&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">]:</span>
    446                         <span class="bp">self</span><span class="o">.</span><span class="n">params</span><span class="p">[</span><span class="s1">&#39;OG__SL&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> <span class="o">+=</span> <span class="s1">&#39;/&#39;</span> <span class="o">+</span> <span class="n">par</span>
    447 
     402            <span class="bp">self</span><span class="o">.</span><span class="n">_create_params</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">gauss</span><span class="p">,</span> <span class="n">c</span><span class="o">.</span><span class="n">eta</span><span class="p">,</span> <span class="n">c</span><span class="o">.</span><span class="n">omega</span><span class="p">,</span> <span class="n">c</span><span class="o">.</span><span class="n">cwc</span><span class="p">,</span> <span class="n">c</span><span class="o">.</span><span class="n">wrf</span><span class="p">)</span>
     403
     404        <span class="k">if</span> <span class="n">fluxes</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">c</span><span class="o">.</span><span class="n">purefc</span><span class="p">:</span>
     405            <span class="bp">self</span><span class="o">.</span><span class="n">_create_field_types_fluxes</span><span class="p">()</span>
    448406        <span class="k">else</span><span class="p">:</span>
    449             <span class="bp">self</span><span class="o">.</span><span class="n">params</span><span class="p">[</span><span class="s1">&#39;OG_acc_SL&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="p">[</span><span class="s2">&quot;LSP/CP/SSHF/EWSS/NSSS/SSR&quot;</span><span class="p">,</span> \
    450                                         <span class="s1">&#39;SFC&#39;</span><span class="p">,</span> <span class="s1">&#39;1&#39;</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid</span><span class="p">]</span>
    451 
     407            <span class="bp">self</span><span class="o">.</span><span class="n">_create_field_types</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">type</span><span class="p">,</span> <span class="n">c</span><span class="o">.</span><span class="n">time</span><span class="p">,</span> <span class="n">c</span><span class="o">.</span><span class="n">step</span><span class="p">)</span>
     408        <span class="k">return</span>
     409
     410    <span class="k">def</span> <span class="nf">_create_field_types</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">ftype</span><span class="p">,</span> <span class="n">ftime</span><span class="p">,</span> <span class="n">fstep</span><span class="p">):</span>
     411        <span class="sd">&#39;&#39;&#39;Create the combination of field type, time and forecast step.</span>
     412
     413<span class="sd">        Parameters:</span>
     414<span class="sd">        -----------</span>
     415<span class="sd">        ftype : list of str</span>
     416<span class="sd">            List of field types.</span>
     417
     418<span class="sd">        ftime : list of str</span>
     419<span class="sd">            The time in hours of the field.</span>
     420
     421<span class="sd">        fstep : str</span>
     422<span class="sd">            Specifies the forecast time step from forecast base time.</span>
     423<span class="sd">            Valid values are hours (HH) from forecast base time.</span>
     424
     425<span class="sd">        Return</span>
     426<span class="sd">        ------</span>
     427
     428<span class="sd">        &#39;&#39;&#39;</span>
     429        <span class="n">i</span> <span class="o">=</span> <span class="mi">0</span>
     430        <span class="k">for</span> <span class="n">ty</span><span class="p">,</span> <span class="n">st</span><span class="p">,</span> <span class="n">ti</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="n">ftype</span><span class="p">,</span> <span class="n">fstep</span><span class="p">,</span> <span class="n">ftime</span><span class="p">):</span>
     431            <span class="n">btlist</span> <span class="o">=</span> <span class="nb">range</span><span class="p">(</span><span class="mi">24</span><span class="p">)</span>
     432            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">basetime</span> <span class="o">==</span> <span class="s1">&#39;12&#39;</span><span class="p">:</span>
     433                <span class="n">btlist</span> <span class="o">=</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">8</span><span class="p">,</span> <span class="mi">9</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="mi">11</span><span class="p">,</span> <span class="mi">12</span><span class="p">]</span>
     434            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">basetime</span> <span class="o">==</span> <span class="s1">&#39;00&#39;</span><span class="p">:</span>
     435                <span class="n">btlist</span> <span class="o">=</span> <span class="p">[</span><span class="mi">13</span><span class="p">,</span> <span class="mi">14</span><span class="p">,</span> <span class="mi">15</span><span class="p">,</span> <span class="mi">16</span><span class="p">,</span> <span class="mi">17</span><span class="p">,</span> <span class="mi">18</span><span class="p">,</span> <span class="mi">19</span><span class="p">,</span> <span class="mi">20</span><span class="p">,</span> <span class="mi">21</span><span class="p">,</span> <span class="mi">22</span><span class="p">,</span> <span class="mi">23</span><span class="p">,</span> <span class="mi">0</span><span class="p">]</span>
     436
     437            <span class="c1"># if ((ty.upper() == &#39;AN&#39; and (int(c.time[i]) % int(c.dtime)) == 0) or</span>
     438                <span class="c1"># (ty.upper() != &#39;AN&#39; and (int(c.step[i]) % int(c.dtime)) == 0 and</span>
     439                 <span class="c1"># (int(c.step[i]) % int(c.dtime) == 0)) ) and \</span>
     440                 <span class="c1"># (int(c.time[i]) in btlist or c.purefc):</span>
     441
     442            <span class="k">if</span> <span class="p">(</span><span class="nb">int</span><span class="p">(</span><span class="n">ti</span><span class="p">)</span> <span class="ow">in</span> <span class="n">btlist</span><span class="p">)</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">purefc</span><span class="p">:</span>
     443
     444                <span class="k">if</span> <span class="p">((</span><span class="n">ty</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> <span class="o">==</span> <span class="s1">&#39;AN&#39;</span> <span class="ow">and</span> <span class="p">(</span><span class="nb">int</span><span class="p">(</span><span class="n">ti</span><span class="p">)</span> <span class="o">%</span> <span class="nb">int</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">dtime</span><span class="p">))</span> <span class="o">==</span> <span class="mi">0</span><span class="p">)</span> <span class="ow">or</span>
     445                    <span class="p">(</span><span class="n">ty</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> <span class="o">!=</span> <span class="s1">&#39;AN&#39;</span> <span class="ow">and</span> <span class="p">(</span><span class="nb">int</span><span class="p">(</span><span class="n">st</span><span class="p">)</span> <span class="o">%</span> <span class="nb">int</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">dtime</span><span class="p">))</span> <span class="o">==</span> <span class="mi">0</span><span class="p">)):</span>
     446
     447                    <span class="k">if</span> <span class="n">ty</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">types</span><span class="o">.</span><span class="n">keys</span><span class="p">():</span>
     448                        <span class="bp">self</span><span class="o">.</span><span class="n">types</span><span class="p">[</span><span class="n">ty</span><span class="p">]</span> <span class="o">=</span> <span class="p">{</span><span class="s1">&#39;times&#39;</span><span class="p">:</span> <span class="s1">&#39;&#39;</span><span class="p">,</span> <span class="s1">&#39;steps&#39;</span><span class="p">:</span> <span class="s1">&#39;&#39;</span><span class="p">}</span>
     449
     450                    <span class="k">if</span> <span class="n">ti</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">types</span><span class="p">[</span><span class="n">ty</span><span class="p">][</span><span class="s1">&#39;times&#39;</span><span class="p">]:</span>
     451                        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">types</span><span class="p">[</span><span class="n">ty</span><span class="p">][</span><span class="s1">&#39;times&#39;</span><span class="p">]:</span>
     452                            <span class="bp">self</span><span class="o">.</span><span class="n">types</span><span class="p">[</span><span class="n">ty</span><span class="p">][</span><span class="s1">&#39;times&#39;</span><span class="p">]</span> <span class="o">+=</span> <span class="s1">&#39;/&#39;</span>
     453                        <span class="bp">self</span><span class="o">.</span><span class="n">types</span><span class="p">[</span><span class="n">ty</span><span class="p">][</span><span class="s1">&#39;times&#39;</span><span class="p">]</span> <span class="o">+=</span> <span class="n">ti</span>
     454
     455                    <span class="k">if</span> <span class="n">st</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">types</span><span class="p">[</span><span class="n">ty</span><span class="p">][</span><span class="s1">&#39;steps&#39;</span><span class="p">]:</span>
     456                        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">types</span><span class="p">[</span><span class="n">ty</span><span class="p">][</span><span class="s1">&#39;steps&#39;</span><span class="p">]:</span>
     457                            <span class="bp">self</span><span class="o">.</span><span class="n">types</span><span class="p">[</span><span class="n">ty</span><span class="p">][</span><span class="s1">&#39;steps&#39;</span><span class="p">]</span> <span class="o">+=</span> <span class="s1">&#39;/&#39;</span>
     458                        <span class="bp">self</span><span class="o">.</span><span class="n">types</span><span class="p">[</span><span class="n">ty</span><span class="p">][</span><span class="s1">&#39;steps&#39;</span><span class="p">]</span> <span class="o">+=</span> <span class="n">st</span>
     459            <span class="n">i</span> <span class="o">+=</span> <span class="mi">1</span>
     460        <span class="k">return</span>
     461
     462    <span class="k">def</span> <span class="nf">_create_field_types_fluxes</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
     463        <span class="sd">&#39;&#39;&#39;Create the combination of field type, time and forecast step</span>
     464<span class="sd">        for the flux data.</span>
     465
     466<span class="sd">        Parameters:</span>
     467<span class="sd">        -----------</span>
     468
     469<span class="sd">        Return</span>
     470<span class="sd">        ------</span>
     471
     472<span class="sd">        &#39;&#39;&#39;</span>
     473        <span class="bp">self</span><span class="o">.</span><span class="n">types</span><span class="p">[</span><span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">acctype</span><span class="p">)]</span> <span class="o">=</span> <span class="p">{</span><span class="s1">&#39;times&#39;</span><span class="p">:</span> <span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">acctime</span><span class="p">),</span>
     474                                         <span class="s1">&#39;steps&#39;</span><span class="p">:</span> <span class="s1">&#39;</span><span class="si">{}</span><span class="s1">/to/</span><span class="si">{}</span><span class="s1">/by/</span><span class="si">{}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
     475                                             <span class="bp">self</span><span class="o">.</span><span class="n">dtime</span><span class="p">,</span>
     476                                             <span class="bp">self</span><span class="o">.</span><span class="n">accmaxstep</span><span class="p">,</span>
     477                                             <span class="bp">self</span><span class="o">.</span><span class="n">dtime</span><span class="p">)}</span>
     478        <span class="k">return</span>
     479
     480    <span class="k">def</span> <span class="nf">_create_params</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">gauss</span><span class="p">,</span> <span class="n">eta</span><span class="p">,</span> <span class="n">omega</span><span class="p">,</span> <span class="n">cwc</span><span class="p">,</span> <span class="n">wrf</span><span class="p">):</span>
     481        <span class="sd">&#39;&#39;&#39;Define the specific parameter settings for retrievment.</span>
     482
     483<span class="sd">        The different parameters need specific grid types and level types</span>
     484<span class="sd">        for retrievement. We might get following combination of types</span>
     485<span class="sd">        (depending on selection and availability):</span>
     486<span class="sd">        (These are short cuts for the grib file names (leading sequence)</span>
     487<span class="sd">        SH__ML, OG__ML, GG__ML, SH__SL, OG__SL, GG__SL, OG_OROLSM_SL</span>
     488<span class="sd">        where:</span>
     489<span class="sd">            SH = Spherical Harmonics, GG = Gaussian Grid, OG = Output Grid,</span>
     490<span class="sd">            ML = Model Level, SL = Surface Level</span>
     491
     492<span class="sd">        For each of this combination there is a list of parameter names,</span>
     493<span class="sd">        the level type, the level list and the grid resolution.</span>
     494
     495<span class="sd">        There are different scenarios for data extraction from MARS:</span>
     496<span class="sd">        1) Retrieval of etadot</span>
     497<span class="sd">           eta=1, gauss=0, omega=0</span>
     498<span class="sd">        2) Calculation of etadot from divergence</span>
     499<span class="sd">           eta=0, gauss=1, omega=0</span>
     500<span class="sd">        3) Calculation of etadot from omega (for makes sense for debugging)</span>
     501<span class="sd">           eta=0, gauss=0, omega=1</span>
     502<span class="sd">        4) Retrieval and Calculation of etadot (only for debugging)</span>
     503<span class="sd">           eta=1, gauss=1, omega=0</span>
     504<span class="sd">        5) Download also specific model and surface level data for FLEXPART-WRF</span>
     505
     506<span class="sd">        Parameters:</span>
     507<span class="sd">        -----------</span>
     508<span class="sd">        gauss : int</span>
     509<span class="sd">            Gaussian grid is retrieved.</span>
     510
     511<span class="sd">        eta : int</span>
     512<span class="sd">            Etadot parameter will be directly retrieved.</span>
     513
     514<span class="sd">        omega : int</span>
     515<span class="sd">            The omega paramterwill be retrieved.</span>
     516
     517<span class="sd">        cwc : int</span>
     518<span class="sd">            The cloud liquid and ice water content will be retrieved.</span>
     519
     520<span class="sd">        wrf : int</span>
     521<span class="sd">            Additional model level and surface level data will be retrieved for</span>
     522<span class="sd">            WRF/FLEXPART-WRF simulations.</span>
     523
     524<span class="sd">        Return</span>
     525<span class="sd">        ------</span>
     526
     527<span class="sd">        &#39;&#39;&#39;</span>
     528        <span class="c1"># SURFACE FIELDS</span>
     529        <span class="c1">#-----------------------------------------------------------------------</span>
     530        <span class="bp">self</span><span class="o">.</span><span class="n">params</span><span class="p">[</span><span class="s1">&#39;SH__SL&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;LNSP&#39;</span><span class="p">,</span> <span class="s1">&#39;ML&#39;</span><span class="p">,</span> <span class="s1">&#39;1&#39;</span><span class="p">,</span> <span class="s1">&#39;OFF&#39;</span><span class="p">]</span>
     531        <span class="bp">self</span><span class="o">.</span><span class="n">params</span><span class="p">[</span><span class="s1">&#39;OG__SL&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;SD/MSL/TCC/10U/10V/2T/2D/Z/LSM&#39;</span><span class="p">,</span> \
     532                                 <span class="s1">&#39;SFC&#39;</span><span class="p">,</span> <span class="s1">&#39;1&#39;</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid</span><span class="p">]</span>
     533        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">addpar</span><span class="p">:</span>
     534            <span class="bp">self</span><span class="o">.</span><span class="n">params</span><span class="p">[</span><span class="s1">&#39;OG__SL&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> <span class="o">+=</span> <span class="bp">self</span><span class="o">.</span><span class="n">addpar</span>
     535
     536        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">marsclass</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> <span class="o">==</span> <span class="s1">&#39;EA&#39;</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">marsclass</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> <span class="o">==</span> <span class="s1">&#39;EP&#39;</span><span class="p">:</span>
     537            <span class="bp">self</span><span class="o">.</span><span class="n">params</span><span class="p">[</span><span class="s1">&#39;OG_OROLSM__SL&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="p">[</span><span class="s2">&quot;SDOR/CVL/CVH/FSR&quot;</span><span class="p">,</span>
     538                                            <span class="s1">&#39;SFC&#39;</span><span class="p">,</span> <span class="s1">&#39;1&#39;</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid</span><span class="p">]</span>
     539        <span class="k">else</span><span class="p">:</span>
     540            <span class="bp">self</span><span class="o">.</span><span class="n">params</span><span class="p">[</span><span class="s1">&#39;OG_OROLSM__SL&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="p">[</span><span class="s2">&quot;SDOR/CVL/CVH/SR&quot;</span><span class="p">,</span> \
     541                                            <span class="s1">&#39;SFC&#39;</span><span class="p">,</span> <span class="s1">&#39;1&#39;</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid</span><span class="p">]</span>
     542
     543        <span class="c1"># MODEL LEVEL FIELDS</span>
     544        <span class="c1">#-----------------------------------------------------------------------</span>
     545        <span class="bp">self</span><span class="o">.</span><span class="n">params</span><span class="p">[</span><span class="s1">&#39;OG__ML&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;T/Q&#39;</span><span class="p">,</span> <span class="s1">&#39;ML&#39;</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">levelist</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid</span><span class="p">]</span>
     546
     547        <span class="k">if</span> <span class="ow">not</span> <span class="n">gauss</span> <span class="ow">and</span> <span class="n">eta</span><span class="p">:</span>
     548            <span class="bp">self</span><span class="o">.</span><span class="n">params</span><span class="p">[</span><span class="s1">&#39;OG__ML&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> <span class="o">+=</span> <span class="s1">&#39;/U/V/ETADOT&#39;</span>
     549        <span class="k">elif</span> <span class="n">gauss</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">eta</span><span class="p">:</span>
     550            <span class="bp">self</span><span class="o">.</span><span class="n">params</span><span class="p">[</span><span class="s1">&#39;GG__SL&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;Q&#39;</span><span class="p">,</span> <span class="s1">&#39;ML&#39;</span><span class="p">,</span> <span class="s1">&#39;1&#39;</span><span class="p">,</span> \
     551                                     <span class="s1">&#39;</span><span class="si">{}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">((</span><span class="nb">int</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">resol</span><span class="p">)</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span> <span class="o">/</span> <span class="mi">2</span><span class="p">)]</span>
     552            <span class="bp">self</span><span class="o">.</span><span class="n">params</span><span class="p">[</span><span class="s1">&#39;SH__ML&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;U/V/D&#39;</span><span class="p">,</span> <span class="s1">&#39;ML&#39;</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">glevelist</span><span class="p">,</span> <span class="s1">&#39;OFF&#39;</span><span class="p">]</span>
     553        <span class="k">elif</span> <span class="ow">not</span> <span class="n">gauss</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">eta</span><span class="p">:</span>
     554            <span class="bp">self</span><span class="o">.</span><span class="n">params</span><span class="p">[</span><span class="s1">&#39;OG__ML&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> <span class="o">+=</span> <span class="s1">&#39;/U/V&#39;</span>
     555        <span class="k">else</span><span class="p">:</span>
     556            <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;Warning: Collecting etadot and parameters for gaussian grid </span><span class="se">\</span>
     557<span class="s1">                            is a very costly parameter combination, </span><span class="se">\</span>
     558<span class="s1">                            use this combination only for debugging!&#39;</span><span class="p">)</span>
     559            <span class="bp">self</span><span class="o">.</span><span class="n">params</span><span class="p">[</span><span class="s1">&#39;GG__SL&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;Q&#39;</span><span class="p">,</span> <span class="s1">&#39;ML&#39;</span><span class="p">,</span> <span class="s1">&#39;1&#39;</span><span class="p">,</span> \
     560                                     <span class="s1">&#39;</span><span class="si">{}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">((</span><span class="nb">int</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">resol</span><span class="p">)</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span> <span class="o">/</span> <span class="mi">2</span><span class="p">)]</span>
     561            <span class="bp">self</span><span class="o">.</span><span class="n">params</span><span class="p">[</span><span class="s1">&#39;GG__ML&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;U/V/D/77&#39;</span><span class="p">,</span> <span class="s1">&#39;ML&#39;</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">glevelist</span><span class="p">,</span> \
     562                                     <span class="s1">&#39;</span><span class="si">{}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">((</span><span class="nb">int</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">resol</span><span class="p">)</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span> <span class="o">/</span> <span class="mi">2</span><span class="p">)]</span>
     563
     564        <span class="k">if</span> <span class="n">omega</span><span class="p">:</span>
     565            <span class="bp">self</span><span class="o">.</span><span class="n">params</span><span class="p">[</span><span class="s1">&#39;OG__ML&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> <span class="o">+=</span> <span class="s1">&#39;/W&#39;</span>
     566
     567        <span class="k">if</span> <span class="n">cwc</span><span class="p">:</span>
     568            <span class="bp">self</span><span class="o">.</span><span class="n">params</span><span class="p">[</span><span class="s1">&#39;OG__ML&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> <span class="o">+=</span> <span class="s1">&#39;/CLWC/CIWC&#39;</span>
     569
     570        <span class="c1"># ADDITIONAL FIELDS FOR FLEXPART-WRF MODEL (IF QUESTIONED)</span>
     571        <span class="c1">#-----------------------------------------------------------------------</span>
     572        <span class="k">if</span> <span class="n">wrf</span><span class="p">:</span>
     573            <span class="bp">self</span><span class="o">.</span><span class="n">params</span><span class="p">[</span><span class="s1">&#39;OG__ML&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> <span class="o">+=</span> <span class="s1">&#39;/Z/VO&#39;</span>
     574            <span class="k">if</span> <span class="s1">&#39;/D&#39;</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">params</span><span class="p">[</span><span class="s1">&#39;OG__ML&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">]:</span>
     575                <span class="bp">self</span><span class="o">.</span><span class="n">params</span><span class="p">[</span><span class="s1">&#39;OG__ML&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> <span class="o">+=</span> <span class="s1">&#39;/D&#39;</span>
     576            <span class="n">wrf_sfc</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;SP&#39;</span><span class="p">,</span><span class="s1">&#39;SKT&#39;</span><span class="p">,</span><span class="s1">&#39;SST&#39;</span><span class="p">,</span><span class="s1">&#39;CI&#39;</span><span class="p">,</span><span class="s1">&#39;STL1&#39;</span><span class="p">,</span><span class="s1">&#39;STL2&#39;</span><span class="p">,</span> <span class="s1">&#39;STL3&#39;</span><span class="p">,</span><span class="s1">&#39;STL4&#39;</span><span class="p">,</span>
     577                       <span class="s1">&#39;SWVL1&#39;</span><span class="p">,</span><span class="s1">&#39;SWVL2&#39;</span><span class="p">,</span><span class="s1">&#39;SWVL3&#39;</span><span class="p">,</span><span class="s1">&#39;SWVL4&#39;</span><span class="p">]</span>
     578            <span class="k">for</span> <span class="n">par</span> <span class="ow">in</span> <span class="n">wrf_sfc</span><span class="p">:</span>
     579                <span class="k">if</span> <span class="n">par</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">params</span><span class="p">[</span><span class="s1">&#39;OG__SL&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">]:</span>
     580                    <span class="bp">self</span><span class="o">.</span><span class="n">params</span><span class="p">[</span><span class="s1">&#39;OG__SL&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> <span class="o">+=</span> <span class="s1">&#39;/&#39;</span> <span class="o">+</span> <span class="n">par</span>
     581
     582        <span class="k">return</span>
     583
     584
     585    <span class="k">def</span> <span class="nf">_create_params_fluxes</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
     586        <span class="sd">&#39;&#39;&#39;Define the parameter setting for flux data.</span>
     587
     588<span class="sd">        Flux data are accumulated fields in time and are stored on the</span>
     589<span class="sd">        surface level. The leading short cut name for the grib files is:</span>
     590<span class="sd">        &quot;OG_acc_SL&quot; with OG for Regular Output Grid, SL for Surface Level, and</span>
     591<span class="sd">        acc for Accumulated Grid.</span>
     592<span class="sd">        The params dictionary stores a list of parameter names, the level type,</span>
     593<span class="sd">        the level list and the grid resolution.</span>
     594
     595<span class="sd">        The flux data are: LSP/CP/SSHF/EWSS/NSSS/SSR</span>
     596
     597<span class="sd">        Parameters:</span>
     598<span class="sd">        -----------</span>
     599
     600<span class="sd">        Return</span>
     601<span class="sd">        ------</span>
     602
     603<span class="sd">        &#39;&#39;&#39;</span>
     604        <span class="bp">self</span><span class="o">.</span><span class="n">params</span><span class="p">[</span><span class="s1">&#39;OG_acc_SL&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="p">[</span><span class="s2">&quot;LSP/CP/SSHF/EWSS/NSSS/SSR&quot;</span><span class="p">,</span> \
     605                                    <span class="s1">&#39;SFC&#39;</span><span class="p">,</span> <span class="s1">&#39;1&#39;</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid</span><span class="p">]</span>
    452606        <span class="k">return</span>
    453607
     
    459613<span class="sd">        Parameters</span>
    460614<span class="sd">        ----------</span>
    461 <span class="sd">        ftype : :obj:`string`</span>
     615<span class="sd">        ftype : str</span>
    462616<span class="sd">            Shortcut name of the type of the field. E.g. AN, FC, PF, ...</span>
    463617
    464 <span class="sd">        param : :obj:`string`</span>
     618<span class="sd">        param : str</span>
    465619<span class="sd">            Shortcut of the grid type. E.g. SH__ML, SH__SL, GG__ML,</span>
    466620<span class="sd">            GG__SL, OG__ML, OG__SL, OG_OROLSM_SL, OG_acc_SL</span>
    467621
    468 <span class="sd">        date : :obj:`string`</span>
     622<span class="sd">        date : str</span>
    469623<span class="sd">            The date period of the grib data to be stored in this file.</span>
    470624
    471625<span class="sd">        Return</span>
    472626<span class="sd">        ------</span>
    473 <span class="sd">        targetname : :obj:`string`</span>
     627<span class="sd">        targetname : str</span>
    474628<span class="sd">            The target filename for the grib data.</span>
    475629<span class="sd">        &#39;&#39;&#39;</span>
     
    486640<span class="sd">        Parameters</span>
    487641<span class="sd">        ----------</span>
    488 <span class="sd">        request : :obj:`integer`</span>
     642<span class="sd">        request : int</span>
    489643<span class="sd">            Selects the mode of retrieval.</span>
    490644<span class="sd">            0: Retrieves the data from ECMWF.</span>
     
    492646<span class="sd">            2: Retrieves the data and prints the mars request.</span>
    493647
    494 <span class="sd">        par_dict : :obj:`dictionary`</span>
     648<span class="sd">        par_dict : dictionary</span>
    495649<span class="sd">            Contains all parameter which have to be set for creating the</span>
    496650<span class="sd">            Mars Retrievals. The parameter are:</span>
     
    548702<span class="sd">        Parameters</span>
    549703<span class="sd">        ----------</span>
    550 <span class="sd">        keys : :obj:`dictionary`</span>
     704<span class="sd">        keys : dictionary</span>
    551705<span class="sd">            List of parameter names which serves as index.</span>
    552706
    553 <span class="sd">        inputfiles : :obj:`UioFiles`</span>
     707<span class="sd">        inputfiles : UioFiles</span>
    554708<span class="sd">            Contains a list of files.</span>
    555709
    556710<span class="sd">        Return</span>
    557711<span class="sd">        ------</span>
    558 <span class="sd">        iid : :obj:`grib_index`</span>
     712<span class="sd">        iid : codes_index</span>
    559713<span class="sd">            This is a grib specific index structure to access</span>
    560714<span class="sd">            messages in a file.</span>
    561715
    562 <span class="sd">        index_vals : :obj:`list`</span>
     716<span class="sd">        index_vals : list of list  of str</span>
    563717<span class="sd">            Contains the values from the keys used for a distinct selection</span>
    564718<span class="sd">            of grib messages in processing  the grib files.</span>
     
    573727        <span class="n">indexfile</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">inputdir</span><span class="p">,</span> <span class="n">_config</span><span class="o">.</span><span class="n">FILE_GRIB_INDEX</span><span class="p">)</span>
    574728        <span class="n">silent_remove</span><span class="p">(</span><span class="n">indexfile</span><span class="p">)</span>
    575         <span class="n">grib</span> <span class="o">=</span> <span class="n">GribTools</span><span class="p">(</span><span class="n">inputfiles</span><span class="o">.</span><span class="n">files</span><span class="p">)</span>
     729        <span class="n">grib</span> <span class="o">=</span> <span class="n">GribUtil</span><span class="p">(</span><span class="n">inputfiles</span><span class="o">.</span><span class="n">files</span><span class="p">)</span>
    576730        <span class="c1"># creates new index file</span>
    577731        <span class="n">iid</span> <span class="o">=</span> <span class="n">grib</span><span class="o">.</span><span class="n">index</span><span class="p">(</span><span class="n">index_keys</span><span class="o">=</span><span class="n">index_keys</span><span class="p">,</span> <span class="n">index_file</span><span class="o">=</span><span class="n">indexfile</span><span class="p">)</span>
     
    580734        <span class="n">index_vals</span> <span class="o">=</span> <span class="p">[]</span>
    581735        <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">index_keys</span><span class="p">:</span>
    582             <span class="c1">#index_vals.append(grib_index_get(iid, key))</span>
    583             <span class="c1">#print(index_vals[-1])</span>
    584             <span class="n">key_vals</span> <span class="o">=</span> <span class="n">grib_index_get</span><span class="p">(</span><span class="n">iid</span><span class="p">,</span> <span class="n">key</span><span class="p">)</span>
    585             <span class="nb">print</span><span class="p">(</span><span class="n">key_vals</span><span class="p">)</span>
    586             <span class="c1"># have to sort the steps for disaggregation,</span>
     736            <span class="n">key_vals</span> <span class="o">=</span> <span class="n">codes_index_get</span><span class="p">(</span><span class="n">iid</span><span class="p">,</span> <span class="n">key</span><span class="p">)</span>
     737            <span class="c1"># have to sort the key values for correct disaggregation,</span>
    587738            <span class="c1"># therefore convert to int first</span>
    588             <span class="k">if</span> <span class="n">key</span> <span class="o">==</span> <span class="s1">&#39;step&#39;</span><span class="p">:</span>
    589                 <span class="n">key_vals</span> <span class="o">=</span> <span class="p">[</span><span class="nb">int</span><span class="p">(</span><span class="n">k</span><span class="p">)</span> <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="n">key_vals</span><span class="p">]</span>
    590                 <span class="n">key_vals</span><span class="o">.</span><span class="n">sort</span><span class="p">()</span>
    591                 <span class="n">key_vals</span> <span class="o">=</span> <span class="p">[</span><span class="nb">str</span><span class="p">(</span><span class="n">k</span><span class="p">)</span> <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="n">key_vals</span><span class="p">]</span>
     739            <span class="n">key_vals</span> <span class="o">=</span> <span class="p">[</span><span class="nb">int</span><span class="p">(</span><span class="n">k</span><span class="p">)</span> <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="n">key_vals</span><span class="p">]</span>
     740            <span class="n">key_vals</span><span class="o">.</span><span class="n">sort</span><span class="p">()</span>
     741            <span class="n">key_vals</span> <span class="o">=</span> <span class="p">[</span><span class="nb">str</span><span class="p">(</span><span class="n">k</span><span class="p">)</span> <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="n">key_vals</span><span class="p">]</span>
    592742            <span class="n">index_vals</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">key_vals</span><span class="p">)</span>
    593743            <span class="c1"># index_vals looks for example like:</span>
     
    606756<span class="sd">        Parameters</span>
    607757<span class="sd">        ----------</span>
    608 <span class="sd">        server : :obj:`ECMWFService` or :obj:`ECMWFDataServer`</span>
     758<span class="sd">        server : ECMWFService or ECMWFDataServer</span>
    609759<span class="sd">            The connection to the ECMWF server. This is different</span>
    610760<span class="sd">            for member state users which have full access and non</span>
     
    614764<span class="sd">            for member state users its False (ECMWFService)</span>
    615765
    616 <span class="sd">        dates : :obj:`string`</span>
     766<span class="sd">        dates : str</span>
    617767<span class="sd">            Contains start and end date of the retrieval in the format</span>
    618768<span class="sd">            &quot;YYYYMMDD/to/YYYYMMDD&quot;</span>
    619769
    620 <span class="sd">        request : :obj:`integer`</span>
     770<span class="sd">        request : int</span>
    621771<span class="sd">            Selects the mode of retrieval.</span>
    622772<span class="sd">            0: Retrieves the data from ECMWF.</span>
     
    624774<span class="sd">            2: Retrieves the data and prints the mars request.</span>
    625775
    626 <span class="sd">        inputdir : :obj:`string`, optional</span>
     776<span class="sd">        inputdir : str, optional</span>
    627777<span class="sd">            Path to the directory where the retrieved data is about</span>
    628778<span class="sd">            to be stored. The default is the current directory (&#39;.&#39;).</span>
     
    693843                <span class="n">retr_param_dict</span><span class="p">[</span><span class="s1">&#39;gaussian&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">gaussian</span>
    694844
    695                 <span class="k">if</span> <span class="n">pk</span> <span class="o">==</span> <span class="s1">&#39;OG__SL&#39;</span><span class="p">:</span>
    696                     <span class="k">pass</span>
    697845                <span class="k">if</span> <span class="n">pk</span> <span class="o">==</span> <span class="s1">&#39;OG_OROLSM__SL&#39;</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">oro</span><span class="p">:</span>
    698846                    <span class="n">oro</span> <span class="o">=</span> <span class="kc">True</span>
     
    814962<span class="sd">        Parameters</span>
    815963<span class="sd">        ----------</span>
    816 <span class="sd">        c : :obj:`ControlFile`</span>
     964<span class="sd">        c : ControlFile</span>
    817965<span class="sd">            Contains all the parameters of CONTROL file and</span>
    818966<span class="sd">            command line.</span>
    819967
    820 <span class="sd">        filename : :obj:`string`</span>
     968<span class="sd">        filename : str</span>
    821969<span class="sd">                Name of the namelist file.</span>
    822970
     
    828976        <span class="kn">from</span> <span class="nn">genshi.template.text</span> <span class="k">import</span> <span class="n">NewTextTemplate</span>
    829977        <span class="kn">from</span> <span class="nn">genshi.template</span> <span class="k">import</span>  <span class="n">TemplateLoader</span>
    830 
    831         <span class="n">loader</span> <span class="o">=</span> <span class="n">TemplateLoader</span><span class="p">(</span><span class="n">_config</span><span class="o">.</span><span class="n">PATH_TEMPLATES</span><span class="p">,</span> <span class="n">auto_reload</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
    832         <span class="n">namelist_template</span> <span class="o">=</span> <span class="n">loader</span><span class="o">.</span><span class="n">load</span><span class="p">(</span><span class="n">_config</span><span class="o">.</span><span class="n">TEMPFILE_NAMELIST</span><span class="p">,</span>
    833                                        <span class="bp">cls</span><span class="o">=</span><span class="n">NewTextTemplate</span><span class="p">)</span>
    834 
    835         <span class="bp">self</span><span class="o">.</span><span class="n">inputdir</span> <span class="o">=</span> <span class="n">c</span><span class="o">.</span><span class="n">inputdir</span>
    836         <span class="n">area</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">asarray</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">area</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s1">&#39;/&#39;</span><span class="p">))</span><span class="o">.</span><span class="n">astype</span><span class="p">(</span><span class="nb">float</span><span class="p">)</span>
    837         <span class="n">grid</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">asarray</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s1">&#39;/&#39;</span><span class="p">))</span><span class="o">.</span><span class="n">astype</span><span class="p">(</span><span class="nb">float</span><span class="p">)</span>
    838 
    839         <span class="k">if</span> <span class="n">area</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">&gt;</span> <span class="n">area</span><span class="p">[</span><span class="mi">3</span><span class="p">]:</span>
    840             <span class="n">area</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">-=</span> <span class="mi">360</span>
    841         <span class="n">maxl</span> <span class="o">=</span> <span class="nb">int</span><span class="p">((</span><span class="n">area</span><span class="p">[</span><span class="mi">3</span><span class="p">]</span> <span class="o">-</span> <span class="n">area</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span> <span class="o">/</span> <span class="n">grid</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span> <span class="o">+</span> <span class="mi">1</span>
    842         <span class="n">maxb</span> <span class="o">=</span> <span class="nb">int</span><span class="p">((</span><span class="n">area</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">-</span> <span class="n">area</span><span class="p">[</span><span class="mi">2</span><span class="p">])</span> <span class="o">/</span> <span class="n">grid</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="o">+</span> <span class="mi">1</span>
    843 
    844         <span class="n">stream</span> <span class="o">=</span> <span class="n">namelist_template</span><span class="o">.</span><span class="n">generate</span><span class="p">(</span>
    845             <span class="n">maxl</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">maxl</span><span class="p">),</span>
    846             <span class="n">maxb</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">maxb</span><span class="p">),</span>
    847             <span class="n">mlevel</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">level</span><span class="p">),</span>
    848             <span class="n">mlevelist</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">levelist</span><span class="p">),</span>
    849             <span class="n">mnauf</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">resol</span><span class="p">),</span>
    850             <span class="n">metapar</span> <span class="o">=</span> <span class="s1">&#39;77&#39;</span><span class="p">,</span>
    851             <span class="n">rlo0</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">area</span><span class="p">[</span><span class="mi">1</span><span class="p">]),</span>
    852             <span class="n">rlo1</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">area</span><span class="p">[</span><span class="mi">3</span><span class="p">]),</span>
    853             <span class="n">rla0</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">area</span><span class="p">[</span><span class="mi">2</span><span class="p">]),</span>
    854             <span class="n">rla1</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">area</span><span class="p">[</span><span class="mi">0</span><span class="p">]),</span>
    855             <span class="n">momega</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">omega</span><span class="p">),</span>
    856             <span class="n">momegadiff</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">omegadiff</span><span class="p">),</span>
    857             <span class="n">mgauss</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">gauss</span><span class="p">),</span>
    858             <span class="n">msmooth</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">smooth</span><span class="p">),</span>
    859             <span class="n">meta</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">eta</span><span class="p">),</span>
    860             <span class="n">metadiff</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">etadiff</span><span class="p">),</span>
    861             <span class="n">mdpdeta</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">dpdeta</span><span class="p">)</span>
    862         <span class="p">)</span>
    863 
    864         <span class="n">namelistfile</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">inputdir</span><span class="p">,</span> <span class="n">_config</span><span class="o">.</span><span class="n">FILE_NAMELIST</span><span class="p">)</span>
    865 
    866         <span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">namelistfile</span><span class="p">,</span> <span class="s1">&#39;w&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
    867             <span class="n">f</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">stream</span><span class="o">.</span><span class="n">render</span><span class="p">(</span><span class="s1">&#39;text&#39;</span><span class="p">))</span>
     978        <span class="kn">from</span> <span class="nn">genshi.template.eval</span> <span class="k">import</span>  <span class="n">UndefinedError</span>
     979
     980        <span class="k">try</span><span class="p">:</span>
     981            <span class="n">loader</span> <span class="o">=</span> <span class="n">TemplateLoader</span><span class="p">(</span><span class="n">_config</span><span class="o">.</span><span class="n">PATH_TEMPLATES</span><span class="p">,</span> <span class="n">auto_reload</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
     982            <span class="n">namelist_template</span> <span class="o">=</span> <span class="n">loader</span><span class="o">.</span><span class="n">load</span><span class="p">(</span><span class="n">_config</span><span class="o">.</span><span class="n">TEMPFILE_NAMELIST</span><span class="p">,</span>
     983                                            <span class="bp">cls</span><span class="o">=</span><span class="n">NewTextTemplate</span><span class="p">)</span>
     984
     985            <span class="bp">self</span><span class="o">.</span><span class="n">inputdir</span> <span class="o">=</span> <span class="n">c</span><span class="o">.</span><span class="n">inputdir</span>
     986            <span class="n">area</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">asarray</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">area</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s1">&#39;/&#39;</span><span class="p">))</span><span class="o">.</span><span class="n">astype</span><span class="p">(</span><span class="nb">float</span><span class="p">)</span>
     987            <span class="n">grid</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">asarray</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s1">&#39;/&#39;</span><span class="p">))</span><span class="o">.</span><span class="n">astype</span><span class="p">(</span><span class="nb">float</span><span class="p">)</span>
     988
     989            <span class="k">if</span> <span class="n">area</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">&gt;</span> <span class="n">area</span><span class="p">[</span><span class="mi">3</span><span class="p">]:</span>
     990                <span class="n">area</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">-=</span> <span class="mi">360</span>
     991            <span class="n">maxl</span> <span class="o">=</span> <span class="nb">int</span><span class="p">((</span><span class="n">area</span><span class="p">[</span><span class="mi">3</span><span class="p">]</span> <span class="o">-</span> <span class="n">area</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span> <span class="o">/</span> <span class="n">grid</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span> <span class="o">+</span> <span class="mi">1</span>
     992            <span class="n">maxb</span> <span class="o">=</span> <span class="nb">int</span><span class="p">((</span><span class="n">area</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">-</span> <span class="n">area</span><span class="p">[</span><span class="mi">2</span><span class="p">])</span> <span class="o">/</span> <span class="n">grid</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="o">+</span> <span class="mi">1</span>
     993
     994            <span class="n">stream</span> <span class="o">=</span> <span class="n">namelist_template</span><span class="o">.</span><span class="n">generate</span><span class="p">(</span>
     995                <span class="n">maxl</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">maxl</span><span class="p">),</span>
     996                <span class="n">maxb</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">maxb</span><span class="p">),</span>
     997                <span class="n">mlevel</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">level</span><span class="p">),</span>
     998                <span class="n">mlevelist</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">levelist</span><span class="p">),</span>
     999                <span class="n">mnauf</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">resol</span><span class="p">),</span>
     1000                <span class="n">metapar</span> <span class="o">=</span> <span class="s1">&#39;77&#39;</span><span class="p">,</span>
     1001                <span class="n">rlo0</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">area</span><span class="p">[</span><span class="mi">1</span><span class="p">]),</span>
     1002                <span class="n">rlo1</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">area</span><span class="p">[</span><span class="mi">3</span><span class="p">]),</span>
     1003                <span class="n">rla0</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">area</span><span class="p">[</span><span class="mi">2</span><span class="p">]),</span>
     1004                <span class="n">rla1</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">area</span><span class="p">[</span><span class="mi">0</span><span class="p">]),</span>
     1005                <span class="n">momega</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">omega</span><span class="p">),</span>
     1006                <span class="n">momegadiff</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">omegadiff</span><span class="p">),</span>
     1007                <span class="n">mgauss</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">gauss</span><span class="p">),</span>
     1008                <span class="n">msmooth</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">smooth</span><span class="p">),</span>
     1009                <span class="n">meta</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">eta</span><span class="p">),</span>
     1010                <span class="n">metadiff</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">etadiff</span><span class="p">),</span>
     1011                <span class="n">mdpdeta</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">dpdeta</span><span class="p">)</span>
     1012            <span class="p">)</span>
     1013        <span class="k">except</span> <span class="n">UndefinedError</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
     1014            <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;... ERROR &#39;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">e</span><span class="p">))</span>
     1015
     1016            <span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="s1">&#39;</span><span class="se">\n</span><span class="s1">... error occured while trying to generate namelist &#39;</span> <span class="o">+</span>
     1017                     <span class="n">_config</span><span class="o">.</span><span class="n">TEMPFILE_NAMELIST</span><span class="p">)</span>
     1018        <span class="k">except</span> <span class="ne">OSError</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
     1019            <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;... ERROR CODE: &#39;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">errno</span><span class="p">))</span>
     1020            <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;... ERROR MESSAGE:</span><span class="se">\n</span><span class="s1"> </span><span class="se">\t</span><span class="s1"> &#39;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">strerror</span><span class="p">))</span>
     1021
     1022            <span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="s1">&#39;</span><span class="se">\n</span><span class="s1">... error occured while trying to generate template &#39;</span> <span class="o">+</span>
     1023                     <span class="n">_config</span><span class="o">.</span><span class="n">TEMPFILE_NAMELIST</span><span class="p">)</span>
     1024
     1025        <span class="k">try</span><span class="p">:</span>
     1026            <span class="n">namelistfile</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">inputdir</span><span class="p">,</span> <span class="n">_config</span><span class="o">.</span><span class="n">FILE_NAMELIST</span><span class="p">)</span>
     1027
     1028            <span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">namelistfile</span><span class="p">,</span> <span class="s1">&#39;w&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
     1029                <span class="n">f</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">stream</span><span class="o">.</span><span class="n">render</span><span class="p">(</span><span class="s1">&#39;text&#39;</span><span class="p">))</span>
     1030        <span class="k">except</span> <span class="ne">OSError</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
     1031            <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;... ERROR CODE: &#39;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">errno</span><span class="p">))</span>
     1032            <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;... ERROR MESSAGE:</span><span class="se">\n</span><span class="s1"> </span><span class="se">\t</span><span class="s1"> &#39;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">strerror</span><span class="p">))</span>
     1033
     1034            <span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="s1">&#39;</span><span class="se">\n</span><span class="s1">... error occured while trying to write &#39;</span> <span class="o">+</span>
     1035                     <span class="n">namelistfile</span><span class="p">)</span>
    8681036
    8691037        <span class="k">return</span></div>
     
    8711039
    8721040<div class="viewcode-block" id="EcFlexpart.deacc_fluxes"><a class="viewcode-back" href="../api.html#EcFlexpart.EcFlexpart.deacc_fluxes">[docs]</a>    <span class="k">def</span> <span class="nf">deacc_fluxes</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">inputfiles</span><span class="p">,</span> <span class="n">c</span><span class="p">):</span>
    873         <span class="sd">&#39;&#39;&#39;Goes through all flux fields in ordered time and de-accumulate</span>
     1041        <span class="sd">&#39;&#39;&#39;De-accumulate and disaggregate flux data.</span>
     1042
     1043<span class="sd">        Goes through all flux fields in ordered time and de-accumulate</span>
    8741044<span class="sd">        the fields. Afterwards the fields are disaggregated in time.</span>
    8751045<span class="sd">        Different versions of disaggregation is provided for rainfall</span>
     
    8791049<span class="sd">        Parameters</span>
    8801050<span class="sd">        ----------</span>
    881 <span class="sd">        inputfiles : :obj:`UioFiles`</span>
    882 <span class="sd">            Contains a list of files.</span>
    883 
    884 <span class="sd">        c : :obj:`ControlFile`</span>
     1051<span class="sd">        inputfiles : UioFiles</span>
     1052<span class="sd">            Contains the list of files that contain flux data.</span>
     1053
     1054<span class="sd">        c : ControlFile</span>
    8851055<span class="sd">            Contains all the parameters of CONTROL file and</span>
    8861056<span class="sd">            command line.</span>
     
    9051075        <span class="c1"># index_vals looks like e.g.:</span>
    9061076        <span class="c1"># index_vals[0]: (&#39;20171106&#39;, &#39;20171107&#39;, &#39;20171108&#39;) ; date</span>
    907         <span class="c1"># index_vals[1]: (&#39;0&#39;, &#39;1200&#39;, &#39;1800&#39;, &#39;600&#39;) ; time</span>
    908         <span class="c1"># index_vals[2]: (&#39;0&#39;, &#39;12&#39;, &#39;3&#39;, &#39;6&#39;, &#39;9&#39;) ; stepRange</span>
    909 
    910         <span class="n">valsdict</span> <span class="o">=</span> <span class="p">{}</span>
    911         <span class="n">svalsdict</span> <span class="o">=</span> <span class="p">{}</span>
    912 <span class="c1">#        stepsdict = {}</span>
     1077        <span class="c1"># index_vals[1]: (&#39;0&#39;, &#39;600&#39;, &#39;1200&#39;, &#39;1800&#39;) ; time</span>
     1078        <span class="c1"># index_vals[2]: (&#39;0&#39;, &#39;3&#39;, &#39;6&#39;, &#39;9&#39;, &#39;12&#39;) ; stepRange</span>
     1079
     1080        <span class="k">if</span> <span class="n">c</span><span class="o">.</span><span class="n">rrint</span><span class="p">:</span>
     1081            <span class="k">if</span> <span class="ow">not</span> <span class="n">c</span><span class="o">.</span><span class="n">purefc</span><span class="p">:</span>
     1082                <span class="n">start_date</span> <span class="o">=</span> <span class="n">datetime</span><span class="o">.</span><span class="n">strptime</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">start_date</span> <span class="o">+</span> <span class="s1">&#39;00&#39;</span><span class="p">,</span> <span class="s1">&#39;%Y%m</span><span class="si">%d</span><span class="s1">%H&#39;</span><span class="p">)</span>
     1083                <span class="n">end_date</span> <span class="o">=</span> <span class="n">datetime</span><span class="o">.</span><span class="n">strptime</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">end_date</span> <span class="o">+</span> <span class="s1">&#39;23&#39;</span><span class="p">,</span> <span class="s1">&#39;%Y%m</span><span class="si">%d</span><span class="s1">%H&#39;</span><span class="p">)</span>
     1084            <span class="k">else</span><span class="p">:</span>
     1085                <span class="n">sdate_str</span> <span class="o">=</span> <span class="n">c</span><span class="o">.</span><span class="n">start_date</span> <span class="o">+</span> <span class="s1">&#39;</span><span class="si">{:0&gt;2}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">index_vals</span><span class="p">[</span><span class="mi">1</span><span class="p">][</span><span class="mi">0</span><span class="p">])</span>
     1086                <span class="n">start_date</span> <span class="o">=</span> <span class="n">datetime</span><span class="o">.</span><span class="n">strptime</span><span class="p">(</span><span class="n">sdate_str</span><span class="p">,</span> <span class="s1">&#39;%Y%m</span><span class="si">%d</span><span class="s1">%H&#39;</span><span class="p">)</span>
     1087                <span class="n">edate_str</span> <span class="o">=</span> <span class="n">c</span><span class="o">.</span><span class="n">end_date</span> <span class="o">+</span> <span class="s1">&#39;</span><span class="si">{:0&gt;2}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">index_vals</span><span class="p">[</span><span class="mi">1</span><span class="p">][</span><span class="o">-</span><span class="mi">1</span><span class="p">])</span>
     1088                <span class="n">end_date</span> <span class="o">=</span> <span class="n">datetime</span><span class="o">.</span><span class="n">strptime</span><span class="p">(</span><span class="n">edate_str</span><span class="p">,</span> <span class="s1">&#39;%Y%m</span><span class="si">%d</span><span class="s1">%H&#39;</span><span class="p">)</span>
     1089                <span class="n">end_date</span> <span class="o">=</span> <span class="n">end_date</span> <span class="o">+</span> <span class="n">timedelta</span><span class="p">(</span><span class="n">hours</span><span class="o">=</span><span class="n">c</span><span class="o">.</span><span class="n">maxstep</span><span class="p">)</span>
     1090
     1091            <span class="n">info</span> <span class="o">=</span> <span class="n">get_informations</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">inputdir</span><span class="p">,</span>
     1092                                                 <span class="n">inputfiles</span><span class="o">.</span><span class="n">files</span><span class="p">[</span><span class="mi">0</span><span class="p">]))</span>
     1093            <span class="n">dims</span> <span class="o">=</span> <span class="n">get_dimensions</span><span class="p">(</span><span class="n">info</span><span class="p">,</span> <span class="n">c</span><span class="o">.</span><span class="n">purefc</span><span class="p">,</span> <span class="n">c</span><span class="o">.</span><span class="n">dtime</span><span class="p">,</span> <span class="n">index_vals</span><span class="p">,</span>
     1094                                  <span class="n">start_date</span><span class="p">,</span> <span class="n">end_date</span><span class="p">)</span>
     1095            <span class="c1"># create numpy array</span>
     1096            <span class="n">lsp_np</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">((</span><span class="n">dims</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">*</span> <span class="n">dims</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">dims</span><span class="p">[</span><span class="mi">2</span><span class="p">]),</span> <span class="n">dtype</span><span class="o">=</span><span class="n">np</span><span class="o">.</span><span class="n">float64</span><span class="p">)</span>
     1097            <span class="n">cp_np</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">((</span><span class="n">dims</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">*</span> <span class="n">dims</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">dims</span><span class="p">[</span><span class="mi">2</span><span class="p">]),</span> <span class="n">dtype</span><span class="o">=</span><span class="n">np</span><span class="o">.</span><span class="n">float64</span><span class="p">)</span>
     1098            <span class="n">it_lsp</span> <span class="o">=</span> <span class="mi">0</span>
     1099            <span class="n">it_cp</span> <span class="o">=</span> <span class="mi">0</span>
     1100            <span class="n">date_list</span> <span class="o">=</span> <span class="p">[]</span>
     1101            <span class="n">step_list</span> <span class="o">=</span> <span class="p">[]</span>
     1102
     1103        <span class="c1"># initialize dictionaries to store values</span>
     1104        <span class="n">orig_vals</span> <span class="o">=</span> <span class="p">{}</span>
     1105        <span class="n">deac_vals</span> <span class="o">=</span> <span class="p">{}</span>
    9131106        <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">pars</span><span class="p">:</span>
    914             <span class="n">valsdict</span><span class="p">[</span><span class="nb">str</span><span class="p">(</span><span class="n">p</span><span class="p">)]</span> <span class="o">=</span> <span class="p">[]</span>
    915             <span class="n">svalsdict</span><span class="p">[</span><span class="nb">str</span><span class="p">(</span><span class="n">p</span><span class="p">)]</span> <span class="o">=</span> <span class="p">[]</span>
    916 <span class="c1">#            stepsdict[str(p)] = []</span>
    917 
    918         <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;maxstep: &#39;</span><span class="p">,</span> <span class="n">c</span><span class="o">.</span><span class="n">maxstep</span><span class="p">)</span>
     1107            <span class="n">orig_vals</span><span class="p">[</span><span class="n">p</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span>
     1108            <span class="n">deac_vals</span><span class="p">[</span><span class="n">p</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span>
    9191109
    9201110        <span class="c1"># &quot;product&quot; genereates each possible combination between the</span>
     
    9241114            <span class="c1">#             (  date    ,time, step)</span>
    9251115
    926             <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;current product: &#39;</span><span class="p">,</span> <span class="n">prod</span><span class="p">)</span>
     1116            <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;CURRENT PRODUCT: &#39;</span><span class="p">,</span> <span class="n">prod</span><span class="p">)</span>
    9271117
    9281118            <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">index_keys</span><span class="p">)):</span>
    929                 <span class="n">grib_index_select</span><span class="p">(</span><span class="n">iid</span><span class="p">,</span> <span class="n">index_keys</span><span class="p">[</span><span class="n">i</span><span class="p">],</span> <span class="n">prod</span><span class="p">[</span><span class="n">i</span><span class="p">])</span>
     1119                <span class="n">codes_index_select</span><span class="p">(</span><span class="n">iid</span><span class="p">,</span> <span class="n">index_keys</span><span class="p">[</span><span class="n">i</span><span class="p">],</span> <span class="n">prod</span><span class="p">[</span><span class="n">i</span><span class="p">])</span>
    9301120
    9311121            <span class="c1"># get first id from current product</span>
    932             <span class="n">gid</span> <span class="o">=</span> <span class="n">grib_new_from_index</span><span class="p">(</span><span class="n">iid</span><span class="p">)</span>
     1122            <span class="n">gid</span> <span class="o">=</span> <span class="n">codes_new_from_index</span><span class="p">(</span><span class="n">iid</span><span class="p">)</span>
    9331123
    9341124            <span class="c1"># if there is no data for this specific time combination / product</span>
     
    9381128
    9391129            <span class="c1"># create correct timestamp from the three time informations</span>
    940             <span class="n">cdate</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">grib_get</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="s1">&#39;date&#39;</span><span class="p">))</span>
    941             <span class="n">ctime</span> <span class="o">=</span> <span class="s1">&#39;</span><span class="si">{:0&gt;2}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">grib_get</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="s1">&#39;time&#39;</span><span class="p">)</span><span class="o">/</span><span class="mi">100</span><span class="p">)</span>
    942             <span class="n">cstep</span> <span class="o">=</span> <span class="s1">&#39;</span><span class="si">{:0&gt;3}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">grib_get</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="s1">&#39;step&#39;</span><span class="p">))</span>
     1130            <span class="n">cdate</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">codes_get</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="s1">&#39;date&#39;</span><span class="p">))</span>
     1131            <span class="n">time</span> <span class="o">=</span> <span class="n">codes_get</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="s1">&#39;time&#39;</span><span class="p">)</span><span class="o">/</span><span class="mi">100</span> <span class="c1"># integer</span>
     1132            <span class="n">step</span> <span class="o">=</span> <span class="n">codes_get</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="s1">&#39;step&#39;</span><span class="p">)</span> <span class="c1"># integer</span>
     1133            <span class="n">ctime</span> <span class="o">=</span> <span class="s1">&#39;</span><span class="si">{:0&gt;2}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">time</span><span class="p">)</span>
     1134            <span class="n">cstep</span> <span class="o">=</span> <span class="s1">&#39;</span><span class="si">{:0&gt;3}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">step</span><span class="p">)</span>
     1135
    9431136            <span class="n">t_date</span> <span class="o">=</span> <span class="n">datetime</span><span class="o">.</span><span class="n">strptime</span><span class="p">(</span><span class="n">cdate</span> <span class="o">+</span> <span class="n">ctime</span><span class="p">,</span> <span class="s1">&#39;%Y%m</span><span class="si">%d</span><span class="s1">%H&#39;</span><span class="p">)</span>
    944             <span class="n">t_dt</span> <span class="o">=</span> <span class="n">t_date</span> <span class="o">+</span> <span class="n">timedelta</span><span class="p">(</span><span class="n">hours</span><span class="o">=</span><span class="nb">int</span><span class="p">(</span><span class="n">cstep</span><span class="p">))</span>
    945             <span class="n">t_m1dt</span> <span class="o">=</span> <span class="n">t_date</span> <span class="o">+</span> <span class="n">timedelta</span><span class="p">(</span><span class="n">hours</span><span class="o">=</span><span class="nb">int</span><span class="p">(</span><span class="n">cstep</span><span class="p">)</span><span class="o">-</span><span class="nb">int</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">dtime</span><span class="p">))</span>
    946             <span class="n">t_m2dt</span> <span class="o">=</span> <span class="n">t_date</span> <span class="o">+</span> <span class="n">timedelta</span><span class="p">(</span><span class="n">hours</span><span class="o">=</span><span class="nb">int</span><span class="p">(</span><span class="n">cstep</span><span class="p">)</span><span class="o">-</span><span class="mi">2</span><span class="o">*</span><span class="nb">int</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">dtime</span><span class="p">))</span>
     1137            <span class="n">t_dt</span> <span class="o">=</span> <span class="n">t_date</span> <span class="o">+</span> <span class="n">timedelta</span><span class="p">(</span><span class="n">hours</span><span class="o">=</span><span class="n">step</span><span class="p">)</span>
     1138            <span class="n">t_m1dt</span> <span class="o">=</span> <span class="n">t_date</span> <span class="o">+</span> <span class="n">timedelta</span><span class="p">(</span><span class="n">hours</span><span class="o">=</span><span class="n">step</span><span class="o">-</span><span class="nb">int</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">dtime</span><span class="p">))</span>
     1139            <span class="n">t_m2dt</span> <span class="o">=</span> <span class="n">t_date</span> <span class="o">+</span> <span class="n">timedelta</span><span class="p">(</span><span class="n">hours</span><span class="o">=</span><span class="n">step</span><span class="o">-</span><span class="mi">2</span><span class="o">*</span><span class="nb">int</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">dtime</span><span class="p">))</span>
    9471140            <span class="n">t_enddate</span> <span class="o">=</span> <span class="kc">None</span>
    9481141
    949             <span class="k">if</span> <span class="n">c</span><span class="o">.</span><span class="n">maxstep</span> <span class="o">&gt;</span> <span class="mi">12</span><span class="p">:</span>
     1142            <span class="k">if</span> <span class="n">c</span><span class="o">.</span><span class="n">purefc</span><span class="p">:</span>
    9501143                <span class="n">fnout</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">inputdir</span><span class="p">,</span> <span class="s1">&#39;flux&#39;</span> <span class="o">+</span>
    9511144                                     <span class="n">t_date</span><span class="o">.</span><span class="n">strftime</span><span class="p">(</span><span class="s1">&#39;%Y%m</span><span class="si">%d</span><span class="s1">.%H&#39;</span><span class="p">)</span> <span class="o">+</span>
     
    9661159
    9671160            <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;outputfile = &quot;</span> <span class="o">+</span> <span class="n">fnout</span><span class="p">)</span>
    968 
    969             <span class="c1"># read message for message and store relevant data fields</span>
     1161            <span class="n">f_handle</span> <span class="o">=</span> <span class="nb">open</span><span class="p">(</span><span class="n">fnout</span><span class="p">,</span> <span class="s1">&#39;w&#39;</span><span class="p">)</span>
     1162            <span class="n">h_handle</span> <span class="o">=</span> <span class="nb">open</span><span class="p">(</span><span class="n">hnout</span><span class="p">,</span> <span class="s1">&#39;w&#39;</span><span class="p">)</span>
     1163            <span class="n">g_handle</span> <span class="o">=</span> <span class="nb">open</span><span class="p">(</span><span class="n">gnout</span><span class="p">,</span> <span class="s1">&#39;w&#39;</span><span class="p">)</span>
     1164
     1165            <span class="c1"># read message for message and store relevant data fields, where</span>
    9701166            <span class="c1"># data keywords are stored in pars</span>
    971             <span class="k">while</span> <span class="mi">1</span><span class="p">:</span>
     1167            <span class="k">while</span> <span class="kc">True</span><span class="p">:</span>
    9721168                <span class="k">if</span> <span class="ow">not</span> <span class="n">gid</span><span class="p">:</span>
    9731169                    <span class="k">break</span>
    974                 <span class="n">cparamId</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">grib_get</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="s1">&#39;paramId&#39;</span><span class="p">))</span>
    975                 <span class="n">step</span> <span class="o">=</span> <span class="n">grib_get</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="s1">&#39;step&#39;</span><span class="p">)</span>
    976                 <span class="n">time</span> <span class="o">=</span> <span class="n">grib_get</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="s1">&#39;time&#39;</span><span class="p">)</span>
    977                 <span class="n">ni</span> <span class="o">=</span> <span class="n">grib_get</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="s1">&#39;Ni&#39;</span><span class="p">)</span>
    978                 <span class="n">nj</span> <span class="o">=</span> <span class="n">grib_get</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="s1">&#39;Nj&#39;</span><span class="p">)</span>
    979                 <span class="k">if</span> <span class="n">cparamId</span> <span class="ow">in</span> <span class="n">valsdict</span><span class="o">.</span><span class="n">keys</span><span class="p">():</span>
    980                     <span class="n">values</span> <span class="o">=</span> <span class="n">grib_get_values</span><span class="p">(</span><span class="n">gid</span><span class="p">)</span>
    981                     <span class="n">vdp</span> <span class="o">=</span> <span class="n">valsdict</span><span class="p">[</span><span class="n">cparamId</span><span class="p">]</span>
    982                     <span class="n">svdp</span> <span class="o">=</span> <span class="n">svalsdict</span><span class="p">[</span><span class="n">cparamId</span><span class="p">]</span>
    983  <span class="c1">#                   sd = stepsdict[cparamId]</span>
    984 
    985                     <span class="k">if</span> <span class="n">cparamId</span> <span class="o">==</span> <span class="s1">&#39;142&#39;</span> <span class="ow">or</span> <span class="n">cparamId</span> <span class="o">==</span> <span class="s1">&#39;143&#39;</span><span class="p">:</span>
    986                         <span class="n">fak</span> <span class="o">=</span> <span class="mf">1.</span> <span class="o">/</span> <span class="mf">1000.</span>
     1170                <span class="n">parId</span> <span class="o">=</span> <span class="n">codes_get</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="s1">&#39;paramId&#39;</span><span class="p">)</span> <span class="c1"># integer</span>
     1171                <span class="n">step</span> <span class="o">=</span> <span class="n">codes_get</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="s1">&#39;step&#39;</span><span class="p">)</span> <span class="c1"># integer</span>
     1172                <span class="n">time</span> <span class="o">=</span> <span class="n">codes_get</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="s1">&#39;time&#39;</span><span class="p">)</span> <span class="c1"># integer</span>
     1173                <span class="n">ni</span> <span class="o">=</span> <span class="n">codes_get</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="s1">&#39;Ni&#39;</span><span class="p">)</span> <span class="c1"># integer</span>
     1174                <span class="n">nj</span> <span class="o">=</span> <span class="n">codes_get</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="s1">&#39;Nj&#39;</span><span class="p">)</span> <span class="c1"># integer</span>
     1175                <span class="k">if</span> <span class="n">parId</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">orig_vals</span><span class="o">.</span><span class="n">keys</span><span class="p">():</span>
     1176                    <span class="c1"># parameter is not a flux, find next one</span>
     1177                    <span class="k">continue</span>
     1178
     1179                <span class="c1"># define conversion factor</span>
     1180                <span class="k">if</span> <span class="n">parId</span> <span class="o">==</span> <span class="mi">142</span> <span class="ow">or</span> <span class="n">parId</span> <span class="o">==</span> <span class="mi">143</span><span class="p">:</span>
     1181                    <span class="n">fak</span> <span class="o">=</span> <span class="mf">1.</span> <span class="o">/</span> <span class="mf">1000.</span>
     1182                <span class="k">else</span><span class="p">:</span>
     1183                    <span class="n">fak</span> <span class="o">=</span> <span class="mf">3600.</span>
     1184
     1185                <span class="c1"># get parameter values and reshape</span>
     1186                <span class="n">values</span> <span class="o">=</span> <span class="n">codes_get_values</span><span class="p">(</span><span class="n">gid</span><span class="p">)</span>
     1187                <span class="n">values</span> <span class="o">=</span> <span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">reshape</span><span class="p">(</span><span class="n">values</span><span class="p">,</span> <span class="p">(</span><span class="n">nj</span><span class="p">,</span> <span class="n">ni</span><span class="p">)))</span><span class="o">.</span><span class="n">flatten</span><span class="p">()</span> <span class="o">/</span> <span class="n">fak</span>
     1188
     1189                <span class="c1"># save the original and accumulated values</span>
     1190                <span class="n">orig_vals</span><span class="p">[</span><span class="n">parId</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">values</span><span class="p">[:])</span>
     1191
     1192                <span class="k">if</span> <span class="n">c</span><span class="o">.</span><span class="n">marsclass</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> <span class="o">==</span> <span class="s1">&#39;EA&#39;</span> <span class="ow">or</span> <span class="n">step</span> <span class="o">&lt;=</span> <span class="nb">int</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">dtime</span><span class="p">):</span>
     1193                    <span class="c1"># no de-accumulation needed</span>
     1194                    <span class="n">deac_vals</span><span class="p">[</span><span class="n">parId</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">values</span><span class="p">[:]</span> <span class="o">/</span> <span class="nb">int</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">dtime</span><span class="p">))</span>
     1195                <span class="k">else</span><span class="p">:</span>
     1196                    <span class="c1"># do de-accumulation</span>
     1197                    <span class="n">deac_vals</span><span class="p">[</span><span class="n">parId</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span>
     1198                        <span class="p">(</span><span class="n">orig_vals</span><span class="p">[</span><span class="n">parId</span><span class="p">][</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span> <span class="o">-</span> <span class="n">orig_vals</span><span class="p">[</span><span class="n">parId</span><span class="p">][</span><span class="o">-</span><span class="mi">2</span><span class="p">])</span> <span class="o">/</span>
     1199                         <span class="nb">int</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">dtime</span><span class="p">))</span>
     1200
     1201                <span class="c1"># store precipitation if new disaggregation method is selected</span>
     1202                <span class="c1"># only the exact days are needed</span>
     1203                <span class="k">if</span> <span class="n">c</span><span class="o">.</span><span class="n">rrint</span><span class="p">:</span>
     1204                    <span class="k">if</span> <span class="n">start_date</span> <span class="o">&lt;=</span> <span class="n">t_dt</span> <span class="o">&lt;=</span> <span class="n">end_date</span><span class="p">:</span>
     1205                        <span class="k">if</span> <span class="ow">not</span> <span class="n">c</span><span class="o">.</span><span class="n">purefc</span><span class="p">:</span>
     1206                            <span class="k">if</span> <span class="n">t_dt</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">date_list</span><span class="p">:</span>
     1207                                <span class="n">date_list</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">t_dt</span><span class="p">)</span>
     1208                                <span class="n">step_list</span> <span class="o">=</span> <span class="p">[</span><span class="mi">0</span><span class="p">]</span>
     1209                        <span class="k">else</span><span class="p">:</span>
     1210                            <span class="k">if</span> <span class="n">t_date</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">date_list</span><span class="p">:</span>
     1211                                <span class="n">date_list</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">t_date</span><span class="p">)</span>
     1212                            <span class="k">if</span> <span class="n">step</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">step_list</span><span class="p">:</span>
     1213                                <span class="n">step_list</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">step</span><span class="p">)</span>
     1214                        <span class="k">if</span> <span class="n">c</span><span class="o">.</span><span class="n">rrint</span> <span class="ow">and</span> <span class="n">parId</span> <span class="o">==</span> <span class="mi">142</span><span class="p">:</span>
     1215                            <span class="n">lsp_np</span><span class="p">[:,</span><span class="n">it_lsp</span><span class="p">]</span> <span class="o">=</span> <span class="n">deac_vals</span><span class="p">[</span><span class="n">parId</span><span class="p">][</span><span class="o">-</span><span class="mi">1</span><span class="p">][:]</span>
     1216                            <span class="n">it_lsp</span> <span class="o">+=</span> <span class="mi">1</span>
     1217                        <span class="k">elif</span> <span class="n">c</span><span class="o">.</span><span class="n">rrint</span> <span class="ow">and</span> <span class="n">parId</span> <span class="o">==</span> <span class="mi">143</span><span class="p">:</span>
     1218                            <span class="n">cp_np</span><span class="p">[:,</span><span class="n">it_cp</span><span class="p">]</span> <span class="o">=</span> <span class="n">deac_vals</span><span class="p">[</span><span class="n">parId</span><span class="p">][</span><span class="o">-</span><span class="mi">1</span><span class="p">][:]</span>
     1219                            <span class="n">it_cp</span> <span class="o">+=</span> <span class="mi">1</span>
     1220
     1221                <span class="c1"># information printout</span>
     1222                <span class="nb">print</span><span class="p">(</span><span class="n">parId</span><span class="p">,</span> <span class="n">time</span><span class="p">,</span> <span class="n">step</span><span class="p">,</span> <span class="nb">len</span><span class="p">(</span><span class="n">values</span><span class="p">),</span> <span class="n">values</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">np</span><span class="o">.</span><span class="n">std</span><span class="p">(</span><span class="n">values</span><span class="p">))</span>
     1223
     1224                <span class="c1"># length of deac_vals[parId] corresponds to the</span>
     1225                <span class="c1"># number of time steps, max. 4 are needed for disaggegration</span>
     1226                <span class="c1"># with the old and original method</span>
     1227                <span class="c1"># run over all grib messages and perform</span>
     1228                <span class="c1"># shifting in time</span>
     1229                <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">deac_vals</span><span class="p">[</span><span class="n">parId</span><span class="p">])</span> <span class="o">&gt;=</span> <span class="mi">3</span><span class="p">:</span>
     1230                    <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">deac_vals</span><span class="p">[</span><span class="n">parId</span><span class="p">])</span> <span class="o">&gt;</span> <span class="mi">3</span><span class="p">:</span>
     1231                        <span class="k">if</span> <span class="ow">not</span> <span class="n">c</span><span class="o">.</span><span class="n">rrint</span> <span class="ow">and</span> <span class="p">(</span><span class="n">parId</span> <span class="o">==</span> <span class="mi">142</span> <span class="ow">or</span> <span class="n">parId</span> <span class="o">==</span> <span class="mi">143</span><span class="p">):</span>
     1232                            <span class="n">values</span> <span class="o">=</span> <span class="n">disaggregation</span><span class="o">.</span><span class="n">darain</span><span class="p">(</span><span class="n">deac_vals</span><span class="p">[</span><span class="n">parId</span><span class="p">])</span>
     1233                        <span class="k">else</span><span class="p">:</span>
     1234                            <span class="n">values</span> <span class="o">=</span> <span class="n">disaggregation</span><span class="o">.</span><span class="n">dapoly</span><span class="p">(</span><span class="n">deac_vals</span><span class="p">[</span><span class="n">parId</span><span class="p">])</span>
     1235
     1236                        <span class="k">if</span> <span class="ow">not</span> <span class="p">(</span><span class="n">step</span> <span class="o">==</span> <span class="n">c</span><span class="o">.</span><span class="n">maxstep</span> <span class="ow">and</span> <span class="n">c</span><span class="o">.</span><span class="n">purefc</span> \
     1237                                <span class="ow">or</span> <span class="n">t_dt</span> <span class="o">==</span> <span class="n">t_enddate</span><span class="p">):</span>
     1238                            <span class="c1"># remove first time step in list to shift</span>
     1239                            <span class="c1"># time line</span>
     1240                            <span class="n">orig_vals</span><span class="p">[</span><span class="n">parId</span><span class="p">]</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span>
     1241                            <span class="n">deac_vals</span><span class="p">[</span><span class="n">parId</span><span class="p">]</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span>
    9871242                    <span class="k">else</span><span class="p">:</span>
    988                         <span class="n">fak</span> <span class="o">=</span> <span class="mf">3600.</span>
    989 
    990                     <span class="n">values</span> <span class="o">=</span> <span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">reshape</span><span class="p">(</span><span class="n">values</span><span class="p">,</span> <span class="p">(</span><span class="n">nj</span><span class="p">,</span> <span class="n">ni</span><span class="p">)))</span><span class="o">.</span><span class="n">flatten</span><span class="p">()</span> <span class="o">/</span> <span class="n">fak</span>
    991                     <span class="n">vdp</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">values</span><span class="p">[:])</span>  <span class="c1"># save the accumulated values</span>
    992                     <span class="k">if</span> <span class="n">c</span><span class="o">.</span><span class="n">marsclass</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> <span class="o">==</span> <span class="s1">&#39;EA&#39;</span> <span class="ow">or</span> \
    993                        <span class="n">step</span> <span class="o">&lt;=</span> <span class="nb">int</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">dtime</span><span class="p">):</span>
    994                         <span class="n">svdp</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">values</span><span class="p">[:]</span> <span class="o">/</span> <span class="nb">int</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">dtime</span><span class="p">))</span>
    995                     <span class="k">else</span><span class="p">:</span>  <span class="c1"># deaccumulate values</span>
    996                         <span class="n">svdp</span><span class="o">.</span><span class="n">append</span><span class="p">((</span><span class="n">vdp</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span> <span class="o">-</span> <span class="n">vdp</span><span class="p">[</span><span class="o">-</span><span class="mi">2</span><span class="p">])</span> <span class="o">/</span> <span class="nb">int</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">dtime</span><span class="p">))</span>
    997 
    998                     <span class="nb">print</span><span class="p">(</span><span class="n">cparamId</span><span class="p">,</span> <span class="n">time</span><span class="p">,</span> <span class="n">step</span><span class="p">,</span> <span class="nb">len</span><span class="p">(</span><span class="n">values</span><span class="p">),</span>
    999                           <span class="n">values</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">np</span><span class="o">.</span><span class="n">std</span><span class="p">(</span><span class="n">values</span><span class="p">))</span>
    1000 
    1001                     <span class="c1"># len(svdp) correspond to the time</span>
    1002                     <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">svdp</span><span class="p">)</span> <span class="o">&gt;=</span> <span class="mi">3</span><span class="p">:</span>
    1003                         <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">svdp</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">3</span><span class="p">:</span>
    1004                             <span class="k">if</span> <span class="n">cparamId</span> <span class="o">==</span> <span class="s1">&#39;142&#39;</span> <span class="ow">or</span> <span class="n">cparamId</span> <span class="o">==</span> <span class="s1">&#39;143&#39;</span><span class="p">:</span>
    1005                                 <span class="n">values</span> <span class="o">=</span> <span class="n">disaggregation</span><span class="o">.</span><span class="n">darain</span><span class="p">(</span><span class="n">svdp</span><span class="p">)</span>
    1006                             <span class="k">else</span><span class="p">:</span>
    1007                                 <span class="n">values</span> <span class="o">=</span> <span class="n">disaggregation</span><span class="o">.</span><span class="n">dapoly</span><span class="p">(</span><span class="n">svdp</span><span class="p">)</span>
    1008 
    1009                             <span class="k">if</span> <span class="ow">not</span> <span class="p">(</span><span class="n">step</span> <span class="o">==</span> <span class="n">c</span><span class="o">.</span><span class="n">maxstep</span> <span class="ow">and</span> <span class="n">c</span><span class="o">.</span><span class="n">maxstep</span> <span class="o">&gt;</span> <span class="mi">12</span> \
    1010                                     <span class="ow">or</span> <span class="n">t_dt</span> <span class="o">==</span> <span class="n">t_enddate</span><span class="p">):</span>
    1011                                 <span class="n">vdp</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span>
    1012                                 <span class="n">svdp</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span>
     1243                        <span class="c1"># if the third time step is read (per parId),</span>
     1244                        <span class="c1"># write out the first one as a boundary value</span>
     1245                        <span class="k">if</span> <span class="n">c</span><span class="o">.</span><span class="n">purefc</span><span class="p">:</span>
     1246                            <span class="n">values</span> <span class="o">=</span> <span class="n">deac_vals</span><span class="p">[</span><span class="n">parId</span><span class="p">][</span><span class="mi">1</span><span class="p">]</span>
    10131247                        <span class="k">else</span><span class="p">:</span>
    1014                             <span class="k">if</span> <span class="n">c</span><span class="o">.</span><span class="n">maxstep</span> <span class="o">&gt;</span> <span class="mi">12</span><span class="p">:</span>
    1015                                 <span class="n">values</span> <span class="o">=</span> <span class="n">svdp</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>
    1016                             <span class="k">else</span><span class="p">:</span>
    1017                                 <span class="n">values</span> <span class="o">=</span> <span class="n">svdp</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
    1018 
    1019                         <span class="n">grib_set_values</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="n">values</span><span class="p">)</span>
    1020 
    1021                         <span class="k">if</span> <span class="n">c</span><span class="o">.</span><span class="n">maxstep</span> <span class="o">&gt;</span> <span class="mi">12</span><span class="p">:</span>
    1022                             <span class="n">grib_set</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="s1">&#39;step&#39;</span><span class="p">,</span> <span class="nb">max</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">step</span><span class="o">-</span><span class="mi">2</span><span class="o">*</span><span class="nb">int</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">dtime</span><span class="p">)))</span>
     1248                            <span class="n">values</span> <span class="o">=</span> <span class="n">deac_vals</span><span class="p">[</span><span class="n">parId</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span>
     1249
     1250                    <span class="k">if</span> <span class="ow">not</span> <span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">rrint</span> <span class="ow">and</span> <span class="p">(</span><span class="n">parId</span> <span class="o">==</span> <span class="mi">142</span> <span class="ow">or</span> <span class="n">parId</span> <span class="o">==</span> <span class="mi">143</span><span class="p">)):</span>
     1251                        <span class="n">codes_set_values</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="n">values</span><span class="p">)</span>
     1252
     1253                        <span class="k">if</span> <span class="n">c</span><span class="o">.</span><span class="n">purefc</span><span class="p">:</span>
     1254                            <span class="n">codes_set</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="s1">&#39;stepRange&#39;</span><span class="p">,</span> <span class="nb">max</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">step</span><span class="o">-</span><span class="mi">2</span><span class="o">*</span><span class="nb">int</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">dtime</span><span class="p">)))</span>
    10231255                        <span class="k">else</span><span class="p">:</span>
    1024                             <span class="n">grib_set</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="s1">&#39;step&#39;</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span>
    1025                             <span class="n">grib_set</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="s1">&#39;time&#39;</span><span class="p">,</span> <span class="n">t_m2dt</span><span class="o">.</span><span class="n">hour</span><span class="o">*</span><span class="mi">100</span><span class="p">)</span>
    1026                             <span class="n">grib_set</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="s1">&#39;date&#39;</span><span class="p">,</span> <span class="nb">int</span><span class="p">(</span><span class="n">t_m2dt</span><span class="o">.</span><span class="n">strftime</span><span class="p">(</span><span class="s1">&#39;%Y%m</span><span class="si">%d</span><span class="s1">&#39;</span><span class="p">)))</span>
    1027 
    1028                         <span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">fnout</span><span class="p">,</span> <span class="s1">&#39;w&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">f_handle</span><span class="p">:</span>
    1029                             <span class="n">grib_write</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="n">f_handle</span><span class="p">)</span>
     1256                            <span class="n">codes_set</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="s1">&#39;stepRange&#39;</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span>
     1257                            <span class="n">codes_set</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="s1">&#39;time&#39;</span><span class="p">,</span> <span class="n">t_m2dt</span><span class="o">.</span><span class="n">hour</span><span class="o">*</span><span class="mi">100</span><span class="p">)</span>
     1258                            <span class="n">codes_set</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="s1">&#39;date&#39;</span><span class="p">,</span> <span class="nb">int</span><span class="p">(</span><span class="n">t_m2dt</span><span class="o">.</span><span class="n">strftime</span><span class="p">(</span><span class="s1">&#39;%Y%m</span><span class="si">%d</span><span class="s1">&#39;</span><span class="p">)))</span>
     1259
     1260                        <span class="n">codes_write</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="n">f_handle</span><span class="p">)</span>
    10301261
    10311262                        <span class="k">if</span> <span class="n">c</span><span class="o">.</span><span class="n">basetime</span><span class="p">:</span>
    1032                             <span class="n">t_enddate</span> <span class="o">=</span> <span class="n">datetime</span><span class="o">.</span><span class="n">strptime</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">end_date</span> <span class="o">+</span>
    1033                                                           <span class="n">c</span><span class="o">.</span><span class="n">basetime</span><span class="p">,</span>
     1263                            <span class="n">t_enddate</span> <span class="o">=</span> <span class="n">datetime</span><span class="o">.</span><span class="n">strptime</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">end_date</span> <span class="o">+</span> <span class="n">c</span><span class="o">.</span><span class="n">basetime</span><span class="p">,</span>
    10341264                                                          <span class="s1">&#39;%Y%m</span><span class="si">%d</span><span class="s1">%H&#39;</span><span class="p">)</span>
    10351265                        <span class="k">else</span><span class="p">:</span>
    10361266                            <span class="n">t_enddate</span> <span class="o">=</span> <span class="n">t_date</span> <span class="o">+</span> <span class="n">timedelta</span><span class="p">(</span><span class="mi">2</span><span class="o">*</span><span class="nb">int</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">dtime</span><span class="p">))</span>
    10371267
    1038                         <span class="c1"># squeeze out information of last two steps contained</span>
    1039                         <span class="c1"># in svdp</span>
    1040                         <span class="c1"># if step+int(c.dtime) == c.maxstep and c.maxstep&gt;12</span>
    1041                         <span class="c1"># or t_dt+timedelta(hours = int(c.dtime))</span>
    1042                         <span class="c1"># &gt;= t_enddate:</span>
    1043                         <span class="c1"># Note that svdp[0] has not been popped in this case</span>
    1044 
    1045                         <span class="k">if</span> <span class="n">step</span> <span class="o">==</span> <span class="n">c</span><span class="o">.</span><span class="n">maxstep</span> <span class="ow">and</span> <span class="n">c</span><span class="o">.</span><span class="n">maxstep</span> <span class="o">&gt;</span> <span class="mi">12</span> <span class="ow">or</span> \
    1046                            <span class="n">t_dt</span> <span class="o">==</span> <span class="n">t_enddate</span><span class="p">:</span>
    1047 
    1048                             <span class="n">values</span> <span class="o">=</span> <span class="n">svdp</span><span class="p">[</span><span class="mi">3</span><span class="p">]</span>
    1049                             <span class="n">grib_set_values</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="n">values</span><span class="p">)</span>
    1050                             <span class="n">grib_set</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="s1">&#39;step&#39;</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span>
    1051                             <span class="n">truedatetime</span> <span class="o">=</span> <span class="n">t_m2dt</span> <span class="o">+</span> <span class="n">timedelta</span><span class="p">(</span><span class="n">hours</span><span class="o">=</span>
    1052                                                               <span class="mi">2</span><span class="o">*</span><span class="nb">int</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">dtime</span><span class="p">))</span>
    1053                             <span class="n">grib_set</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="s1">&#39;time&#39;</span><span class="p">,</span> <span class="n">truedatetime</span><span class="o">.</span><span class="n">hour</span> <span class="o">*</span> <span class="mi">100</span><span class="p">)</span>
    1054                             <span class="n">grib_set</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="s1">&#39;date&#39;</span><span class="p">,</span> <span class="n">truedatetime</span><span class="o">.</span><span class="n">year</span> <span class="o">*</span> <span class="mi">10000</span> <span class="o">+</span>
    1055                                       <span class="n">truedatetime</span><span class="o">.</span><span class="n">month</span> <span class="o">*</span> <span class="mi">100</span> <span class="o">+</span>
    1056                                       <span class="n">truedatetime</span><span class="o">.</span><span class="n">day</span><span class="p">)</span>
    1057                             <span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">hnout</span><span class="p">,</span> <span class="s1">&#39;w&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">h_handle</span><span class="p">:</span>
    1058                                 <span class="n">grib_write</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="n">h_handle</span><span class="p">)</span>
    1059 
    1060                             <span class="c1">#values = (svdp[1]+svdp[2])/2.</span>
    1061                             <span class="k">if</span> <span class="n">cparamId</span> <span class="o">==</span> <span class="s1">&#39;142&#39;</span> <span class="ow">or</span> <span class="n">cparamId</span> <span class="o">==</span> <span class="s1">&#39;143&#39;</span><span class="p">:</span>
    1062                                 <span class="n">values</span> <span class="o">=</span> <span class="n">disaggregation</span><span class="o">.</span><span class="n">darain</span><span class="p">(</span><span class="nb">list</span><span class="p">(</span><span class="nb">reversed</span><span class="p">(</span><span class="n">svdp</span><span class="p">)))</span>
    1063                             <span class="k">else</span><span class="p">:</span>
    1064                                 <span class="n">values</span> <span class="o">=</span> <span class="n">disaggregation</span><span class="o">.</span><span class="n">dapoly</span><span class="p">(</span><span class="nb">list</span><span class="p">(</span><span class="nb">reversed</span><span class="p">(</span><span class="n">svdp</span><span class="p">)))</span>
    1065 
    1066                             <span class="n">grib_set</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="s1">&#39;step&#39;</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span>
    1067                             <span class="n">truedatetime</span> <span class="o">=</span> <span class="n">t_m2dt</span> <span class="o">+</span> <span class="n">timedelta</span><span class="p">(</span><span class="n">hours</span><span class="o">=</span><span class="nb">int</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">dtime</span><span class="p">))</span>
    1068                             <span class="n">grib_set</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="s1">&#39;time&#39;</span><span class="p">,</span> <span class="n">truedatetime</span><span class="o">.</span><span class="n">hour</span> <span class="o">*</span> <span class="mi">100</span><span class="p">)</span>
    1069                             <span class="n">grib_set</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="s1">&#39;date&#39;</span><span class="p">,</span> <span class="n">truedatetime</span><span class="o">.</span><span class="n">year</span> <span class="o">*</span> <span class="mi">10000</span> <span class="o">+</span>
    1070                                      <span class="n">truedatetime</span><span class="o">.</span><span class="n">month</span> <span class="o">*</span> <span class="mi">100</span> <span class="o">+</span>
    1071                                      <span class="n">truedatetime</span><span class="o">.</span><span class="n">day</span><span class="p">)</span>
    1072                             <span class="n">grib_set_values</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="n">values</span><span class="p">)</span>
    1073                             <span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">gnout</span><span class="p">,</span> <span class="s1">&#39;w&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">g_handle</span><span class="p">:</span>
    1074                                 <span class="n">grib_write</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="n">g_handle</span><span class="p">)</span>
    1075 
    1076                 <span class="n">grib_release</span><span class="p">(</span><span class="n">gid</span><span class="p">)</span>
    1077 
    1078                 <span class="n">gid</span> <span class="o">=</span> <span class="n">grib_new_from_index</span><span class="p">(</span><span class="n">iid</span><span class="p">)</span>
    1079 
    1080         <span class="n">grib_index_release</span><span class="p">(</span><span class="n">iid</span><span class="p">)</span>
     1268                            <span class="c1"># squeeze out information of last two steps</span>
     1269                            <span class="c1"># contained in deac_vals[parId]</span>
     1270                            <span class="c1"># Note that deac_vals[parId][0] has not been popped</span>
     1271                            <span class="c1"># in this case</span>
     1272
     1273                            <span class="k">if</span> <span class="n">step</span> <span class="o">==</span> <span class="n">c</span><span class="o">.</span><span class="n">maxstep</span> <span class="ow">and</span> <span class="n">c</span><span class="o">.</span><span class="n">purefc</span> <span class="ow">or</span> \
     1274                               <span class="n">t_dt</span> <span class="o">==</span> <span class="n">t_enddate</span><span class="p">:</span>
     1275                                <span class="c1"># last step</span>
     1276                                <span class="k">if</span> <span class="n">c</span><span class="o">.</span><span class="n">purefc</span><span class="p">:</span>
     1277                                    <span class="n">values</span> <span class="o">=</span> <span class="n">deac_vals</span><span class="p">[</span><span class="n">parId</span><span class="p">][</span><span class="mi">3</span><span class="p">]</span>
     1278                                    <span class="n">codes_set_values</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="n">values</span><span class="p">)</span>
     1279                                    <span class="n">codes_set</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="s1">&#39;stepRange&#39;</span><span class="p">,</span> <span class="n">step</span><span class="p">)</span>
     1280                                    <span class="c1">#truedatetime = t_m2dt + timedelta(hours=2*int(c.dtime))</span>
     1281                                    <span class="n">codes_write</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="n">h_handle</span><span class="p">)</span>
     1282                                <span class="k">else</span><span class="p">:</span>
     1283                                    <span class="n">values</span> <span class="o">=</span> <span class="n">deac_vals</span><span class="p">[</span><span class="n">parId</span><span class="p">][</span><span class="mi">3</span><span class="p">]</span>
     1284                                    <span class="n">codes_set_values</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="n">values</span><span class="p">)</span>
     1285                                    <span class="n">codes_set</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="s1">&#39;stepRange&#39;</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span>
     1286                                    <span class="n">truedatetime</span> <span class="o">=</span> <span class="n">t_m2dt</span> <span class="o">+</span> <span class="n">timedelta</span><span class="p">(</span><span class="n">hours</span><span class="o">=</span><span class="mi">2</span><span class="o">*</span><span class="nb">int</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">dtime</span><span class="p">))</span>
     1287                                    <span class="n">codes_set</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="s1">&#39;time&#39;</span><span class="p">,</span> <span class="n">truedatetime</span><span class="o">.</span><span class="n">hour</span> <span class="o">*</span> <span class="mi">100</span><span class="p">)</span>
     1288                                    <span class="n">codes_set</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="s1">&#39;date&#39;</span><span class="p">,</span> <span class="nb">int</span><span class="p">(</span><span class="n">truedatetime</span><span class="o">.</span><span class="n">strftime</span><span class="p">(</span><span class="s1">&#39;%Y%m</span><span class="si">%d</span><span class="s1">&#39;</span><span class="p">)))</span>
     1289                                    <span class="n">codes_write</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="n">h_handle</span><span class="p">)</span>
     1290
     1291                                <span class="k">if</span> <span class="n">parId</span> <span class="o">==</span> <span class="mi">142</span> <span class="ow">or</span> <span class="n">parId</span> <span class="o">==</span> <span class="mi">143</span><span class="p">:</span>
     1292                                    <span class="n">values</span> <span class="o">=</span> <span class="n">disaggregation</span><span class="o">.</span><span class="n">darain</span><span class="p">(</span><span class="nb">list</span><span class="p">(</span><span class="nb">reversed</span><span class="p">(</span><span class="n">deac_vals</span><span class="p">[</span><span class="n">parId</span><span class="p">])))</span>
     1293                                <span class="k">else</span><span class="p">:</span>
     1294                                    <span class="n">values</span> <span class="o">=</span> <span class="n">disaggregation</span><span class="o">.</span><span class="n">dapoly</span><span class="p">(</span><span class="nb">list</span><span class="p">(</span><span class="nb">reversed</span><span class="p">(</span><span class="n">deac_vals</span><span class="p">[</span><span class="n">parId</span><span class="p">])))</span>
     1295
     1296                                <span class="c1"># step before last step</span>
     1297                                <span class="k">if</span> <span class="n">c</span><span class="o">.</span><span class="n">purefc</span><span class="p">:</span>
     1298                                    <span class="n">codes_set</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="s1">&#39;stepRange&#39;</span><span class="p">,</span> <span class="n">step</span><span class="o">-</span><span class="nb">int</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">dtime</span><span class="p">))</span>
     1299                                    <span class="c1">#truedatetime = t_m2dt + timedelta(hours=int(c.dtime))</span>
     1300                                    <span class="n">codes_set_values</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="n">values</span><span class="p">)</span>
     1301                                    <span class="n">codes_write</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="n">g_handle</span><span class="p">)</span>
     1302                                <span class="k">else</span><span class="p">:</span>
     1303                                    <span class="n">codes_set</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="s1">&#39;stepRange&#39;</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span>
     1304                                    <span class="n">truedatetime</span> <span class="o">=</span> <span class="n">t_m2dt</span> <span class="o">+</span> <span class="n">timedelta</span><span class="p">(</span><span class="n">hours</span><span class="o">=</span><span class="nb">int</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">dtime</span><span class="p">))</span>
     1305                                    <span class="n">codes_set</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="s1">&#39;time&#39;</span><span class="p">,</span> <span class="n">truedatetime</span><span class="o">.</span><span class="n">hour</span> <span class="o">*</span> <span class="mi">100</span><span class="p">)</span>
     1306                                    <span class="n">codes_set</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="s1">&#39;date&#39;</span><span class="p">,</span> <span class="nb">int</span><span class="p">(</span><span class="n">truedatetime</span><span class="o">.</span><span class="n">strftime</span><span class="p">(</span><span class="s1">&#39;%Y%m</span><span class="si">%d</span><span class="s1">&#39;</span><span class="p">)))</span>
     1307                                    <span class="n">codes_set_values</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="n">values</span><span class="p">)</span>
     1308                                    <span class="n">codes_write</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="n">g_handle</span><span class="p">)</span>
     1309
     1310                <span class="n">codes_release</span><span class="p">(</span><span class="n">gid</span><span class="p">)</span>
     1311
     1312                <span class="n">gid</span> <span class="o">=</span> <span class="n">codes_new_from_index</span><span class="p">(</span><span class="n">iid</span><span class="p">)</span>
     1313
     1314            <span class="n">f_handle</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>
     1315            <span class="n">g_handle</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>
     1316            <span class="n">h_handle</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>
     1317
     1318        <span class="n">codes_index_release</span><span class="p">(</span><span class="n">iid</span><span class="p">)</span>
     1319
     1320        <span class="k">if</span> <span class="n">c</span><span class="o">.</span><span class="n">rrint</span><span class="p">:</span>
     1321            <span class="bp">self</span><span class="o">.</span><span class="n">_create_rr_grib_dummy</span><span class="p">(</span><span class="n">inputfiles</span><span class="o">.</span><span class="n">files</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">c</span><span class="o">.</span><span class="n">inputdir</span><span class="p">)</span>
     1322
     1323            <span class="bp">self</span><span class="o">.</span><span class="n">_prep_new_rrint</span><span class="p">(</span><span class="n">ni</span><span class="p">,</span> <span class="n">nj</span><span class="p">,</span> <span class="n">lsp_np</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="n">lsp_np</span><span class="p">,</span>
     1324                                 <span class="n">cp_np</span><span class="p">,</span> <span class="n">date_list</span><span class="p">,</span> <span class="n">step_list</span><span class="p">,</span> <span class="n">c</span><span class="p">)</span>
    10811325
    10821326        <span class="k">return</span></div>
    10831327
     1328    <span class="k">def</span> <span class="nf">_prep_new_rrint</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">ni</span><span class="p">,</span> <span class="n">nj</span><span class="p">,</span> <span class="n">nt</span><span class="p">,</span> <span class="n">lsp_np</span><span class="p">,</span> <span class="n">cp_np</span><span class="p">,</span> <span class="n">date_list</span><span class="p">,</span> <span class="n">step_list</span><span class="p">,</span> <span class="n">c</span><span class="p">):</span>
     1329        <span class="sd">&#39;&#39;&#39;Calculates and writes out the disaggregated precipitation fields.</span>
     1330
     1331<span class="sd">        Disaggregation is done in time and original times are written to the</span>
     1332<span class="sd">        flux files, while the additional subgrid times are written to</span>
     1333<span class="sd">        extra files.</span>
     1334
     1335<span class="sd">        Parameters</span>
     1336<span class="sd">        ----------</span>
     1337<span class="sd">        ni : int</span>
     1338<span class="sd">            Amount of zonal grid points.</span>
     1339
     1340<span class="sd">        nj : int</span>
     1341<span class="sd">            Amount of meridional grid points.</span>
     1342
     1343<span class="sd">        nt : int</span>
     1344<span class="sd">            Number of time steps.</span>
     1345
     1346<span class="sd">        lsp_np : numpy array of float</span>
     1347<span class="sd">            The large scale precipitation fields for each time step.</span>
     1348<span class="sd">            Shape (ni * nj, nt).</span>
     1349
     1350<span class="sd">        cp_np : numpy array of float</span>
     1351<span class="sd">            The convective precipitation fields for each time step.</span>
     1352<span class="sd">            Shape (ni * nj, nt).</span>
     1353
     1354<span class="sd">        date_list : list of datetime</span>
     1355<span class="sd">            The list of dates for which the disaggregation is to be done.</span>
     1356
     1357<span class="sd">        step_list : list of int</span>
     1358<span class="sd">            The list of steps for a single forecast time.</span>
     1359<span class="sd">            Only necessary for pure forecasts.</span>
     1360
     1361<span class="sd">        c : ControlFile</span>
     1362<span class="sd">            Contains all the parameters of CONTROL file and</span>
     1363<span class="sd">            command line.</span>
     1364
     1365<span class="sd">        Return</span>
     1366<span class="sd">        ------</span>
     1367
     1368<span class="sd">        &#39;&#39;&#39;</span>
     1369        <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;... disaggregation or precipitation with new method.&#39;</span><span class="p">)</span>
     1370        <span class="n">lsp_new_np</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">((</span><span class="n">ni</span> <span class="o">*</span> <span class="n">nj</span><span class="p">,</span> <span class="n">nt</span> <span class="o">*</span> <span class="mi">3</span><span class="p">),</span> <span class="n">dtype</span><span class="o">=</span><span class="n">np</span><span class="o">.</span><span class="n">float64</span><span class="p">)</span>
     1371        <span class="n">cp_new_np</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">((</span><span class="n">ni</span> <span class="o">*</span> <span class="n">nj</span><span class="p">,</span> <span class="n">nt</span> <span class="o">*</span> <span class="mi">3</span><span class="p">),</span> <span class="n">dtype</span><span class="o">=</span><span class="n">np</span><span class="o">.</span><span class="n">float64</span><span class="p">)</span>
     1372
     1373        <span class="c1"># do the disaggregation, but neglect the last value of the</span>
     1374        <span class="c1"># time series. This one corresponds for example to 24 hour,</span>
     1375        <span class="c1"># which we don&#39;t need.</span>
     1376        <span class="k">for</span> <span class="n">ix</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">ni</span><span class="o">*</span><span class="n">nj</span><span class="p">):</span>
     1377            <span class="n">lsp_new_np</span><span class="p">[</span><span class="n">ix</span><span class="p">,:]</span> <span class="o">=</span> <span class="n">disaggregation</span><span class="o">.</span><span class="n">IA3</span><span class="p">(</span><span class="n">lsp_np</span><span class="p">[</span><span class="n">ix</span><span class="p">,:])[:</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span>
     1378            <span class="n">cp_new_np</span><span class="p">[</span><span class="n">ix</span><span class="p">,:]</span> <span class="o">=</span> <span class="n">disaggregation</span><span class="o">.</span><span class="n">IA3</span><span class="p">(</span><span class="n">cp_np</span><span class="p">[</span><span class="n">ix</span><span class="p">,:])[:</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span>
     1379
     1380        <span class="c1"># write to grib files (full/orig times to flux file and inbetween</span>
     1381        <span class="c1"># times into seperate end files)</span>
     1382        <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;... write disaggregated precipitation to files.&#39;</span><span class="p">)</span>
     1383        <span class="n">it</span> <span class="o">=</span> <span class="mi">0</span>
     1384        <span class="k">for</span> <span class="n">date</span> <span class="ow">in</span> <span class="n">date_list</span><span class="p">:</span>
     1385            <span class="k">for</span> <span class="n">step</span> <span class="ow">in</span> <span class="n">step_list</span><span class="p">:</span>
     1386                <span class="n">tmpfile</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">inputdir</span><span class="p">,</span> <span class="s1">&#39;rr_grib_dummy.grb&#39;</span><span class="p">)</span>
     1387
     1388                <span class="k">if</span> <span class="n">c</span><span class="o">.</span><span class="n">purefc</span><span class="p">:</span>
     1389                    <span class="n">fluxfilename</span> <span class="o">=</span> <span class="s1">&#39;flux&#39;</span> <span class="o">+</span> <span class="n">date</span><span class="o">.</span><span class="n">strftime</span><span class="p">(</span><span class="s1">&#39;%Y%m</span><span class="si">%d</span><span class="s1">.%H&#39;</span><span class="p">)</span> <span class="o">+</span> \
     1390                                   <span class="s1">&#39;.</span><span class="si">{:0&gt;3}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">step</span><span class="p">)</span>
     1391                    <span class="n">filename1</span> <span class="o">=</span> <span class="n">c</span><span class="o">.</span><span class="n">prefix</span> <span class="o">+</span> <span class="n">date</span><span class="o">.</span><span class="n">strftime</span><span class="p">(</span><span class="s1">&#39;%y%m</span><span class="si">%d</span><span class="s1">.%H&#39;</span><span class="p">)</span> <span class="o">+</span> \
     1392                                <span class="s1">&#39;.</span><span class="si">{:0&gt;3}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">step</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39;_1&#39;</span>
     1393                    <span class="n">filename2</span> <span class="o">=</span> <span class="n">c</span><span class="o">.</span><span class="n">prefix</span> <span class="o">+</span> <span class="n">date</span><span class="o">.</span><span class="n">strftime</span><span class="p">(</span><span class="s1">&#39;%y%m</span><span class="si">%d</span><span class="s1">.%H&#39;</span><span class="p">)</span> <span class="o">+</span> \
     1394                                <span class="s1">&#39;.</span><span class="si">{:0&gt;3}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">step</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39;_2&#39;</span>
     1395                <span class="k">else</span><span class="p">:</span>
     1396                    <span class="n">fluxfilename</span> <span class="o">=</span> <span class="s1">&#39;flux&#39;</span> <span class="o">+</span> <span class="n">date</span><span class="o">.</span><span class="n">strftime</span><span class="p">(</span><span class="s1">&#39;%Y%m</span><span class="si">%d</span><span class="s1">%H&#39;</span><span class="p">)</span>
     1397                    <span class="n">filename1</span> <span class="o">=</span> <span class="n">c</span><span class="o">.</span><span class="n">prefix</span> <span class="o">+</span> <span class="n">date</span><span class="o">.</span><span class="n">strftime</span><span class="p">(</span><span class="s1">&#39;%y%m</span><span class="si">%d</span><span class="s1">%H&#39;</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39;_1&#39;</span>
     1398                    <span class="n">filename2</span> <span class="o">=</span> <span class="n">c</span><span class="o">.</span><span class="n">prefix</span> <span class="o">+</span> <span class="n">date</span><span class="o">.</span><span class="n">strftime</span><span class="p">(</span><span class="s1">&#39;%y%m</span><span class="si">%d</span><span class="s1">%H&#39;</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39;_2&#39;</span>
     1399
     1400                <span class="c1"># collect for final processing</span>
     1401                <span class="bp">self</span><span class="o">.</span><span class="n">outputfilelist</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">basename</span><span class="p">(</span><span class="n">fluxfilename</span><span class="p">))</span>
     1402                <span class="bp">self</span><span class="o">.</span><span class="n">outputfilelist</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">basename</span><span class="p">(</span><span class="n">filename1</span><span class="p">))</span>
     1403                <span class="bp">self</span><span class="o">.</span><span class="n">outputfilelist</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">basename</span><span class="p">(</span><span class="n">filename2</span><span class="p">))</span>
     1404
     1405                <span class="c1"># write original time step to flux file as usual</span>
     1406                <span class="n">fluxfile</span> <span class="o">=</span> <span class="n">GribUtil</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">inputdir</span><span class="p">,</span> <span class="n">fluxfilename</span><span class="p">))</span>
     1407                <span class="n">fluxfile</span><span class="o">.</span><span class="n">set_keys</span><span class="p">(</span><span class="n">tmpfile</span><span class="p">,</span> <span class="n">filemode</span><span class="o">=</span><span class="s1">&#39;a&#39;</span><span class="p">,</span> <span class="n">strict</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span>
     1408                                  <span class="n">wherekeynames</span><span class="o">=</span><span class="p">[</span><span class="s1">&#39;paramId&#39;</span><span class="p">],</span> <span class="n">wherekeyvalues</span><span class="o">=</span><span class="p">[</span><span class="mi">142</span><span class="p">],</span>
     1409                                  <span class="n">keynames</span><span class="o">=</span><span class="p">[</span><span class="s1">&#39;date&#39;</span><span class="p">,</span><span class="s1">&#39;time&#39;</span><span class="p">,</span><span class="s1">&#39;stepRange&#39;</span><span class="p">,</span><span class="s1">&#39;values&#39;</span><span class="p">],</span>
     1410                                  <span class="n">keyvalues</span><span class="o">=</span><span class="p">[</span><span class="nb">int</span><span class="p">(</span><span class="n">date</span><span class="o">.</span><span class="n">strftime</span><span class="p">(</span><span class="s1">&#39;%Y%m</span><span class="si">%d</span><span class="s1">&#39;</span><span class="p">)),</span>
     1411                                             <span class="n">date</span><span class="o">.</span><span class="n">hour</span><span class="o">*</span><span class="mi">100</span><span class="p">,</span> <span class="n">step</span><span class="p">,</span> <span class="n">lsp_new_np</span><span class="p">[:,</span><span class="n">it</span><span class="p">]],</span>
     1412                                 <span class="p">)</span>
     1413                <span class="n">fluxfile</span><span class="o">.</span><span class="n">set_keys</span><span class="p">(</span><span class="n">tmpfile</span><span class="p">,</span> <span class="n">filemode</span><span class="o">=</span><span class="s1">&#39;a&#39;</span><span class="p">,</span> <span class="n">strict</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span>
     1414                                  <span class="n">wherekeynames</span><span class="o">=</span><span class="p">[</span><span class="s1">&#39;paramId&#39;</span><span class="p">],</span> <span class="n">wherekeyvalues</span><span class="o">=</span><span class="p">[</span><span class="mi">143</span><span class="p">],</span>
     1415                                  <span class="n">keynames</span><span class="o">=</span><span class="p">[</span><span class="s1">&#39;date&#39;</span><span class="p">,</span><span class="s1">&#39;time&#39;</span><span class="p">,</span><span class="s1">&#39;stepRange&#39;</span><span class="p">,</span><span class="s1">&#39;values&#39;</span><span class="p">],</span>
     1416                                  <span class="n">keyvalues</span><span class="o">=</span><span class="p">[</span><span class="nb">int</span><span class="p">(</span><span class="n">date</span><span class="o">.</span><span class="n">strftime</span><span class="p">(</span><span class="s1">&#39;%Y%m</span><span class="si">%d</span><span class="s1">&#39;</span><span class="p">)),</span>
     1417                                             <span class="n">date</span><span class="o">.</span><span class="n">hour</span><span class="o">*</span><span class="mi">100</span><span class="p">,</span> <span class="n">step</span><span class="p">,</span> <span class="n">cp_new_np</span><span class="p">[:,</span><span class="n">it</span><span class="p">]]</span>
     1418                                 <span class="p">)</span>
     1419
     1420                <span class="c1"># write first subgrid time step</span>
     1421                <span class="n">endfile1</span> <span class="o">=</span> <span class="n">GribUtil</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">inputdir</span><span class="p">,</span> <span class="n">filename1</span><span class="p">))</span>
     1422                <span class="n">endfile1</span><span class="o">.</span><span class="n">set_keys</span><span class="p">(</span><span class="n">tmpfile</span><span class="p">,</span> <span class="n">filemode</span><span class="o">=</span><span class="s1">&#39;w&#39;</span><span class="p">,</span> <span class="n">strict</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span>
     1423                                  <span class="n">wherekeynames</span><span class="o">=</span><span class="p">[</span><span class="s1">&#39;paramId&#39;</span><span class="p">],</span> <span class="n">wherekeyvalues</span><span class="o">=</span><span class="p">[</span><span class="mi">142</span><span class="p">],</span>
     1424                                  <span class="n">keynames</span><span class="o">=</span><span class="p">[</span><span class="s1">&#39;date&#39;</span><span class="p">,</span><span class="s1">&#39;time&#39;</span><span class="p">,</span><span class="s1">&#39;stepRange&#39;</span><span class="p">,</span><span class="s1">&#39;values&#39;</span><span class="p">],</span>
     1425                                  <span class="n">keyvalues</span><span class="o">=</span><span class="p">[</span><span class="nb">int</span><span class="p">(</span><span class="n">date</span><span class="o">.</span><span class="n">strftime</span><span class="p">(</span><span class="s1">&#39;%Y%m</span><span class="si">%d</span><span class="s1">&#39;</span><span class="p">)),</span>
     1426                                             <span class="n">date</span><span class="o">.</span><span class="n">hour</span><span class="o">*</span><span class="mi">100</span><span class="p">,</span> <span class="n">step</span><span class="p">,</span> <span class="n">lsp_new_np</span><span class="p">[:,</span><span class="n">it</span><span class="o">+</span><span class="mi">1</span><span class="p">]]</span>
     1427                                  <span class="p">)</span>
     1428                <span class="n">endfile1</span><span class="o">.</span><span class="n">set_keys</span><span class="p">(</span><span class="n">tmpfile</span><span class="p">,</span> <span class="n">filemode</span><span class="o">=</span><span class="s1">&#39;a&#39;</span><span class="p">,</span> <span class="n">strict</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span>
     1429                                  <span class="n">wherekeynames</span><span class="o">=</span><span class="p">[</span><span class="s1">&#39;paramId&#39;</span><span class="p">],</span> <span class="n">wherekeyvalues</span><span class="o">=</span><span class="p">[</span><span class="mi">143</span><span class="p">],</span>
     1430                                  <span class="n">keynames</span><span class="o">=</span><span class="p">[</span><span class="s1">&#39;date&#39;</span><span class="p">,</span><span class="s1">&#39;time&#39;</span><span class="p">,</span><span class="s1">&#39;stepRange&#39;</span><span class="p">,</span><span class="s1">&#39;values&#39;</span><span class="p">],</span>
     1431                                  <span class="n">keyvalues</span><span class="o">=</span><span class="p">[</span><span class="nb">int</span><span class="p">(</span><span class="n">date</span><span class="o">.</span><span class="n">strftime</span><span class="p">(</span><span class="s1">&#39;%Y%m</span><span class="si">%d</span><span class="s1">&#39;</span><span class="p">)),</span>
     1432                                             <span class="n">date</span><span class="o">.</span><span class="n">hour</span><span class="o">*</span><span class="mi">100</span><span class="p">,</span> <span class="n">step</span><span class="p">,</span> <span class="n">cp_new_np</span><span class="p">[:,</span><span class="n">it</span><span class="o">+</span><span class="mi">1</span><span class="p">]]</span>
     1433                                 <span class="p">)</span>
     1434
     1435                <span class="c1"># write second subgrid time step</span>
     1436                <span class="n">endfile2</span> <span class="o">=</span> <span class="n">GribUtil</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">inputdir</span><span class="p">,</span> <span class="n">filename2</span><span class="p">))</span>
     1437                <span class="n">endfile2</span><span class="o">.</span><span class="n">set_keys</span><span class="p">(</span><span class="n">tmpfile</span><span class="p">,</span> <span class="n">filemode</span><span class="o">=</span><span class="s1">&#39;w&#39;</span><span class="p">,</span> <span class="n">strict</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span>
     1438                                  <span class="n">wherekeynames</span><span class="o">=</span><span class="p">[</span><span class="s1">&#39;paramId&#39;</span><span class="p">],</span> <span class="n">wherekeyvalues</span><span class="o">=</span><span class="p">[</span><span class="mi">142</span><span class="p">],</span>
     1439                                  <span class="n">keynames</span><span class="o">=</span><span class="p">[</span><span class="s1">&#39;date&#39;</span><span class="p">,</span><span class="s1">&#39;time&#39;</span><span class="p">,</span><span class="s1">&#39;stepRange&#39;</span><span class="p">,</span><span class="s1">&#39;values&#39;</span><span class="p">],</span>
     1440                                  <span class="n">keyvalues</span><span class="o">=</span><span class="p">[</span><span class="nb">int</span><span class="p">(</span><span class="n">date</span><span class="o">.</span><span class="n">strftime</span><span class="p">(</span><span class="s1">&#39;%Y%m</span><span class="si">%d</span><span class="s1">&#39;</span><span class="p">)),</span>
     1441                                             <span class="n">date</span><span class="o">.</span><span class="n">hour</span><span class="o">*</span><span class="mi">100</span><span class="p">,</span> <span class="n">step</span><span class="p">,</span> <span class="n">lsp_new_np</span><span class="p">[:,</span><span class="n">it</span><span class="o">+</span><span class="mi">2</span><span class="p">]]</span>
     1442                                 <span class="p">)</span>
     1443                <span class="n">endfile2</span><span class="o">.</span><span class="n">set_keys</span><span class="p">(</span><span class="n">tmpfile</span><span class="p">,</span> <span class="n">filemode</span><span class="o">=</span><span class="s1">&#39;a&#39;</span><span class="p">,</span> <span class="n">strict</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span>
     1444                                  <span class="n">wherekeynames</span><span class="o">=</span><span class="p">[</span><span class="s1">&#39;paramId&#39;</span><span class="p">],</span> <span class="n">wherekeyvalues</span><span class="o">=</span><span class="p">[</span><span class="mi">143</span><span class="p">],</span>
     1445                                  <span class="n">keynames</span><span class="o">=</span><span class="p">[</span><span class="s1">&#39;date&#39;</span><span class="p">,</span><span class="s1">&#39;time&#39;</span><span class="p">,</span><span class="s1">&#39;stepRange&#39;</span><span class="p">,</span><span class="s1">&#39;values&#39;</span><span class="p">],</span>
     1446                                  <span class="n">keyvalues</span><span class="o">=</span><span class="p">[</span><span class="nb">int</span><span class="p">(</span><span class="n">date</span><span class="o">.</span><span class="n">strftime</span><span class="p">(</span><span class="s1">&#39;%Y%m</span><span class="si">%d</span><span class="s1">&#39;</span><span class="p">)),</span>
     1447                                             <span class="n">date</span><span class="o">.</span><span class="n">hour</span><span class="o">*</span><span class="mi">100</span><span class="p">,</span> <span class="n">step</span><span class="p">,</span> <span class="n">cp_new_np</span><span class="p">[:,</span><span class="n">it</span><span class="o">+</span><span class="mi">2</span><span class="p">]]</span>
     1448                                 <span class="p">)</span>
     1449                <span class="n">it</span> <span class="o">=</span> <span class="n">it</span> <span class="o">+</span> <span class="mi">3</span> <span class="c1"># jump to next original time step</span>
     1450        <span class="k">return</span>
     1451
     1452    <span class="k">def</span> <span class="nf">_create_rr_grib_dummy</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">ifile</span><span class="p">,</span> <span class="n">inputdir</span><span class="p">):</span>
     1453        <span class="sd">&#39;&#39;&#39;Creates a grib file with a dummy message for the two precipitation</span>
     1454<span class="sd">        types lsp and cp each.</span>
     1455
     1456<span class="sd">        Parameters</span>
     1457<span class="sd">        ----------</span>
     1458<span class="sd">        ifile : str</span>
     1459<span class="sd">            Filename of the input file to read the grib messages from.</span>
     1460
     1461<span class="sd">        inputdir : str, optional</span>
     1462<span class="sd">            Path to the directory where the retrieved data is stored.</span>
     1463
     1464<span class="sd">        Return</span>
     1465<span class="sd">        ------</span>
     1466
     1467<span class="sd">        &#39;&#39;&#39;</span>
     1468
     1469        <span class="n">gribfile</span> <span class="o">=</span> <span class="n">GribUtil</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">inputdir</span><span class="p">,</span><span class="s1">&#39;rr_grib_dummy.grb&#39;</span><span class="p">))</span>
     1470
     1471        <span class="n">gribfile</span><span class="o">.</span><span class="n">copy_dummy_msg</span><span class="p">(</span><span class="n">ifile</span><span class="p">,</span> <span class="n">keynames</span><span class="o">=</span><span class="p">[</span><span class="s1">&#39;paramId&#39;</span><span class="p">],</span>
     1472                      <span class="n">keyvalues</span><span class="o">=</span><span class="p">[</span><span class="mi">142</span><span class="p">],</span> <span class="n">filemode</span><span class="o">=</span><span class="s1">&#39;w&#39;</span><span class="p">)</span>
     1473
     1474        <span class="n">gribfile</span><span class="o">.</span><span class="n">copy_dummy_msg</span><span class="p">(</span><span class="n">ifile</span><span class="p">,</span> <span class="n">keynames</span><span class="o">=</span><span class="p">[</span><span class="s1">&#39;paramId&#39;</span><span class="p">],</span>
     1475                      <span class="n">keyvalues</span><span class="o">=</span><span class="p">[</span><span class="mi">143</span><span class="p">],</span> <span class="n">filemode</span><span class="o">=</span><span class="s1">&#39;a&#39;</span><span class="p">)</span>
     1476
     1477        <span class="k">return</span>
    10841478
    10851479<div class="viewcode-block" id="EcFlexpart.create"><a class="viewcode-back" href="../api.html#EcFlexpart.EcFlexpart.create">[docs]</a>    <span class="k">def</span> <span class="nf">create</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">inputfiles</span><span class="p">,</span> <span class="n">c</span><span class="p">):</span>
     
    11001494<span class="sd">        Parameters</span>
    11011495<span class="sd">        ----------</span>
    1102 <span class="sd">        inputfiles : :obj:`UioFiles`</span>
     1496<span class="sd">        inputfiles : UioFiles</span>
    11031497<span class="sd">            Contains a list of files.</span>
    11041498
    1105 <span class="sd">        c : :obj:`ControlFile`</span>
     1499<span class="sd">        c : ControlFile</span>
    11061500<span class="sd">            Contains all the parameters of CONTROL file and</span>
    11071501<span class="sd">            command line.</span>
     
    11371531        <span class="c1"># index_vals looks like e.g.:</span>
    11381532        <span class="c1"># index_vals[0]: (&#39;20171106&#39;, &#39;20171107&#39;, &#39;20171108&#39;) ; date</span>
    1139         <span class="c1"># index_vals[1]: (&#39;0&#39;, &#39;1200&#39;, &#39;1800&#39;, &#39;600&#39;) ; time</span>
     1533        <span class="c1"># index_vals[1]: (&#39;0&#39;, &#39;600&#39;, &#39;1200&#39;, &#39;1800&#39;) ; time</span>
    11401534        <span class="c1"># index_vals[2]: (&#39;0&#39;, &#39;12&#39;, &#39;3&#39;, &#39;6&#39;, &#39;9&#39;) ; stepRange</span>
    11411535
     
    11491543
    11501544            <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">index_keys</span><span class="p">)):</span>
    1151                 <span class="n">grib_index_select</span><span class="p">(</span><span class="n">iid</span><span class="p">,</span> <span class="n">index_keys</span><span class="p">[</span><span class="n">i</span><span class="p">],</span> <span class="n">prod</span><span class="p">[</span><span class="n">i</span><span class="p">])</span>
     1545                <span class="n">codes_index_select</span><span class="p">(</span><span class="n">iid</span><span class="p">,</span> <span class="n">index_keys</span><span class="p">[</span><span class="n">i</span><span class="p">],</span> <span class="n">prod</span><span class="p">[</span><span class="n">i</span><span class="p">])</span>
    11521546
    11531547            <span class="c1"># get first id from current product</span>
    1154             <span class="n">gid</span> <span class="o">=</span> <span class="n">grib_new_from_index</span><span class="p">(</span><span class="n">iid</span><span class="p">)</span>
     1548            <span class="n">gid</span> <span class="o">=</span> <span class="n">codes_new_from_index</span><span class="p">(</span><span class="n">iid</span><span class="p">)</span>
    11551549
    11561550            <span class="c1"># if there is no data for this specific time combination / product</span>
     
    11581552            <span class="k">if</span> <span class="ow">not</span> <span class="n">gid</span><span class="p">:</span>
    11591553                <span class="k">continue</span>
    1160 
     1554<span class="c1">#============================================================================================</span>
    11611555            <span class="c1"># remove old fort.* files and open new ones</span>
    11621556            <span class="c1"># they are just valid for a single product</span>
     
    11651559                <span class="n">silent_remove</span><span class="p">(</span><span class="n">fortfile</span><span class="p">)</span>
    11661560                <span class="n">fdict</span><span class="p">[</span><span class="n">k</span><span class="p">]</span> <span class="o">=</span> <span class="nb">open</span><span class="p">(</span><span class="n">fortfile</span><span class="p">,</span> <span class="s1">&#39;w&#39;</span><span class="p">)</span>
    1167 
     1561<span class="c1">#============================================================================================</span>
    11681562            <span class="c1"># create correct timestamp from the three time informations</span>
    1169             <span class="n">cdate</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">grib_get</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="s1">&#39;date&#39;</span><span class="p">))</span>
    1170             <span class="n">ctime</span> <span class="o">=</span> <span class="s1">&#39;</span><span class="si">{:0&gt;2}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">grib_get</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="s1">&#39;time&#39;</span><span class="p">)</span><span class="o">/</span><span class="mi">100</span><span class="p">)</span>
    1171             <span class="n">cstep</span> <span class="o">=</span> <span class="s1">&#39;</span><span class="si">{:0&gt;3}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">grib_get</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="s1">&#39;step&#39;</span><span class="p">))</span>
     1563            <span class="n">cdate</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">codes_get</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="s1">&#39;date&#39;</span><span class="p">))</span>
     1564            <span class="n">ctime</span> <span class="o">=</span> <span class="s1">&#39;</span><span class="si">{:0&gt;2}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">codes_get</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="s1">&#39;time&#39;</span><span class="p">)</span><span class="o">/</span><span class="mi">100</span><span class="p">)</span>
     1565            <span class="n">cstep</span> <span class="o">=</span> <span class="s1">&#39;</span><span class="si">{:0&gt;3}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">codes_get</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="s1">&#39;step&#39;</span><span class="p">))</span>
    11721566            <span class="n">timestamp</span> <span class="o">=</span> <span class="n">datetime</span><span class="o">.</span><span class="n">strptime</span><span class="p">(</span><span class="n">cdate</span> <span class="o">+</span> <span class="n">ctime</span><span class="p">,</span> <span class="s1">&#39;%Y%m</span><span class="si">%d</span><span class="s1">%H&#39;</span><span class="p">)</span>
    11731567            <span class="n">timestamp</span> <span class="o">+=</span> <span class="n">timedelta</span><span class="p">(</span><span class="n">hours</span><span class="o">=</span><span class="nb">int</span><span class="p">(</span><span class="n">cstep</span><span class="p">))</span>
     
    11891583                                <span class="s1">&#39;WRF&#39;</span> <span class="o">+</span> <span class="n">cdate</span> <span class="o">+</span> <span class="s1">&#39;.&#39;</span> <span class="o">+</span> <span class="n">ctime</span> <span class="o">+</span> <span class="s1">&#39;.000.grb2&#39;</span><span class="p">),</span> <span class="s1">&#39;w&#39;</span><span class="p">)</span>
    11901584                    <span class="n">olddate</span> <span class="o">=</span> <span class="n">cdate</span><span class="p">[:]</span>
    1191 
     1585<span class="c1">#============================================================================================</span>
    11921586            <span class="c1"># savedfields remembers which fields were already used.</span>
    11931587            <span class="n">savedfields</span> <span class="o">=</span> <span class="p">[]</span>
     
    11971591                <span class="k">if</span> <span class="ow">not</span> <span class="n">gid</span><span class="p">:</span>
    11981592                    <span class="k">break</span>
    1199                 <span class="n">paramId</span> <span class="o">=</span> <span class="n">grib_get</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="s1">&#39;paramId&#39;</span><span class="p">)</span>
    1200                 <span class="n">gridtype</span> <span class="o">=</span> <span class="n">grib_get</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="s1">&#39;gridType&#39;</span><span class="p">)</span>
    1201                 <span class="n">levtype</span> <span class="o">=</span> <span class="n">grib_get</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="s1">&#39;typeOfLevel&#39;</span><span class="p">)</span>
     1593                <span class="n">paramId</span> <span class="o">=</span> <span class="n">codes_get</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="s1">&#39;paramId&#39;</span><span class="p">)</span>
     1594                <span class="n">gridtype</span> <span class="o">=</span> <span class="n">codes_get</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="s1">&#39;gridType&#39;</span><span class="p">)</span>
     1595                <span class="n">levtype</span> <span class="o">=</span> <span class="n">codes_get</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="s1">&#39;typeOfLevel&#39;</span><span class="p">)</span>
    12021596                <span class="k">if</span> <span class="n">paramId</span> <span class="o">==</span> <span class="mi">77</span><span class="p">:</span> <span class="c1"># ETADOT</span>
    1203                     <span class="n">grib_write</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="n">fdict</span><span class="p">[</span><span class="s1">&#39;21&#39;</span><span class="p">])</span>
     1597                    <span class="n">codes_write</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="n">fdict</span><span class="p">[</span><span class="s1">&#39;21&#39;</span><span class="p">])</span>
    12041598                <span class="k">elif</span> <span class="n">paramId</span> <span class="o">==</span> <span class="mi">130</span><span class="p">:</span> <span class="c1"># T</span>
    1205                     <span class="n">grib_write</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="n">fdict</span><span class="p">[</span><span class="s1">&#39;11&#39;</span><span class="p">])</span>
     1599                    <span class="n">codes_write</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="n">fdict</span><span class="p">[</span><span class="s1">&#39;11&#39;</span><span class="p">])</span>
    12061600                <span class="k">elif</span> <span class="n">paramId</span> <span class="o">==</span> <span class="mi">131</span> <span class="ow">or</span> <span class="n">paramId</span> <span class="o">==</span> <span class="mi">132</span><span class="p">:</span> <span class="c1"># U, V wind component</span>
    1207                     <span class="n">grib_write</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="n">fdict</span><span class="p">[</span><span class="s1">&#39;10&#39;</span><span class="p">])</span>
     1601                    <span class="n">codes_write</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="n">fdict</span><span class="p">[</span><span class="s1">&#39;10&#39;</span><span class="p">])</span>
    12081602                <span class="k">elif</span> <span class="n">paramId</span> <span class="o">==</span> <span class="mi">133</span> <span class="ow">and</span> <span class="n">gridtype</span> <span class="o">!=</span> <span class="s1">&#39;reduced_gg&#39;</span><span class="p">:</span> <span class="c1"># Q</span>
    1209                     <span class="n">grib_write</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="n">fdict</span><span class="p">[</span><span class="s1">&#39;17&#39;</span><span class="p">])</span>
     1603                    <span class="n">codes_write</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="n">fdict</span><span class="p">[</span><span class="s1">&#39;17&#39;</span><span class="p">])</span>
    12101604                <span class="k">elif</span> <span class="n">paramId</span> <span class="o">==</span> <span class="mi">133</span> <span class="ow">and</span> <span class="n">gridtype</span> <span class="o">==</span> <span class="s1">&#39;reduced_gg&#39;</span><span class="p">:</span> <span class="c1"># Q, gaussian</span>
    1211                     <span class="n">grib_write</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="n">fdict</span><span class="p">[</span><span class="s1">&#39;18&#39;</span><span class="p">])</span>
     1605                    <span class="n">codes_write</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="n">fdict</span><span class="p">[</span><span class="s1">&#39;18&#39;</span><span class="p">])</span>
    12121606                <span class="k">elif</span> <span class="n">paramId</span> <span class="o">==</span> <span class="mi">135</span><span class="p">:</span> <span class="c1"># W</span>
    1213                     <span class="n">grib_write</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="n">fdict</span><span class="p">[</span><span class="s1">&#39;19&#39;</span><span class="p">])</span>
     1607                    <span class="n">codes_write</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="n">fdict</span><span class="p">[</span><span class="s1">&#39;19&#39;</span><span class="p">])</span>
    12141608                <span class="k">elif</span> <span class="n">paramId</span> <span class="o">==</span> <span class="mi">152</span><span class="p">:</span> <span class="c1"># LNSP</span>
    1215                     <span class="n">grib_write</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="n">fdict</span><span class="p">[</span><span class="s1">&#39;12&#39;</span><span class="p">])</span>
     1609                    <span class="n">codes_write</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="n">fdict</span><span class="p">[</span><span class="s1">&#39;12&#39;</span><span class="p">])</span>
    12161610                <span class="k">elif</span> <span class="n">paramId</span> <span class="o">==</span> <span class="mi">155</span> <span class="ow">and</span> <span class="n">gridtype</span> <span class="o">==</span> <span class="s1">&#39;sh&#39;</span><span class="p">:</span> <span class="c1"># D</span>
    1217                     <span class="n">grib_write</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="n">fdict</span><span class="p">[</span><span class="s1">&#39;13&#39;</span><span class="p">])</span>
     1611                    <span class="n">codes_write</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="n">fdict</span><span class="p">[</span><span class="s1">&#39;13&#39;</span><span class="p">])</span>
    12181612                <span class="k">elif</span> <span class="n">paramId</span> <span class="o">==</span> <span class="mi">246</span> <span class="ow">or</span> <span class="n">paramId</span> <span class="o">==</span> <span class="mi">247</span><span class="p">:</span> <span class="c1"># CLWC, CIWC</span>
    12191613                    <span class="c1"># sum cloud liquid water and ice</span>
    12201614                    <span class="k">if</span> <span class="n">scwc</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
    1221                         <span class="n">scwc</span> <span class="o">=</span> <span class="n">grib_get_values</span><span class="p">(</span><span class="n">gid</span><span class="p">)</span>
     1615                        <span class="n">scwc</span> <span class="o">=</span> <span class="n">codes_get_values</span><span class="p">(</span><span class="n">gid</span><span class="p">)</span>
    12221616                    <span class="k">else</span><span class="p">:</span>
    1223                         <span class="n">scwc</span> <span class="o">+=</span> <span class="n">grib_get_values</span><span class="p">(</span><span class="n">gid</span><span class="p">)</span>
    1224                         <span class="n">grib_set_values</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="n">scwc</span><span class="p">)</span>
    1225                         <span class="n">grib_set</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="s1">&#39;paramId&#39;</span><span class="p">,</span> <span class="mi">201031</span><span class="p">)</span>
    1226                         <span class="n">grib_write</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="n">fdict</span><span class="p">[</span><span class="s1">&#39;22&#39;</span><span class="p">])</span>
     1617                        <span class="n">scwc</span> <span class="o">+=</span> <span class="n">codes_get_values</span><span class="p">(</span><span class="n">gid</span><span class="p">)</span>
     1618                        <span class="n">codes_set_values</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="n">scwc</span><span class="p">)</span>
     1619                        <span class="n">codes_set</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="s1">&#39;paramId&#39;</span><span class="p">,</span> <span class="mi">201031</span><span class="p">)</span>
     1620                        <span class="n">codes_write</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="n">fdict</span><span class="p">[</span><span class="s1">&#39;22&#39;</span><span class="p">])</span>
     1621                        <span class="n">scwc</span> <span class="o">=</span> <span class="kc">None</span>
    12271622                <span class="k">elif</span> <span class="n">c</span><span class="o">.</span><span class="n">wrf</span> <span class="ow">and</span> <span class="n">paramId</span> <span class="ow">in</span> <span class="p">[</span><span class="mi">129</span><span class="p">,</span> <span class="mi">138</span><span class="p">,</span> <span class="mi">155</span><span class="p">]</span> <span class="ow">and</span> \
    12281623                      <span class="n">levtype</span> <span class="o">==</span> <span class="s1">&#39;hybrid&#39;</span><span class="p">:</span> <span class="c1"># Z, VO, D</span>
     
    12341629                        <span class="c1"># SD/MSL/TCC/10U/10V/2T/2D/Z/LSM/SDOR/CVL/CVH/SR</span>
    12351630                        <span class="c1"># and all ADDPAR parameter</span>
    1236                         <span class="n">grib_write</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="n">fdict</span><span class="p">[</span><span class="s1">&#39;16&#39;</span><span class="p">])</span>
     1631                        <span class="n">codes_write</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="n">fdict</span><span class="p">[</span><span class="s1">&#39;16&#39;</span><span class="p">])</span>
    12371632                        <span class="n">savedfields</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">paramId</span><span class="p">)</span>
    12381633                    <span class="k">else</span><span class="p">:</span>
     
    12441639                        <span class="k">if</span> <span class="n">levtype</span> <span class="o">==</span> <span class="s1">&#39;hybrid&#39;</span> <span class="ow">and</span> \
    12451640                           <span class="n">paramId</span> <span class="ow">in</span> <span class="p">[</span><span class="mi">129</span><span class="p">,</span> <span class="mi">130</span><span class="p">,</span> <span class="mi">131</span><span class="p">,</span> <span class="mi">132</span><span class="p">,</span> <span class="mi">133</span><span class="p">,</span> <span class="mi">138</span><span class="p">,</span> <span class="mi">155</span><span class="p">]:</span>
    1246                             <span class="n">grib_write</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="n">fwrf</span><span class="p">)</span>
     1641                            <span class="n">codes_write</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="n">fwrf</span><span class="p">)</span>
    12471642                        <span class="c1"># sfc layer</span>
    12481643                        <span class="k">elif</span> <span class="n">paramId</span> <span class="ow">in</span> <span class="n">wrfpars</span><span class="p">:</span>
    1249                             <span class="n">grib_write</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="n">fwrf</span><span class="p">)</span>
     1644                            <span class="n">codes_write</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="n">fwrf</span><span class="p">)</span>
    12501645                <span class="k">except</span> <span class="ne">AttributeError</span><span class="p">:</span>
    12511646                    <span class="k">pass</span>
    12521647
    1253                 <span class="n">grib_release</span><span class="p">(</span><span class="n">gid</span><span class="p">)</span>
    1254                 <span class="n">gid</span> <span class="o">=</span> <span class="n">grib_new_from_index</span><span class="p">(</span><span class="n">iid</span><span class="p">)</span>
    1255 
     1648                <span class="n">codes_release</span><span class="p">(</span><span class="n">gid</span><span class="p">)</span>
     1649                <span class="n">gid</span> <span class="o">=</span> <span class="n">codes_new_from_index</span><span class="p">(</span><span class="n">iid</span><span class="p">)</span>
     1650<span class="c1">#============================================================================================</span>
    12561651            <span class="k">for</span> <span class="n">f</span> <span class="ow">in</span> <span class="n">fdict</span><span class="o">.</span><span class="n">values</span><span class="p">():</span>
    12571652                <span class="n">f</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>
    1258 
     1653<span class="c1">#============================================================================================</span>
    12591654            <span class="c1"># call for Fortran program to convert e.g. reduced_gg grids to</span>
    12601655            <span class="c1"># regular_ll and calculate detadot/dp</span>
     
    12671662                <span class="n">my_error</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">mailfail</span><span class="p">,</span> <span class="s1">&#39;fort.21 is empty while parameter eta </span><span class="se">\</span>
    12681663<span class="s1">                         is set to 1 in CONTROL file&#39;</span><span class="p">)</span>
     1664<span class="c1">#============================================================================================</span>
     1665            <span class="c1"># write out all output to log file before starting fortran programm</span>
     1666            <span class="n">sys</span><span class="o">.</span><span class="n">stdout</span><span class="o">.</span><span class="n">flush</span><span class="p">()</span>
    12691667
    12701668            <span class="c1"># Fortran program creates file fort.15 (with u,v,etadot,t,sp,q)</span>
    1271             <span class="n">p</span> <span class="o">=</span> <span class="n">subprocess</span><span class="o">.</span><span class="n">check_call</span><span class="p">([</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span>
    1272                 <span class="n">c</span><span class="o">.</span><span class="n">exedir</span><span class="p">,</span> <span class="n">_config</span><span class="o">.</span><span class="n">FORTRAN_EXECUTABLE</span><span class="p">)],</span> <span class="n">shell</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
     1669            <span class="n">execute_subprocess</span><span class="p">([</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">exedir</span><span class="p">,</span>
     1670                                <span class="n">_config</span><span class="o">.</span><span class="n">FORTRAN_EXECUTABLE</span><span class="p">)],</span>
     1671                               <span class="n">error_msg</span><span class="o">=</span><span class="s1">&#39;FORTRAN PROGRAM FAILED!&#39;</span><span class="p">)</span><span class="c1">#shell=True)</span>
     1672
    12731673            <span class="n">os</span><span class="o">.</span><span class="n">chdir</span><span class="p">(</span><span class="n">pwd</span><span class="p">)</span>
    1274 
     1674<span class="c1">#============================================================================================</span>
    12751675            <span class="c1"># create name of final output file, e.g. EN13040500 (ENYYMMDDHH)</span>
    1276             <span class="k">if</span> <span class="n">c</span><span class="o">.</span><span class="n">maxstep</span> <span class="o">&gt;</span> <span class="mi">12</span><span class="p">:</span>
     1676            <span class="k">if</span> <span class="n">c</span><span class="o">.</span><span class="n">purefc</span><span class="p">:</span>
    12771677                <span class="n">suffix</span> <span class="o">=</span> <span class="n">cdate</span><span class="p">[</span><span class="mi">2</span><span class="p">:</span><span class="mi">8</span><span class="p">]</span> <span class="o">+</span> <span class="s1">&#39;.&#39;</span> <span class="o">+</span> <span class="n">ctime</span> <span class="o">+</span> <span class="s1">&#39;.&#39;</span> <span class="o">+</span> <span class="n">cstep</span>
    12781678            <span class="k">else</span><span class="p">:</span>
     
    12821682            <span class="c1"># collect for final processing</span>
    12831683            <span class="bp">self</span><span class="o">.</span><span class="n">outputfilelist</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">basename</span><span class="p">(</span><span class="n">fnout</span><span class="p">))</span>
    1284 
     1684<span class="c1">#============================================================================================</span>
    12851685            <span class="c1"># create outputfile and copy all data from intermediate files</span>
    12861686            <span class="c1"># to the outputfile (final GRIB input files for FLEXPART)</span>
     
    13021702                    <span class="n">shutil</span><span class="o">.</span><span class="n">copyfileobj</span><span class="p">(</span><span class="nb">open</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">inputdir</span><span class="p">,</span> <span class="s1">&#39;fort.25&#39;</span><span class="p">),</span>
    13031703                                            <span class="s1">&#39;rb&#39;</span><span class="p">),</span> <span class="n">fout</span><span class="p">)</span>
    1304 
     1704<span class="c1">#============================================================================================</span>
    13051705        <span class="k">if</span> <span class="n">c</span><span class="o">.</span><span class="n">wrf</span><span class="p">:</span>
    13061706            <span class="n">fwrf</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>
    13071707
    1308         <span class="n">grib_index_release</span><span class="p">(</span><span class="n">iid</span><span class="p">)</span>
     1708        <span class="n">codes_index_release</span><span class="p">(</span><span class="n">iid</span><span class="p">)</span>
    13091709
    13101710        <span class="k">return</span></div>
     
    13121712
    13131713<div class="viewcode-block" id="EcFlexpart.process_output"><a class="viewcode-back" href="../api.html#EcFlexpart.EcFlexpart.process_output">[docs]</a>    <span class="k">def</span> <span class="nf">process_output</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">c</span><span class="p">):</span>
    1314         <span class="sd">&#39;&#39;&#39;The grib files are postprocessed depending on the selection in</span>
     1714        <span class="sd">&#39;&#39;&#39;Postprocessing of FLEXPART input files.</span>
     1715
     1716<span class="sd">        The grib files are postprocessed depending on the selection in</span>
    13151717<span class="sd">        CONTROL file. The resulting files are moved to the output</span>
    13161718<span class="sd">        directory if its not equal to the input directory.</span>
     
    13231725<span class="sd">        Parameters</span>
    13241726<span class="sd">        ----------</span>
    1325 <span class="sd">        c : :obj:`ControlFile`</span>
     1727<span class="sd">        c : ControlFile</span>
    13261728<span class="sd">            Contains all the parameters of CONTROL file and</span>
    13271729<span class="sd">            command line.</span>
     
    13471749
    13481750            <span class="k">if</span> <span class="n">c</span><span class="o">.</span><span class="n">format</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="o">==</span> <span class="s1">&#39;grib2&#39;</span><span class="p">:</span>
    1349                 <span class="n">p</span> <span class="o">=</span> <span class="n">subprocess</span><span class="o">.</span><span class="n">check_call</span><span class="p">([</span><span class="s1">&#39;grib_set&#39;</span><span class="p">,</span> <span class="s1">&#39;-s&#39;</span><span class="p">,</span> <span class="s1">&#39;edition=2, </span><span class="se">\</span>
    1350 <span class="s1">                                           productDefinitionTemplateNumber=8&#39;</span><span class="p">,</span>
    1351                                            <span class="n">ofile</span><span class="p">,</span> <span class="n">ofile</span> <span class="o">+</span> <span class="s1">&#39;_2&#39;</span><span class="p">])</span>
    1352                 <span class="n">p</span> <span class="o">=</span> <span class="n">subprocess</span><span class="o">.</span><span class="n">check_call</span><span class="p">([</span><span class="s1">&#39;mv&#39;</span><span class="p">,</span> <span class="n">ofile</span> <span class="o">+</span> <span class="s1">&#39;_2&#39;</span><span class="p">,</span> <span class="n">ofile</span><span class="p">])</span>
     1751                <span class="n">execute_subprocess</span><span class="p">([</span><span class="s1">&#39;grib_set&#39;</span><span class="p">,</span> <span class="s1">&#39;-s&#39;</span><span class="p">,</span> <span class="s1">&#39;edition=2,&#39;</span> <span class="o">+</span>
     1752                                    <span class="s1">&#39;productDefinitionTemplateNumber=8&#39;</span><span class="p">,</span>
     1753                                    <span class="n">ofile</span><span class="p">,</span> <span class="n">ofile</span> <span class="o">+</span> <span class="s1">&#39;_2&#39;</span><span class="p">],</span>
     1754                                   <span class="n">error_msg</span><span class="o">=</span><span class="s1">&#39;GRIB2 CONVERSION FAILED!&#39;</span><span class="p">)</span>
     1755
     1756                <span class="n">execute_subprocess</span><span class="p">([</span><span class="s1">&#39;mv&#39;</span><span class="p">,</span> <span class="n">ofile</span> <span class="o">+</span> <span class="s1">&#39;_2&#39;</span><span class="p">,</span> <span class="n">ofile</span><span class="p">],</span>
     1757                                   <span class="n">error_msg</span><span class="o">=</span><span class="s1">&#39;RENAMING FOR NEW GRIB2 FORMAT &#39;</span>
     1758                                   <span class="s1">&#39;FILES FAILED!&#39;</span><span class="p">)</span>
    13531759
    13541760            <span class="k">if</span> <span class="n">c</span><span class="o">.</span><span class="n">ectrans</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">c</span><span class="o">.</span><span class="n">ecapi</span><span class="p">:</span>
    1355                 <span class="n">p</span> <span class="o">=</span> <span class="n">subprocess</span><span class="o">.</span><span class="n">check_call</span><span class="p">([</span><span class="s1">&#39;ectrans&#39;</span><span class="p">,</span> <span class="s1">&#39;-overwrite&#39;</span><span class="p">,</span> <span class="s1">&#39;-gateway&#39;</span><span class="p">,</span>
    1356                                            <span class="n">c</span><span class="o">.</span><span class="n">gateway</span><span class="p">,</span> <span class="s1">&#39;-remote&#39;</span><span class="p">,</span> <span class="n">c</span><span class="o">.</span><span class="n">destination</span><span class="p">,</span>
    1357                                            <span class="s1">&#39;-source&#39;</span><span class="p">,</span> <span class="n">ofile</span><span class="p">])</span>
     1761                <span class="n">execute_subprocess</span><span class="p">([</span><span class="s1">&#39;ectrans&#39;</span><span class="p">,</span> <span class="s1">&#39;-overwrite&#39;</span><span class="p">,</span> <span class="s1">&#39;-gateway&#39;</span><span class="p">,</span>
     1762                                    <span class="n">c</span><span class="o">.</span><span class="n">gateway</span><span class="p">,</span> <span class="s1">&#39;-remote&#39;</span><span class="p">,</span> <span class="n">c</span><span class="o">.</span><span class="n">destination</span><span class="p">,</span>
     1763                                    <span class="s1">&#39;-source&#39;</span><span class="p">,</span> <span class="n">ofile</span><span class="p">],</span>
     1764                                   <span class="n">error_msg</span><span class="o">=</span><span class="s1">&#39;TRANSFER TO LOCAL SERVER FAILED!&#39;</span><span class="p">)</span>
    13581765
    13591766            <span class="k">if</span> <span class="n">c</span><span class="o">.</span><span class="n">ecstorage</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">c</span><span class="o">.</span><span class="n">ecapi</span><span class="p">:</span>
    1360                 <span class="n">p</span> <span class="o">=</span> <span class="n">subprocess</span><span class="o">.</span><span class="n">check_call</span><span class="p">([</span><span class="s1">&#39;ecp&#39;</span><span class="p">,</span> <span class="s1">&#39;-o&#39;</span><span class="p">,</span> <span class="n">ofile</span><span class="p">,</span>
    1361                                            <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">expandvars</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">ecfsdir</span><span class="p">)])</span>
     1767                <span class="n">execute_subprocess</span><span class="p">([</span><span class="s1">&#39;ecp&#39;</span><span class="p">,</span> <span class="s1">&#39;-o&#39;</span><span class="p">,</span> <span class="n">ofile</span><span class="p">,</span>
     1768                                    <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">expandvars</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">ecfsdir</span><span class="p">)],</span>
     1769                                   <span class="n">error_msg</span><span class="o">=</span><span class="s1">&#39;COPY OF FILES TO ECSTORAGE &#39;</span>
     1770                                   <span class="s1">&#39;AREA FAILED!&#39;</span><span class="p">)</span>
    13621771
    13631772            <span class="k">if</span> <span class="n">c</span><span class="o">.</span><span class="n">outputdir</span> <span class="o">!=</span> <span class="n">c</span><span class="o">.</span><span class="n">inputdir</span><span class="p">:</span>
    1364                 <span class="n">p</span> <span class="o">=</span> <span class="n">subprocess</span><span class="o">.</span><span class="n">check_call</span><span class="p">([</span><span class="s1">&#39;mv&#39;</span><span class="p">,</span>
    1365                                            <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">inputdir</span><span class="p">,</span> <span class="n">ofile</span><span class="p">),</span>
    1366                                            <span class="n">c</span><span class="o">.</span><span class="n">outputdir</span><span class="p">])</span>
     1773                <span class="n">execute_subprocess</span><span class="p">([</span><span class="s1">&#39;mv&#39;</span><span class="p">,</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">inputdir</span><span class="p">,</span> <span class="n">ofile</span><span class="p">),</span>
     1774                                    <span class="n">c</span><span class="o">.</span><span class="n">outputdir</span><span class="p">],</span>
     1775                                   <span class="n">error_msg</span><span class="o">=</span><span class="s1">&#39;RELOCATION OF OUTPUT FILES &#39;</span>
     1776                                   <span class="s1">&#39;TO OUTPUTDIR FAILED!&#39;</span><span class="p">)</span>
    13671777
    13681778        <span class="k">return</span></div>
     
    13741784<span class="sd">        Parameters</span>
    13751785<span class="sd">        ----------</span>
    1376 <span class="sd">        c : :obj:`ControlFile`</span>
     1786<span class="sd">        c : ControlFile</span>
    13771787<span class="sd">            Contains all the parameters of CONTROL file and</span>
    13781788<span class="sd">            command line.</span>
     
    14191829        <span class="c1"># read template COMMAND file</span>
    14201830        <span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">expandvars</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">expanduser</span><span class="p">(</span>
    1421             <span class="n">c</span><span class="o">.</span><span class="n">flexpart_root_scripts</span><span class="p">))</span> <span class="o">+</span> <span class="s1">&#39;/../Options/COMMAND&#39;</span><span class="p">,</span> <span class="s1">&#39;r&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
     1831            <span class="n">c</span><span class="o">.</span><span class="n">flexpartdir</span><span class="p">))</span> <span class="o">+</span> <span class="s1">&#39;/../Options/COMMAND&#39;</span><span class="p">,</span> <span class="s1">&#39;r&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
    14221832            <span class="n">lflist</span> <span class="o">=</span> <span class="n">f</span><span class="o">.</span><span class="n">read</span><span class="p">()</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s1">&#39;</span><span class="se">\n</span><span class="s1">&#39;</span><span class="p">)</span>
    14231833
     
    14441854        <span class="c1"># afterwards switch back to the working dir</span>
    14451855        <span class="n">os</span><span class="o">.</span><span class="n">chdir</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">outputdir</span><span class="p">)</span>
    1446         <span class="n">p</span> <span class="o">=</span> <span class="n">subprocess</span><span class="o">.</span><span class="n">check_call</span><span class="p">([</span>
    1447             <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">expandvars</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">expanduser</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">flexpart_root_scripts</span><span class="p">))</span>
    1448             <span class="o">+</span> <span class="s1">&#39;/../FLEXPART_PROGRAM/grib2flexpart&#39;</span><span class="p">,</span> <span class="s1">&#39;useAvailable&#39;</span><span class="p">,</span> <span class="s1">&#39;.&#39;</span><span class="p">])</span>
     1856        <span class="n">cmd</span> <span class="o">=</span> <span class="p">[</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">expandvars</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">expanduser</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">flexpartdir</span><span class="p">))</span> <span class="o">+</span>
     1857         <span class="s1">&#39;/../FLEXPART_PROGRAM/grib2flexpart&#39;</span><span class="p">,</span> <span class="s1">&#39;useAvailable&#39;</span><span class="p">,</span> <span class="s1">&#39;.&#39;</span><span class="p">]</span>
     1858        <span class="n">execute_subprocess</span><span class="p">(</span><span class="n">cmd</span><span class="p">)</span>
    14491859        <span class="n">os</span><span class="o">.</span><span class="n">chdir</span><span class="p">(</span><span class="n">pwd</span><span class="p">)</span>
    14501860
     
    14621872  <div role="contentinfo">
    14631873    <p>
    1464         &copy; Copyright 2018, Anne Philipp and Leopold Haimberger.
     1874        &copy; Copyright 2018, Anne Philipp and Leopold Haimberger
    14651875
    14661876    </p>
     
    14811891 
    14821892
    1483     <script type="text/javascript">
    1484         var DOCUMENTATION_OPTIONS = {
    1485             URL_ROOT:'../',
    1486             VERSION:'7.1 alpha',
    1487             LANGUAGE:'None',
    1488             COLLAPSE_INDEX:false,
    1489             FILE_SUFFIX:'.html',
    1490             HAS_SOURCE:  true,
    1491             SOURCELINK_SUFFIX: '.txt'
    1492         };
    1493     </script>
    1494       <script type="text/javascript" src="../_static/jquery.js"></script>
    1495       <script type="text/javascript" src="../_static/underscore.js"></script>
    1496       <script type="text/javascript" src="../_static/doctools.js"></script>
    1497       <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
     1893   
     1894   
     1895      <script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
     1896        <script type="text/javascript" src="../_static/jquery.js"></script>
     1897        <script type="text/javascript" src="../_static/underscore.js"></script>
     1898        <script type="text/javascript" src="../_static/doctools.js"></script>
     1899   
    14981900
    14991901 
  • documentation/Sphinx/build/html/_modules/MarsRetrieval.html

    r274f9ef r2625ca8  
    170170<span class="c1">#        - added documentation</span>
    171171<span class="c1">#        - applied some minor modifications in programming style/structure</span>
     172<span class="c1">#        - added writing of mars request attributes to a csv file</span>
    172173<span class="c1">#</span>
    173174<span class="c1"># @License:</span>
    174 <span class="c1">#    (C) Copyright 2015-2018.</span>
     175<span class="c1">#    (C) Copyright 2014-2019.</span>
     176<span class="c1">#    Anne Philipp, Leopold Haimberger</span>
    175177<span class="c1">#</span>
    176 <span class="c1">#    This software is licensed under the terms of the Apache Licence Version 2.0</span>
    177 <span class="c1">#    which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.</span>
    178 <span class="c1">#</span>
    179 <span class="c1"># @Class Description:</span>
    180 <span class="c1">#    A MARS revtrieval has a specific syntax with a selection of keywords and</span>
    181 <span class="c1">#    their corresponding values. This class provides the necessary functions</span>
    182 <span class="c1">#    by displaying the selected parameters and their values and the actual</span>
    183 <span class="c1">#    retrievement of the data through a mars request or a Python web api</span>
    184 <span class="c1">#    interface. The initialization already expects all the keyword values.</span>
    185 <span class="c1">#</span>
    186 <span class="c1"># @Class Content:</span>
    187 <span class="c1">#    - __init__</span>
    188 <span class="c1">#    - display_info</span>
    189 <span class="c1">#    - data_retrieve</span>
    190 <span class="c1">#</span>
    191 <span class="c1"># @Class Attributes:</span>
    192 <span class="c1">#    - server</span>
    193 <span class="c1">#    - marsclass</span>
    194 <span class="c1">#    - dtype</span>
    195 <span class="c1">#    - levtype</span>
    196 <span class="c1">#    - levelist</span>
    197 <span class="c1">#    - repres</span>
    198 <span class="c1">#    - date</span>
    199 <span class="c1">#    - resol</span>
    200 <span class="c1">#    - stream</span>
    201 <span class="c1">#    - area</span>
    202 <span class="c1">#    - time</span>
    203 <span class="c1">#    - step</span>
    204 <span class="c1">#    - expver</span>
    205 <span class="c1">#    - number</span>
    206 <span class="c1">#    - accuracy</span>
    207 <span class="c1">#    - grid</span>
    208 <span class="c1">#    - gaussian</span>
    209 <span class="c1">#    - target</span>
    210 <span class="c1">#    - param</span>
    211 <span class="c1">#</span>
     178<span class="c1">#    This work is licensed under the Creative Commons Attribution 4.0</span>
     179<span class="c1">#    International License. To view a copy of this license, visit</span>
     180<span class="c1">#    http://creativecommons.org/licenses/by/4.0/ or send a letter to</span>
     181<span class="c1">#    Creative Commons, PO Box 1866, Mountain View, CA 94042, USA.</span>
    212182<span class="c1">#*******************************************************************************</span>
    213183
     
    226196<span class="c1"># ------------------------------------------------------------------------------</span>
    227197<div class="viewcode-block" id="MarsRetrieval"><a class="viewcode-back" href="../api.html#MarsRetrieval.MarsRetrieval">[docs]</a><span class="k">class</span> <span class="nc">MarsRetrieval</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
    228     <span class="sd">&#39;&#39;&#39;Class for submitting MARS retrievals.</span>
     198    <span class="sd">&#39;&#39;&#39;Specific syntax and content for submission of MARS retrievals.</span>
     199
     200<span class="sd">    A MARS revtrieval has a specific syntax with a selection of keywords and</span>
     201<span class="sd">    their corresponding values. This class provides the necessary functions</span>
     202<span class="sd">    by displaying the selected parameters and their values and the actual</span>
     203<span class="sd">    retrievement of the data through a mars request or a Python web api</span>
     204<span class="sd">    interface. The initialization already expects all the keyword values.</span>
    229205
    230206<span class="sd">    A description of MARS keywords/arguments and examples of their</span>
     
    232208<span class="sd">    https://software.ecmwf.int/wiki/display/UDOC/\</span>
    233209<span class="sd">                   Identification+keywords#Identificationkeywords-class</span>
     210
     211<span class="sd">    Attributes</span>
     212<span class="sd">    ----------</span>
     213<span class="sd">    server : ECMWFService or ECMWFDataServer</span>
     214<span class="sd">        This is the connection to the ECMWF data servers.</span>
     215
     216<span class="sd">    public : int</span>
     217<span class="sd">        Decides which Web API Server version is used.</span>
     218
     219<span class="sd">    marsclass : str, optional</span>
     220<span class="sd">        Characterisation of dataset.</span>
     221
     222<span class="sd">    dataset : str, optional</span>
     223<span class="sd">        For public datasets there is the specific naming and parameter</span>
     224<span class="sd">        dataset which has to be used to characterize the type of</span>
     225<span class="sd">        data.</span>
     226
     227<span class="sd">    type : str, optional</span>
     228<span class="sd">        Determines the type of fields to be retrieved.</span>
     229
     230<span class="sd">    levtype : str, optional</span>
     231<span class="sd">        Denotes type of level.</span>
     232
     233<span class="sd">    levelist : str, optional</span>
     234<span class="sd">        Specifies the required levels.</span>
     235
     236<span class="sd">    repres : str, optional</span>
     237<span class="sd">        Selects the representation of the archived data.</span>
     238
     239<span class="sd">    date : str, optional</span>
     240<span class="sd">        Specifies the Analysis date, the Forecast base date or</span>
     241<span class="sd">        Observations date.</span>
     242
     243<span class="sd">    resol : str, optional</span>
     244<span class="sd">        Specifies the desired triangular truncation of retrieved data,</span>
     245<span class="sd">        before carrying out any other selected post-processing.</span>
     246
     247<span class="sd">    stream : str, optional</span>
     248<span class="sd">        Identifies the forecasting system used to generate the data.</span>
     249
     250<span class="sd">    area : str, optional</span>
     251<span class="sd">        Specifies the desired sub-area of data to be extracted.</span>
     252
     253<span class="sd">    time : str, optional</span>
     254<span class="sd">        Specifies the time of the data in hours and minutes.</span>
     255
     256<span class="sd">    step : str, optional</span>
     257<span class="sd">        Specifies the forecast time step from forecast base time.</span>
     258
     259<span class="sd">    expver : str, optional</span>
     260<span class="sd">        The version of the dataset.</span>
     261
     262<span class="sd">    number : str, optional</span>
     263<span class="sd">        Selects the member in ensemble forecast run.</span>
     264
     265<span class="sd">    accuracy : str, optional</span>
     266<span class="sd">        Specifies the number of bits per value to be used in the</span>
     267<span class="sd">        generated GRIB coded fields.</span>
     268
     269<span class="sd">    grid : str, optional</span>
     270<span class="sd">        Specifies the output grid which can be either a Gaussian grid</span>
     271<span class="sd">        or a Latitude/Longitude grid.</span>
     272
     273<span class="sd">    gaussian : str, optional</span>
     274<span class="sd">        This parameter is deprecated and should no longer be used.</span>
     275<span class="sd">        Specifies the desired type of Gaussian grid for the output.</span>
     276
     277<span class="sd">    target : str, optional</span>
     278<span class="sd">        Specifies a file into which data is to be written after</span>
     279<span class="sd">        retrieval or manipulation.</span>
     280
     281<span class="sd">    param : str, optional</span>
     282<span class="sd">        Specifies the meteorological parameter.</span>
    234283<span class="sd">    &#39;&#39;&#39;</span>
    235284
     
    249298<span class="sd">        Parameters</span>
    250299<span class="sd">        ----------</span>
    251 <span class="sd">        server : :obj:`ECMWFService`</span>
     300<span class="sd">        server : ECMWFService or ECMWFDataServer</span>
    252301<span class="sd">            This is the connection to the ECMWF data servers.</span>
    253302<span class="sd">            It is needed for the pythonic access of ECMWF data.</span>
    254303
    255 <span class="sd">        public : :obj:`integer`</span>
     304<span class="sd">        public : int</span>
    256305<span class="sd">            Decides which Web API version is used:</span>
    257306<span class="sd">            0: member-state users and full archive access</span>
     
    260309<span class="sd">            Default is &quot;0&quot; and for member-state users.</span>
    261310
    262 <span class="sd">        marsclass : :obj:`string`, optional</span>
     311<span class="sd">        marsclass : str, optional</span>
    263312<span class="sd">            Characterisation of dataset. E.g. EI (ERA-Interim),</span>
    264313<span class="sd">            E4 (ERA40), OD (Operational archive), ea (ERA5).</span>
    265314<span class="sd">            Default is the ERA-Interim dataset &quot;ei&quot;.</span>
    266315
    267 <span class="sd">        dataset : :obj:`string`, optional</span>
     316<span class="sd">        dataset : str, optional</span>
    268317<span class="sd">            For public datasets there is the specific naming and parameter</span>
    269318<span class="sd">            dataset which has to be used to characterize the type of</span>
     
    272321<span class="sd">            Default is an empty string.</span>
    273322
    274 <span class="sd">        type : :obj:`string`, optional</span>
     323<span class="sd">        type : str, optional</span>
    275324<span class="sd">            Determines the type of fields to be retrieved.</span>
    276325<span class="sd">            Selects between observations, images or fields.</span>
     
    279328<span class="sd">            Default is an empty string.</span>
    280329
    281 <span class="sd">        levtype : :obj:`string`, optional</span>
     330<span class="sd">        levtype : str, optional</span>
    282331<span class="sd">            Denotes type of level. Has a direct implication on valid</span>
    283332<span class="sd">            levelist values!</span>
     
    287336<span class="sd">            Default is an empty string.</span>
    288337
    289 <span class="sd">        levelist : :obj:`string`, optional</span>
     338<span class="sd">        levelist : str, optional</span>
    290339<span class="sd">            Specifies the required levels. It has to have a valid</span>
    291340<span class="sd">            correspondence to the selected levtype.</span>
     
    293342<span class="sd">            Default is an empty string.</span>
    294343
    295 <span class="sd">        repres : :obj:`string`, optional</span>
     344<span class="sd">        repres : str, optional</span>
    296345<span class="sd">            Selects the representation of the archived data.</span>
    297346<span class="sd">            E.g. sh - spherical harmonics, gg - Gaussian grid,</span>
     
    299348<span class="sd">            Default is an empty string.</span>
    300349
    301 <span class="sd">        date : :obj:`string`, optional</span>
     350<span class="sd">        date : str, optional</span>
    302351<span class="sd">            Specifies the Analysis date, the Forecast base date or</span>
    303352<span class="sd">            Observations date. Valid formats are:</span>
     
    305354<span class="sd">            Default is an empty string.</span>
    306355
    307 <span class="sd">        resol : :obj:`string`, optional</span>
     356<span class="sd">        resol : str, optional</span>
    308357<span class="sd">            Specifies the desired triangular truncation of retrieved data,</span>
    309358<span class="sd">            before carrying out any other selected post-processing.</span>
     
    322371<span class="sd">            Default is an empty string.</span>
    323372
    324 <span class="sd">        stream : :obj:`string`, optional</span>
     373<span class="sd">        stream : str, optional</span>
    325374<span class="sd">            Identifies the forecasting system used to generate the data.</span>
    326375<span class="sd">            E.g. oper (Atmospheric model), enfo (Ensemble forecats), ...</span>
    327376<span class="sd">            Default is an empty string.</span>
    328377
    329 <span class="sd">        area : :obj:`string`, optional</span>
     378<span class="sd">        area : str, optional</span>
    330379<span class="sd">            Specifies the desired sub-area of data to be extracted.</span>
    331380<span class="sd">            Areas can be defined to wrap around the globe.</span>
     
    345394<span class="sd">            Default is an empty string.</span>
    346395
    347 <span class="sd">        time : :obj:`string`, optional</span>
     396<span class="sd">        time : str, optional</span>
    348397<span class="sd">            Specifies the time of the data in hours and minutes.</span>
    349398<span class="sd">            Valid values depend on the type of data: Analysis time,</span>
     
    355404<span class="sd">            Default is an empty string.</span>
    356405
    357 <span class="sd">        step : :obj:`string`, optional</span>
     406<span class="sd">        step : str, optional</span>
    358407<span class="sd">            Specifies the forecast time step from forecast base time.</span>
    359408<span class="sd">            Valid values are hours (HH) from forecast base time. It also</span>
     
    363412<span class="sd">            Default is an empty string.</span>
    364413
    365 <span class="sd">        expver : :obj:`string`, optional</span>
     414<span class="sd">        expver : str, optional</span>
    366415<span class="sd">            The version of the dataset. Each experiment is assigned a</span>
    367416<span class="sd">            unique code (version). Production data is assigned 1 or 2,</span>
     
    371420<span class="sd">            Default is &quot;1&quot;.</span>
    372421
    373 <span class="sd">        number : :obj:`string`, optional</span>
     422<span class="sd">        number : str, optional</span>
    374423<span class="sd">            Selects the member in ensemble forecast run. (Only then it</span>
    375424<span class="sd">            is necessary.) It has a different meaning depending on</span>
     
    378427<span class="sd">            Default is an empty string.</span>
    379428
    380 <span class="sd">        accuracy : :obj:`string`, optional</span>
     429<span class="sd">        accuracy : str, optional</span>
    381430<span class="sd">            Specifies the number of bits per value to be used in the</span>
    382431<span class="sd">            generated GRIB coded fields.</span>
     
    389438<span class="sd">            Default is an empty string.</span>
    390439
    391 <span class="sd">        grid : :obj:`string`, optional</span>
     440<span class="sd">        grid : str, optional</span>
    392441<span class="sd">            Specifies the output grid which can be either a Gaussian grid</span>
    393442<span class="sd">            or a Latitude/Longitude grid. MARS requests specifying</span>
     
    410459<span class="sd">            Default is an empty string.</span>
    411460
    412 <span class="sd">        gaussian : :obj:`string`, optional</span>
     461<span class="sd">        gaussian : str, optional</span>
    413462<span class="sd">            This parameter is deprecated and should no longer be used.</span>
    414463<span class="sd">            Specifies the desired type of Gaussian grid for the output.</span>
     
    418467<span class="sd">            Default is an empty string.</span>
    419468
    420 <span class="sd">        target : :obj:`string`, optional</span>
     469<span class="sd">        target : str, optional</span>
    421470<span class="sd">            Specifies a file into which data is to be written after</span>
    422471<span class="sd">            retrieval or manipulation. Path names should always be</span>
     
    432481<span class="sd">            Default is an empty string.</span>
    433482
    434 <span class="sd">        param : :obj:`string`, optional</span>
     483<span class="sd">        param : str, optional</span>
    435484<span class="sd">            Specifies the meteorological parameter.</span>
    436485<span class="sd">            The list of meteorological parameters in MARS is extensive.</span>
     
    500549
    501550
    502 <div class="viewcode-block" id="MarsRetrieval.print_info"><a class="viewcode-back" href="../api.html#MarsRetrieval.MarsRetrieval.print_info">[docs]</a>    <span class="k">def</span> <span class="nf">print_info</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">inputdir</span><span class="p">,</span> <span class="n">request_number</span><span class="p">):</span>
    503         <span class="sd">&#39;&#39;&#39;Prints all mars requests to an extra file for debugging and</span>
    504 <span class="sd">        information.</span>
     551<div class="viewcode-block" id="MarsRetrieval.print_infodata_csv"><a class="viewcode-back" href="../api.html#MarsRetrieval.MarsRetrieval.print_infodata_csv">[docs]</a>    <span class="k">def</span> <span class="nf">print_infodata_csv</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">inputdir</span><span class="p">,</span> <span class="n">request_number</span><span class="p">):</span>
     552        <span class="sd">&#39;&#39;&#39;Write all request parameter in alpabetical order into a &quot;csv&quot; file.</span>
    505553
    506554<span class="sd">        Parameters</span>
    507555<span class="sd">        ----------</span>
    508 <span class="sd">        inputdir : :obj:`string`</span>
     556<span class="sd">        inputdir : str</span>
    509557<span class="sd">            The path where all data from the retrievals are stored.</span>
    510558
    511 <span class="sd">        request_number : :obj:`integer`</span>
    512 <span class="sd">            Number of mars requests for flux and non-flux data.</span>
    513 
    514 <span class="sd">        Return</span>
    515 <span class="sd">        ------</span>
    516 
    517 <span class="sd">        &#39;&#39;&#39;</span>
    518         <span class="c1"># Get all class attributes and their values as a dictionary</span>
    519         <span class="n">attrs</span> <span class="o">=</span> <span class="nb">vars</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span>
    520 
    521         <span class="c1"># open a file to store all requests to</span>
    522         <span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">inputdir</span><span class="p">,</span>
    523                                <span class="n">_config</span><span class="o">.</span><span class="n">FILE_MARS_REQUESTS</span><span class="p">),</span> <span class="s1">&#39;a&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
    524             <span class="n">f</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s1">&#39;mars_request #&#39;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">request_number</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39;</span><span class="se">\n</span><span class="s1">&#39;</span><span class="p">)</span>
    525             <span class="c1"># iterate through all attributes and print them</span>
    526             <span class="c1"># with their corresponding values</span>
    527             <span class="k">for</span> <span class="n">item</span> <span class="ow">in</span> <span class="n">attrs</span><span class="o">.</span><span class="n">items</span><span class="p">():</span>
    528                 <span class="k">if</span> <span class="n">item</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="ow">in</span> <span class="p">[</span><span class="s1">&#39;server&#39;</span><span class="p">,</span> <span class="s1">&#39;public&#39;</span><span class="p">]:</span>
    529                     <span class="k">pass</span>
    530                 <span class="k">else</span><span class="p">:</span>
    531                     <span class="n">f</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">item</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">+</span> <span class="s1">&#39;: &#39;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">item</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span> <span class="o">+</span> <span class="s1">&#39;</span><span class="se">\n</span><span class="s1">&#39;</span><span class="p">)</span>
    532             <span class="n">f</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s1">&#39;</span><span class="se">\n\n</span><span class="s1">&#39;</span><span class="p">)</span>
    533 
    534         <span class="k">return</span></div>
    535 
    536 
    537 <div class="viewcode-block" id="MarsRetrieval.print_infodata_csv"><a class="viewcode-back" href="../api.html#MarsRetrieval.MarsRetrieval.print_infodata_csv">[docs]</a>    <span class="k">def</span> <span class="nf">print_infodata_csv</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">inputdir</span><span class="p">,</span> <span class="n">request_number</span><span class="p">):</span>
    538         <span class="sd">&#39;&#39;&#39;Write all request parameter in alpabetical order into a &quot;csv&quot; file.</span>
    539 
    540 <span class="sd">        Parameters</span>
    541 <span class="sd">        ----------</span>
    542 <span class="sd">        inputdir : :obj:`string`</span>
    543 <span class="sd">            The path where all data from the retrievals are stored.</span>
    544 
    545 <span class="sd">        request_number : :obj:`integer`</span>
     559<span class="sd">        request_number : int</span>
    546560<span class="sd">            Number of mars requests for flux and non-flux data.</span>
    547561
     
    668682  <div role="contentinfo">
    669683    <p>
    670         &copy; Copyright 2018, Anne Philipp and Leopold Haimberger.
     684        &copy; Copyright 2018, Anne Philipp and Leopold Haimberger
    671685
    672686    </p>
     
    687701 
    688702
    689     <script type="text/javascript">
    690         var DOCUMENTATION_OPTIONS = {
    691             URL_ROOT:'../',
    692             VERSION:'7.1 alpha',
    693             LANGUAGE:'None',
    694             COLLAPSE_INDEX:false,
    695             FILE_SUFFIX:'.html',
    696             HAS_SOURCE:  true,
    697             SOURCELINK_SUFFIX: '.txt'
    698         };
    699     </script>
    700       <script type="text/javascript" src="../_static/jquery.js"></script>
    701       <script type="text/javascript" src="../_static/underscore.js"></script>
    702       <script type="text/javascript" src="../_static/doctools.js"></script>
    703       <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
     703   
     704   
     705      <script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
     706        <script type="text/javascript" src="../_static/jquery.js"></script>
     707        <script type="text/javascript" src="../_static/underscore.js"></script>
     708        <script type="text/javascript" src="../_static/doctools.js"></script>
     709   
    704710
    705711 
  • documentation/Sphinx/build/html/_modules/UioFiles.html

    r274f9ef r2625ca8  
    165165<span class="c1">#        - added pattern search in method list_files</span>
    166166<span class="c1">#</span>
    167 <span class="c1">#    February 2018 - Anne Philipp (University of Vienna):</span>
     167<span class="c1">#    February - December 2018 - Anne Philipp (University of Vienna):</span>
    168168<span class="c1">#        - applied PEP8 style guide</span>
    169169<span class="c1">#        - added documentation</span>
     
    173173<span class="c1">#        - modified the class so that it is initiated with a pattern instead</span>
    174174<span class="c1">#          of suffixes. Gives more precision in selection of files.</span>
     175<span class="c1">#        - added delete method</span>
    175176<span class="c1">#</span>
    176177<span class="c1"># @License:</span>
    177 <span class="c1">#    (C) Copyright 2014-2018.</span>
    178 <span class="c1">#</span>
    179 <span class="c1">#    This software is licensed under the terms of the Apache Licence Version 2.0</span>
    180 <span class="c1">#    which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.</span>
    181 <span class="c1">#</span>
    182 <span class="c1"># @Class Decription:</span>
    183 <span class="c1">#    The class is for file manipulation. It is initiated with a regular</span>
    184 <span class="c1">#    expression pattern for this instance and can produce a list of Files</span>
    185 <span class="c1">#    from the given file pattern. These files can be deleted.</span>
    186 <span class="c1">#</span>
    187 <span class="c1"># @Class Content:</span>
    188 <span class="c1">#    - __init__</span>
    189 <span class="c1">#    - __str__</span>
    190 <span class="c1">#    - __list_files__</span>
    191 <span class="c1">#    - delete_files</span>
    192 <span class="c1">#</span>
    193 <span class="c1"># @Class Attributes:</span>
    194 <span class="c1">#    - pattern</span>
    195 <span class="c1">#    - files</span>
    196 <span class="c1">#</span>
     178<span class="c1">#    (C) Copyright 2014-2019.</span>
     179<span class="c1">#    Anne Philipp, Leopold Haimberger</span>
     180<span class="c1">#</span>
     181<span class="c1">#    This work is licensed under the Creative Commons Attribution 4.0</span>
     182<span class="c1">#    International License. To view a copy of this license, visit</span>
     183<span class="c1">#    http://creativecommons.org/licenses/by/4.0/ or send a letter to</span>
     184<span class="c1">#    Creative Commons, PO Box 1866, Mountain View, CA 94042, USA.</span>
    197185<span class="c1">#*******************************************************************************</span>
    198186
     
    204192<span class="kn">import</span> <span class="nn">fnmatch</span>
    205193
    206 <span class="c1"># software specific module from flex_extract</span>
     194<span class="c1"># software specific modules from flex_extract</span>
    207195<span class="n">sys</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;../&#39;</span><span class="p">)</span>
    208 <span class="c1">#import profiling</span>
    209196<span class="kn">from</span> <span class="nn">mods.tools</span> <span class="k">import</span> <span class="n">silent_remove</span><span class="p">,</span> <span class="n">get_list_as_string</span>
    210197
     
    214201
    215202<div class="viewcode-block" id="UioFiles"><a class="viewcode-back" href="../api.html#UioFiles.UioFiles">[docs]</a><span class="k">class</span> <span class="nc">UioFiles</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
    216     <span class="sd">&#39;&#39;&#39;Class to manipulate files. At initialisation it has the pattern</span>
    217 <span class="sd">    which stores a regular expression pattern for the files, the path</span>
    218 <span class="sd">    to the files and the files already.</span>
     203    <span class="sd">&#39;&#39;&#39;Collection of files matching a specific pattern.</span>
     204
     205<span class="sd">    The pattern can contain regular expressions for the files.</span>
     206<span class="sd">    The files are listed and can be transformed to a single string or</span>
     207<span class="sd">    they can be deleted.</span>
     208
     209<span class="sd">    Attributes</span>
     210<span class="sd">    ----------</span>
     211<span class="sd">    path : str</span>
     212<span class="sd">        Directory where to list the files.</span>
     213
     214<span class="sd">    pattern : str</span>
     215<span class="sd">        Regular expression pattern. For example: &#39;\*.grb&#39;</span>
     216
     217<span class="sd">    files : list of str</span>
     218<span class="sd">        List of files matching the pattern in the path.</span>
    219219<span class="sd">    &#39;&#39;&#39;</span>
    220220    <span class="c1"># --------------------------------------------------------------------------</span>
    221     <span class="c1"># CLASS FUNCTIONS</span>
     221    <span class="c1"># CLASS METHODS</span>
    222222    <span class="c1"># --------------------------------------------------------------------------</span>
    223223    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">path</span><span class="p">,</span> <span class="n">pattern</span><span class="p">):</span>
     
    226226<span class="sd">        Parameters</span>
    227227<span class="sd">        ----------</span>
    228 <span class="sd">        path : :obj:`string`</span>
     228<span class="sd">        path : str</span>
    229229<span class="sd">            Directory where to list the files.</span>
    230230
    231 <span class="sd">        pattern : :obj:`string`</span>
     231<span class="sd">        pattern : str</span>
    232232<span class="sd">            Regular expression pattern. For example: &#39;\*.grb&#39;</span>
    233233
     
    241241        <span class="bp">self</span><span class="o">.</span><span class="n">files</span> <span class="o">=</span> <span class="p">[]</span>
    242242
    243         <span class="bp">self</span><span class="o">.</span><span class="n">__list_files__</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">path</span><span class="p">)</span>
     243        <span class="bp">self</span><span class="o">.</span><span class="n">_list_files</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">path</span><span class="p">)</span>
    244244
    245245        <span class="k">return</span>
    246246
    247     <span class="c1">#@profiling.timefn</span>
    248     <span class="k">def</span> <span class="nf">__list_files__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">path</span><span class="p">):</span>
     247
     248    <span class="k">def</span> <span class="nf">_list_files</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">path</span><span class="p">):</span>
    249249        <span class="sd">&#39;&#39;&#39;Lists all files in the directory with the matching</span>
    250250<span class="sd">        regular expression pattern.</span>
     
    252252<span class="sd">        Parameters</span>
    253253<span class="sd">        ----------</span>
    254 <span class="sd">        path : :obj:`string`</span>
     254<span class="sd">        path : str</span>
    255255<span class="sd">            Path to the files.</span>
    256256
     
    269269        <span class="k">return</span>
    270270
     271
    271272    <span class="k">def</span> <span class="nf">__str__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
    272273        <span class="sd">&#39;&#39;&#39;Converts the list of files into a single string.</span>
     
    278279<span class="sd">        Return</span>
    279280<span class="sd">        ------</span>
    280 <span class="sd">        files_string : :obj:`string`</span>
     281<span class="sd">        files_string : str</span>
    281282<span class="sd">            The content of the list as a single string.</span>
    282283<span class="sd">        &#39;&#39;&#39;</span>
     
    286287
    287288        <span class="k">return</span> <span class="n">files_string</span>
     289
    288290
    289291<div class="viewcode-block" id="UioFiles.delete_files"><a class="viewcode-back" href="../api.html#UioFiles.UioFiles.delete_files">[docs]</a>    <span class="k">def</span> <span class="nf">delete_files</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
     
    314316  <div role="contentinfo">
    315317    <p>
    316         &copy; Copyright 2018, Anne Philipp and Leopold Haimberger.
     318        &copy; Copyright 2018, Anne Philipp and Leopold Haimberger
    317319
    318320    </p>
     
    333335 
    334336
    335     <script type="text/javascript">
    336         var DOCUMENTATION_OPTIONS = {
    337             URL_ROOT:'../',
    338             VERSION:'7.1 alpha',
    339             LANGUAGE:'None',
    340             COLLAPSE_INDEX:false,
    341             FILE_SUFFIX:'.html',
    342             HAS_SOURCE:  true,
    343             SOURCELINK_SUFFIX: '.txt'
    344         };
    345     </script>
    346       <script type="text/javascript" src="../_static/jquery.js"></script>
    347       <script type="text/javascript" src="../_static/underscore.js"></script>
    348       <script type="text/javascript" src="../_static/doctools.js"></script>
    349       <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
     337   
     338   
     339      <script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
     340        <script type="text/javascript" src="../_static/jquery.js"></script>
     341        <script type="text/javascript" src="../_static/underscore.js"></script>
     342        <script type="text/javascript" src="../_static/doctools.js"></script>
     343   
    350344
    351345 
  • documentation/Sphinx/build/html/_modules/disaggregation.html

    r708c667 r2625ca8  
    170170<span class="c1">#        - outsourced the disaggregation functions dapoly and darain</span>
    171171<span class="c1">#          to a new module named disaggregation</span>
     172<span class="c1">#        - added the new disaggregation method for precipitation</span>
    172173<span class="c1">#</span>
    173174<span class="c1"># @License:</span>
    174 <span class="c1">#    (C) Copyright 2015-2018.</span>
     175<span class="c1">#    (C) Copyright 2014-2019.</span>
     176<span class="c1">#    Anne Philipp, Leopold Haimberger</span>
    175177<span class="c1">#</span>
    176 <span class="c1">#    This software is licensed under the terms of the Apache Licence Version 2.0</span>
    177 <span class="c1">#    which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.</span>
     178<span class="c1">#    This work is licensed under the Creative Commons Attribution 4.0</span>
     179<span class="c1">#    International License. To view a copy of this license, visit</span>
     180<span class="c1">#    http://creativecommons.org/licenses/by/4.0/ or send a letter to</span>
     181<span class="c1">#    Creative Commons, PO Box 1866, Mountain View, CA 94042, USA.</span>
    178182<span class="c1">#</span>
    179 <span class="c1"># @Module Description:</span>
    180 <span class="c1">#    disaggregation of deaccumulated flux data from an ECMWF model FG field.</span>
    181 <span class="c1">#    Initially the flux data to be concerned are:</span>
    182 <span class="c1">#    - large-scale precipitation</span>
    183 <span class="c1">#    - convective precipitation</span>
    184 <span class="c1">#    - surface sensible heat flux</span>
    185 <span class="c1">#    - surface solar radiation</span>
    186 <span class="c1">#    - u stress</span>
    187 <span class="c1">#    - v stress</span>
    188 <span class="c1">#    Different versions of disaggregation is provided for rainfall</span>
    189 <span class="c1">#    data (darain, modified linear) and the surface fluxes and</span>
    190 <span class="c1">#    stress data (dapoly, cubic polynomial).</span>
    191 <span class="c1">#</span>
    192 <span class="c1"># @Module Content:</span>
     183<span class="c1"># @Methods:</span>
    193184<span class="c1">#    - dapoly</span>
    194185<span class="c1">#    - darain</span>
    195186<span class="c1">#    - IA3</span>
    196 <span class="c1">#</span>
    197187<span class="c1">#*******************************************************************************</span>
     188<span class="sd">&#39;&#39;&#39;Disaggregation of deaccumulated flux data from an ECMWF model FG field.</span>
     189
     190<span class="sd">Initially the flux data to be concerned are:</span>
     191<span class="sd">    - large-scale precipitation</span>
     192<span class="sd">    - convective precipitation</span>
     193<span class="sd">    - surface sensible heat flux</span>
     194<span class="sd">    - surface solar radiation</span>
     195<span class="sd">    - u stress</span>
     196<span class="sd">    - v stress</span>
     197
     198<span class="sd">Different versions of disaggregation is provided for rainfall</span>
     199<span class="sd">data (darain, modified linear) and the surface fluxes and</span>
     200<span class="sd">stress data (dapoly, cubic polynomial).</span>
     201<span class="sd">&#39;&#39;&#39;</span>
    198202
    199203<span class="c1"># ------------------------------------------------------------------------------</span>
     
    218222<span class="sd">    Parameters</span>
    219223<span class="sd">    ----------</span>
    220 <span class="sd">    alist : :obj:`list` of :obj:`array` of :obj:`float`</span>
     224<span class="sd">    alist : list of array of float</span>
    221225<span class="sd">        List of 4 timespans as 2-dimensional, horizontal fields.</span>
    222226<span class="sd">        E.g. [[array_t1], [array_t2], [array_t3], [array_t4]]</span>
     
    224228<span class="sd">    Return</span>
    225229<span class="sd">    ------</span>
    226 <span class="sd">    nfield : :obj:`array` of :obj:`float`</span>
     230<span class="sd">    nfield : array of float</span>
    227231<span class="sd">        Interpolated flux at central point of accumulation timespan.</span>
    228232
     
    262266<span class="sd">    Parameters</span>
    263267<span class="sd">    ----------</span>
    264 <span class="sd">    alist : :obj:`list` of :obj:`array` of :obj:`float`</span>
     268<span class="sd">    alist : list of array of float</span>
    265269<span class="sd">        List of 4 timespans as 2-dimensional, horizontal fields.</span>
    266270<span class="sd">        E.g. [[array_t1], [array_t2], [array_t3], [array_t4]]</span>
     
    268272<span class="sd">    Return</span>
    269273<span class="sd">    ------</span>
    270 <span class="sd">    nfield : :obj:`array` of :obj:`float`</span>
     274<span class="sd">    nfield : array of float</span>
    271275<span class="sd">        Interpolated flux at central point of accumulation timespan.</span>
    272276
     
    313317<span class="sd">    Note</span>
    314318<span class="sd">    ----</span>
    315 <span class="sd">    Copyright 2017</span>
     319<span class="sd">    (C) Copyright 2017-2019</span>
    316320<span class="sd">    Sabine Hittmeir, Anne Philipp, Petra Seibert</span>
    317321
     
    323327<span class="sd">    Parameters</span>
    324328<span class="sd">    ----------</span>
    325 <