source: flex_extract.git/documentation/Sphinx/build/html/_modules/ControlFile.html @ 2625ca8

dev
Last change on this file since 2625ca8 was 2625ca8, checked in by Anne Philipp <anne.philipp@…>, 4 months ago

new build of sphinx for updated api

  • Property mode set to 100644
File size: 71.5 KB
Line 
1
2
3<!DOCTYPE html>
4<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
5<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
6<head>
7  <meta charset="utf-8">
8 
9  <meta name="viewport" content="width=device-width, initial-scale=1.0">
10 
11  <title>ControlFile &mdash; flex_extract 7.1 alpha documentation</title>
12 
13
14 
15 
16 
17 
18
19 
20
21 
22 
23   
24
25 
26
27  <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
28  <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
29    <link rel="index" title="Index" href="../genindex.html" />
30    <link rel="search" title="Search" href="../search.html" /> 
31
32 
33  <script src="../_static/js/modernizr.min.js"></script>
34
35</head>
36
37<body class="wy-body-for-nav">
38
39   
40  <div class="wy-grid-for-nav">
41
42   
43    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
44      <div class="wy-side-scroll">
45        <div class="wy-side-nav-search">
46         
47
48         
49            <a href="../index.html" class="icon icon-home"> flex_extract
50         
51
52         
53          </a>
54
55         
56           
57           
58              <div class="version">
59                7.1
60              </div>
61           
62         
63
64         
65<div role="search">
66  <form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
67    <input type="text" name="q" placeholder="Search docs" />
68    <input type="hidden" name="check_keywords" value="yes" />
69    <input type="hidden" name="area" value="default" />
70  </form>
71</div>
72
73         
74        </div>
75
76        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
77         
78           
79           
80             
81           
82           
83              <p class="caption"><span class="caption-text">Table of Contents:</span></p>
84<ul>
85<li class="toctree-l1"><a class="reference internal" href="../downloads.html">Downloads</a></li>
86<li class="toctree-l1"><a class="reference internal" href="../installation.html">Installation</a></li>
87<li class="toctree-l1"><a class="reference internal" href="../program_structure.html">Program Structure</a></li>
88<li class="toctree-l1"><a class="reference internal" href="../user_guide.html">User Guide</a></li>
89<li class="toctree-l1"><a class="reference internal" href="../api.html">Auto Generated Documentation</a></li>
90<li class="toctree-l1"><a class="reference internal" href="../support.html">Support</a></li>
91</ul>
92
93           
94         
95        </div>
96      </div>
97    </nav>
98
99    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
100
101     
102      <nav class="wy-nav-top" aria-label="top navigation">
103       
104          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
105          <a href="../index.html">flex_extract</a>
106       
107      </nav>
108
109
110      <div class="wy-nav-content">
111       
112        <div class="rst-content">
113       
114         
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130<div role="navigation" aria-label="breadcrumbs navigation">
131
132  <ul class="wy-breadcrumbs">
133   
134      <li><a href="../index.html">Docs</a> &raquo;</li>
135       
136          <li><a href="index.html">Module code</a> &raquo;</li>
137       
138      <li>ControlFile</li>
139   
140   
141      <li class="wy-breadcrumbs-aside">
142       
143      </li>
144   
145  </ul>
146
147 
148  <hr/>
149</div>
150          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
151           <div itemprop="articleBody">
152           
153  <h1>Source code for ControlFile</h1><div class="highlight"><pre>
154<span></span><span class="ch">#!/usr/bin/env python</span>
155<span class="c1"># -*- coding: utf-8 -*-</span>
156<span class="c1">#*******************************************************************************</span>
157<span class="c1"># @Author: Leopold Haimberger (University of Vienna)</span>
158<span class="c1">#</span>
159<span class="c1"># @Date: November 2015</span>
160<span class="c1">#</span>
161<span class="c1"># @Change History:</span>
162<span class="c1">#</span>
163<span class="c1">#   February 2018 - Anne Philipp (University of Vienna):</span>
164<span class="c1">#        - applied PEP8 style guide</span>
165<span class="c1">#        - added documentation</span>
166<span class="c1">#        - applied some minor modifications in programming style/structure</span>
167<span class="c1">#        - changed name of class Control to ControlFile for more</span>
168<span class="c1">#          self-explanation naming</span>
169<span class="c1">#        - outsource of class ControlFile</span>
170<span class="c1">#        - initialisation of class attributes ( to avoid high number of</span>
171<span class="c1">#          conditional statements and set default values )</span>
172<span class="c1">#        - divided assignment of attributes and the check of conditions</span>
173<span class="c1">#        - outsourced the commandline argument assignments to control attributes</span>
174<span class="c1">#</span>
175<span class="c1"># @License:</span>
176<span class="c1">#    (C) Copyright 2014-2019.</span>
177<span class="c1">#    Anne Philipp, Leopold Haimberger</span>
178<span class="c1">#</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>
183<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>
193<span class="c1">#*******************************************************************************</span>
194
195<span class="c1"># ------------------------------------------------------------------------------</span>
196<span class="c1"># MODULES</span>
197<span class="c1"># ------------------------------------------------------------------------------</span>
198<span class="kn">import</span> <span class="nn">os</span>
199<span class="kn">import</span> <span class="nn">re</span>
200<span class="kn">import</span> <span class="nn">sys</span>
201<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>
203
204<span class="c1"># software specific classes and modules from flex_extract</span>
205<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>
206<span class="kn">import</span> <span class="nn">_config</span>
207<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>
215
216<span class="c1"># ------------------------------------------------------------------------------</span>
217<span class="c1"># CLASS</span>
218<span class="c1"># ------------------------------------------------------------------------------</span>
219<div class="viewcode-block" id="ControlFile"><a class="viewcode-back" href="../api.html#ControlFile.ControlFile">[docs]</a><span class="k">class</span> <span class="nc">ControlFile</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
220    <span class="sd">&#39;&#39;&#39;</span>
221<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>
485<span class="sd">    &#39;&#39;&#39;</span>
486
487    <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">filename</span><span class="p">):</span>
488        <span class="sd">&#39;&#39;&#39;Initialises the instance of ControlFile class and defines</span>
489<span class="sd">        all class attributes with default values. Afterwards calls</span>
490<span class="sd">        function __read_controlfile__ to read parameter from Control file.</span>
491
492<span class="sd">        Parameters</span>
493<span class="sd">        ----------</span>
494<span class="sd">        filename : str</span>
495<span class="sd">            Name of CONTROL file.</span>
496
497<span class="sd">        Return</span>
498<span class="sd">        ------</span>
499
500<span class="sd">        &#39;&#39;&#39;</span>
501
502        <span class="c1"># list of all possible class attributes and their default values</span>
503        <span class="bp">self</span><span class="o">.</span><span class="n">controlfile</span> <span class="o">=</span> <span class="n">filename</span>
504        <span class="bp">self</span><span class="o">.</span><span class="n">start_date</span> <span class="o">=</span> <span class="kc">None</span>
505        <span class="bp">self</span><span class="o">.</span><span class="n">end_date</span> <span class="o">=</span> <span class="kc">None</span>
506        <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>
508        <span class="bp">self</span><span class="o">.</span><span class="n">dtime</span> <span class="o">=</span> <span class="kc">None</span>
509        <span class="bp">self</span><span class="o">.</span><span class="n">basetime</span> <span class="o">=</span> <span class="kc">None</span>
510        <span class="bp">self</span><span class="o">.</span><span class="n">maxstep</span> <span class="o">=</span> <span class="kc">None</span>
511        <span class="bp">self</span><span class="o">.</span><span class="n">type</span> <span class="o">=</span> <span class="kc">None</span>
512        <span class="bp">self</span><span class="o">.</span><span class="n">time</span> <span class="o">=</span> <span class="kc">None</span>
513        <span class="bp">self</span><span class="o">.</span><span class="n">step</span> <span class="o">=</span> <span class="kc">None</span>
514        <span class="bp">self</span><span class="o">.</span><span class="n">acctype</span> <span class="o">=</span> <span class="kc">None</span>
515        <span class="bp">self</span><span class="o">.</span><span class="n">acctime</span> <span class="o">=</span> <span class="kc">None</span>
516        <span class="bp">self</span><span class="o">.</span><span class="n">accmaxstep</span> <span class="o">=</span> <span class="kc">None</span>
517        <span class="bp">self</span><span class="o">.</span><span class="n">marsclass</span> <span class="o">=</span> <span class="kc">None</span>
518        <span class="bp">self</span><span class="o">.</span><span class="n">dataset</span> <span class="o">=</span> <span class="kc">None</span>
519        <span class="bp">self</span><span class="o">.</span><span class="n">stream</span> <span class="o">=</span> <span class="kc">None</span>
520        <span class="bp">self</span><span class="o">.</span><span class="n">number</span> <span class="o">=</span> <span class="s1">&#39;OFF&#39;</span>
521        <span class="bp">self</span><span class="o">.</span><span class="n">expver</span> <span class="o">=</span> <span class="s1">&#39;1&#39;</span>
522        <span class="bp">self</span><span class="o">.</span><span class="n">gaussian</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
523        <span class="bp">self</span><span class="o">.</span><span class="n">grid</span> <span class="o">=</span> <span class="kc">None</span>
524        <span class="bp">self</span><span class="o">.</span><span class="n">area</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
525        <span class="bp">self</span><span class="o">.</span><span class="n">left</span> <span class="o">=</span> <span class="kc">None</span>
526        <span class="bp">self</span><span class="o">.</span><span class="n">lower</span> <span class="o">=</span> <span class="kc">None</span>
527        <span class="bp">self</span><span class="o">.</span><span class="n">upper</span> <span class="o">=</span> <span class="kc">None</span>
528        <span class="bp">self</span><span class="o">.</span><span class="n">right</span> <span class="o">=</span> <span class="kc">None</span>
529        <span class="bp">self</span><span class="o">.</span><span class="n">level</span> <span class="o">=</span> <span class="kc">None</span>
530        <span class="bp">self</span><span class="o">.</span><span class="n">levelist</span> <span class="o">=</span> <span class="kc">None</span>
531        <span class="bp">self</span><span class="o">.</span><span class="n">resol</span> <span class="o">=</span> <span class="kc">None</span>
532        <span class="bp">self</span><span class="o">.</span><span class="n">gauss</span> <span class="o">=</span> <span class="mi">0</span>
533        <span class="bp">self</span><span class="o">.</span><span class="n">accuracy</span> <span class="o">=</span> <span class="mi">24</span>
534        <span class="bp">self</span><span class="o">.</span><span class="n">omega</span> <span class="o">=</span> <span class="mi">0</span>
535        <span class="bp">self</span><span class="o">.</span><span class="n">omegadiff</span> <span class="o">=</span> <span class="mi">0</span>
536        <span class="bp">self</span><span class="o">.</span><span class="n">eta</span> <span class="o">=</span> <span class="mi">0</span>
537        <span class="bp">self</span><span class="o">.</span><span class="n">etadiff</span> <span class="o">=</span> <span class="mi">0</span>
538        <span class="bp">self</span><span class="o">.</span><span class="n">etapar</span> <span class="o">=</span> <span class="mi">77</span>
539        <span class="bp">self</span><span class="o">.</span><span class="n">dpdeta</span> <span class="o">=</span> <span class="mi">1</span>
540        <span class="bp">self</span><span class="o">.</span><span class="n">smooth</span> <span class="o">=</span> <span class="mi">0</span>
541        <span class="bp">self</span><span class="o">.</span><span class="n">format</span> <span class="o">=</span> <span class="s1">&#39;GRIB1&#39;</span>
542        <span class="bp">self</span><span class="o">.</span><span class="n">addpar</span> <span class="o">=</span> <span class="kc">None</span>
543        <span class="bp">self</span><span class="o">.</span><span class="n">prefix</span> <span class="o">=</span> <span class="s1">&#39;EN&#39;</span>
544        <span class="bp">self</span><span class="o">.</span><span class="n">cwc</span> <span class="o">=</span> <span class="mi">0</span>
545        <span class="bp">self</span><span class="o">.</span><span class="n">wrf</span> <span class="o">=</span> <span class="mi">0</span>
546        <span class="bp">self</span><span class="o">.</span><span class="n">ecfsdir</span> <span class="o">=</span> <span class="s1">&#39;ectmp:/$</span><span class="si">{USER}</span><span class="s1">/econdemand/&#39;</span>
547        <span class="bp">self</span><span class="o">.</span><span class="n">mailfail</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;$</span><span class="si">{USER}</span><span class="s1">&#39;</span><span class="p">]</span>
548        <span class="bp">self</span><span class="o">.</span><span class="n">mailops</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;$</span><span class="si">{USER}</span><span class="s1">&#39;</span><span class="p">]</span>
549        <span class="bp">self</span><span class="o">.</span><span class="n">grib2flexpart</span> <span class="o">=</span> <span class="mi">0</span>
550        <span class="bp">self</span><span class="o">.</span><span class="n">ecstorage</span> <span class="o">=</span> <span class="mi">0</span>
551        <span class="bp">self</span><span class="o">.</span><span class="n">ectrans</span> <span class="o">=</span> <span class="mi">0</span>
552        <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>
553        <span class="bp">self</span><span class="o">.</span><span class="n">outputdir</span> <span class="o">=</span> <span class="kc">None</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>
555        <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>
556        <span class="bp">self</span><span class="o">.</span><span class="n">flexpartdir</span> <span class="o">=</span> <span class="kc">None</span>
557        <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>
558        <span class="bp">self</span><span class="o">.</span><span class="n">destination</span> <span class="o">=</span> <span class="kc">None</span>
559        <span class="bp">self</span><span class="o">.</span><span class="n">gateway</span> <span class="o">=</span> <span class="kc">None</span>
560        <span class="bp">self</span><span class="o">.</span><span class="n">ecuid</span> <span class="o">=</span> <span class="kc">None</span>
561        <span class="bp">self</span><span class="o">.</span><span class="n">ecgid</span> <span class="o">=</span> <span class="kc">None</span>
562        <span class="bp">self</span><span class="o">.</span><span class="n">install_target</span> <span class="o">=</span> <span class="kc">None</span>
563        <span class="bp">self</span><span class="o">.</span><span class="n">debug</span> <span class="o">=</span> <span class="mi">0</span>
564        <span class="bp">self</span><span class="o">.</span><span class="n">request</span> <span class="o">=</span> <span class="mi">0</span>
565        <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>
569
570        <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>
571                         <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>
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>
576
577        <span class="k">return</span>
578
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>
580        <span class="sd">&#39;&#39;&#39;Read CONTROL file and assign all CONTROL file variables.</span>
581
582<span class="sd">        Parameters</span>
583<span class="sd">        ----------</span>
584
585<span class="sd">        Return</span>
586<span class="sd">        ------</span>
587
588<span class="sd">        &#39;&#39;&#39;</span>
589
590        <span class="k">try</span><span class="p">:</span>
591            <span class="n">cfile</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">_config</span><span class="o">.</span><span class="n">PATH_CONTROLFILES</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">controlfile</span><span class="p">)</span>
592            <span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">cfile</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
593                <span class="n">fdata</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>
594        <span class="k">except</span> <span class="ne">IOError</span><span class="p">:</span>
595            <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;Could not read CONTROL file &quot;&#39;</span> <span class="o">+</span> <span class="n">cfile</span> <span class="o">+</span> <span class="s1">&#39;&quot;&#39;</span><span class="p">)</span>
596            <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;Either it does not exist or its syntax is wrong.&#39;</span><span class="p">)</span>
597            <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> \
598                      <span class="s1">&#39; -h&quot; to print usage information&#39;</span><span class="p">)</span>
599            <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>
600
601        <span class="c1"># go through every line and store parameter</span>
602        <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>
609            <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>
610            <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>
611                <span class="k">if</span> <span class="s1">&#39;m_&#39;</span> <span class="ow">in</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>
612                    <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">data</span><span class="p">[</span><span class="mi">0</span><span class="p">][</span><span class="mi">2</span><span class="p">:]</span>
613                <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;class&#39;</span><span class="p">:</span>
614                    <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;marsclass&#39;</span>
615                <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;day1&#39;</span><span class="p">:</span>
616                    <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;start_date&#39;</span>
617                <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>
618                    <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>
619                <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>
620                    <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>
621                        <span class="nb">setattr</span><span class="p">(</span><span class="bp">self</span><span class="p">,</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="n">data</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span>
622                        <span class="k">while</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>
623                            <span class="n">i</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">index</span><span class="p">(</span><span class="s1">&#39;$&#39;</span><span class="p">)</span>
624                            <span class="n">j</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">find</span><span class="p">(</span><span class="s1">&#39;{&#39;</span><span class="p">)</span>
625                            <span class="n">k</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">find</span><span class="p">(</span><span class="s1">&#39;}&#39;</span><span class="p">)</span>
626                            <span class="n">var</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">getenv</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="mi">1</span><span class="p">][</span><span class="n">j</span><span class="o">+</span><span class="mi">1</span><span class="p">:</span><span class="n">k</span><span class="p">])</span>
627                            <span class="k">if</span> <span class="n">var</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
628                                <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="n">i</span><span class="p">]</span> <span class="o">+</span> <span class="n">var</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="n">k</span><span class="o">+</span><span class="mi">1</span><span class="p">:]</span>
629                            <span class="k">else</span><span class="p">:</span>
630                                <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>
631                                         <span class="s1">&#39;Could not find variable &#39;</span>
632                                         <span class="o">+</span> <span class="n">data</span><span class="p">[</span><span class="mi">1</span><span class="p">][</span><span class="n">j</span><span class="o">+</span><span class="mi">1</span><span class="p">:</span><span class="n">k</span><span class="p">]</span> <span class="o">+</span> <span class="s1">&#39; while reading &#39;</span> <span class="o">+</span>
633                                         <span class="bp">self</span><span class="o">.</span><span class="n">controlfile</span><span class="p">)</span>
634                        <span class="nb">setattr</span><span class="p">(</span><span class="bp">self</span><span class="p">,</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;_expanded&#39;</span><span class="p">,</span> <span class="n">data</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span>
635                    <span class="k">else</span><span class="p">:</span>
636                        <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="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="o">!=</span> <span class="s1">&#39;none&#39;</span><span class="p">:</span>
637                            <span class="nb">setattr</span><span class="p">(</span><span class="bp">self</span><span class="p">,</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="n">data</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span>
638                        <span class="k">else</span><span class="p">:</span>
639                            <span class="nb">setattr</span><span class="p">(</span><span class="bp">self</span><span class="p">,</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="kc">None</span><span class="p">)</span>
640                <span class="k">elif</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">2</span><span class="p">:</span>
641                    <span class="nb">setattr</span><span class="p">(</span><span class="bp">self</span><span class="p">,</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="p">(</span><span class="n">data</span><span class="p">[</span><span class="mi">1</span><span class="p">:]))</span>
642            <span class="k">else</span><span class="p">:</span>
643                <span class="k">pass</span>
644
645        <span class="k">return</span>
646
647    <span class="k">def</span> <span class="nf">__str__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
648        <span class="sd">&#39;&#39;&#39;Prepares a string which have all the ControlFile class attributes</span>
649<span class="sd">        with its associated values. Each attribute is printed in one line and</span>
650<span class="sd">        in alphabetical order.</span>
651
652<span class="sd">        Example</span>
653<span class="sd">        -------</span>
654<span class="sd">        &#39;age&#39;: 10</span>
655<span class="sd">        &#39;color&#39;: &#39;Spotted&#39;</span>
656<span class="sd">        &#39;kids&#39;: 0</span>
657<span class="sd">        &#39;legs&#39;: 2</span>
658<span class="sd">        &#39;name&#39;: &#39;Dog&#39;</span>
659<span class="sd">        &#39;smell&#39;: &#39;Alot&#39;</span>
660
661<span class="sd">        Parameters</span>
662<span class="sd">        ----------</span>
663
664<span class="sd">        Return</span>
665<span class="sd">        ------</span>
666<span class="sd">        string</span>
667<span class="sd">            Single string of concatenated ControlFile class attributes</span>
668<span class="sd">            with their values</span>
669<span class="sd">        &#39;&#39;&#39;</span>
670        <span class="kn">import</span> <span class="nn">collections</span>
671
672        <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>
673        <span class="n">attrs</span> <span class="o">=</span> <span class="n">collections</span><span class="o">.</span><span class="n">OrderedDict</span><span class="p">(</span><span class="nb">sorted</span><span class="p">(</span><span class="n">attrs</span><span class="o">.</span><span class="n">items</span><span class="p">()))</span>
674
675        <span class="k">return</span> <span class="s1">&#39;</span><span class="se">\n</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">join</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="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>
676
677<div class="viewcode-block" id="ControlFile.assign_args_to_control"><a class="viewcode-back" href="../api.html#ControlFile.ControlFile.assign_args_to_control">[docs]</a>    <span class="k">def</span> <span class="nf">assign_args_to_control</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">args</span><span class="p">):</span>
678        <span class="sd">&#39;&#39;&#39;Overwrites the existing ControlFile instance attributes with</span>
679<span class="sd">        the command line arguments.</span>
680
681<span class="sd">        Parameters</span>
682<span class="sd">        ----------</span>
683<span class="sd">        args : Namespace</span>
684<span class="sd">            Contains the commandline arguments from script/program call.</span>
685
686<span class="sd">        Return</span>
687<span class="sd">        ------</span>
688
689<span class="sd">        &#39;&#39;&#39;</span>
690
691        <span class="c1"># get dictionary of command line parameters and eliminate all</span>
692        <span class="c1"># parameters which are None (were not specified)</span>
693        <span class="n">args_dict</span> <span class="o">=</span> <span class="nb">vars</span><span class="p">(</span><span class="n">args</span><span class="p">)</span>
694        <span class="n">arguments</span> <span class="o">=</span> <span class="p">{</span><span class="n">k</span> <span class="p">:</span> <span class="n">args_dict</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">args_dict</span>
695                     <span class="k">if</span> <span class="n">args_dict</span><span class="p">[</span><span class="n">k</span><span class="p">]</span> <span class="o">!=</span> <span class="kc">None</span><span class="p">}</span>
696
697        <span class="c1"># assign all passed command line arguments to ControlFile instance</span>
698        <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">arguments</span><span class="o">.</span><span class="n">iteritems</span><span class="p">():</span>
699            <span class="nb">setattr</span><span class="p">(</span><span class="bp">self</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="n">v</span><span class="p">)</span>
700
701        <span class="k">return</span></div>
702
703<div class="viewcode-block" id="ControlFile.assign_envs_to_control"><a class="viewcode-back" href="../api.html#ControlFile.ControlFile.assign_envs_to_control">[docs]</a>    <span class="k">def</span> <span class="nf">assign_envs_to_control</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">envs</span><span class="p">):</span>
704        <span class="sd">&#39;&#39;&#39;Assigns the ECMWF environment parameter.</span>
705
706<span class="sd">        Parameters</span>
707<span class="sd">        ----------</span>
708<span class="sd">        envs : dict of str</span>
709<span class="sd">            Contains the ECMWF environment parameternames &quot;ECUID&quot;, &quot;ECGID&quot;,</span>
710<span class="sd">            &quot;DESTINATION&quot; and &quot;GATEWAY&quot; with its corresponding values.</span>
711<span class="sd">            They were read from the file &quot;ECMWF_ENV&quot;.</span>
712
713<span class="sd">        Return</span>
714<span class="sd">        ------</span>
715
716<span class="sd">        &#39;&#39;&#39;</span>
717
718        <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">envs</span><span class="o">.</span><span class="n">iteritems</span><span class="p">():</span>
719            <span class="nb">setattr</span><span class="p">(</span><span class="bp">self</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="o">.</span><span class="n">lower</span><span class="p">(),</span> <span class="nb">str</span><span class="p">(</span><span class="n">v</span><span class="p">))</span>
720
721        <span class="k">return</span></div>
722
723<div class="viewcode-block" id="ControlFile.check_conditions"><a class="viewcode-back" href="../api.html#ControlFile.ControlFile.check_conditions">[docs]</a>    <span class="k">def</span> <span class="nf">check_conditions</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">queue</span><span class="p">):</span>
724        <span class="sd">&#39;&#39;&#39;Checks a couple of necessary attributes and conditions,</span>
725<span class="sd">        such as if they exist and contain values.</span>
726<span class="sd">        Otherwise set default values.</span>
727
728<span class="sd">        Parameters</span>
729<span class="sd">        ----------</span>
730<span class="sd">        queue : str</span>
731<span class="sd">            Name of the queue if submitted to the ECMWF servers.</span>
732<span class="sd">            Used to check if ecuid, ecgid, gateway and destination</span>
733<span class="sd">            are set correctly and are not empty.</span>
734
735<span class="sd">        Return</span>
736<span class="sd">        ------</span>
737
738<span class="sd">        &#39;&#39;&#39;</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>
794
795        <span class="k">return</span></div>
796
797<div class="viewcode-block" id="ControlFile.to_list"><a class="viewcode-back" href="../api.html#ControlFile.ControlFile.to_list">[docs]</a>    <span class="k">def</span> <span class="nf">to_list</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
798        <span class="sd">&#39;&#39;&#39;Just generates a list of strings containing the attributes and</span>
799<span class="sd">        assigned values except the attributes &quot;_expanded&quot;, &quot;exedir&quot;,</span>
800<span class="sd">        &quot;flexextractdir&quot; and &quot;flexpartdir&quot;.</span>
801
802<span class="sd">        Parameters</span>
803<span class="sd">        ----------</span>
804
805<span class="sd">        Return</span>
806<span class="sd">        ------</span>
807<span class="sd">        l : list of *</span>
808<span class="sd">            A sorted list of the all ControlFile class attributes with</span>
809<span class="sd">            their values except the attributes &quot;_expanded&quot;, &quot;exedir&quot;,</span>
810<span class="sd">            &quot;flexextractdir&quot; and &quot;flexpartdir&quot;.</span>
811<span class="sd">        &#39;&#39;&#39;</span>
812
813        <span class="kn">import</span> <span class="nn">collections</span>
814
815        <span class="n">attrs</span> <span class="o">=</span> <span class="n">collections</span><span class="o">.</span><span class="n">OrderedDict</span><span class="p">(</span><span class="nb">sorted</span><span class="p">(</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><span class="o">.</span><span class="n">items</span><span class="p">()))</span>
816
817        <span class="n">l</span> <span class="o">=</span> <span class="nb">list</span><span class="p">()</span>
818
819        <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>
820            <span class="k">if</span> <span class="s1">&#39;_expanded&#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>
821                <span class="k">pass</span>
822            <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>
823                <span class="k">pass</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>
825                <span class="k">pass</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>
827                <span class="k">pass</span>
828            <span class="k">else</span><span class="p">:</span>
829                <span class="k">if</span> <span class="nb">isinstance</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="nb">list</span><span class="p">):</span>
830                    <span class="n">stot</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
831                    <span class="k">for</span> <span class="n">s</span> <span class="ow">in</span> <span class="n">item</span><span class="p">[</span><span class="mi">1</span><span class="p">]:</span>
832                        <span class="n">stot</span> <span class="o">+=</span> <span class="n">s</span> <span class="o">+</span> <span class="s1">&#39; &#39;</span>
833
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>
835                <span class="k">else</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>
837
838        <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>
839
840</pre></div>
841
842           </div>
843           
844          </div>
845          <footer>
846 
847
848  <hr/>
849
850  <div role="contentinfo">
851    <p>
852        &copy; Copyright 2018, Anne Philipp and Leopold Haimberger
853
854    </p>
855  </div>
856  Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
857
858</footer>
859
860        </div>
861      </div>
862
863    </section>
864
865  </div>
866 
867
868
869 
870
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   
878
879 
880
881  <script type="text/javascript" src="../_static/js/theme.js"></script>
882
883  <script type="text/javascript">
884      jQuery(function () {
885          SphinxRtdTheme.Navigation.enable(true);
886      });
887  </script> 
888
889</body>
890</html>
Note: See TracBrowser for help on using the repository browser.
hosted by ZAMG