source: flex_extract.git/for_developers/SphinxDoc/_build/doctrees/environment.pickle @ 25b14be

ctbtodev
Last change on this file since 25b14be was 25b14be, checked in by Anne Philipp <anne.philipp@…>, 6 years ago

changed whole tree structure of flex_extract to have better overview

  • Property mode set to 100644
File size: 33.5 KB
Line 
1€csphinx.environment
2BuildEnvironment
3q)q}q(Udlfilesqcsphinx.util
4FilenameUniqDict
5q)qc__builtin__
6set
7q]…RqbU
8reread_alwaysq  h]…Rq
9Utitlesq}q(Xindexq
10cdocutils.nodes
11title
12q)q}q(U     rawsourceqUU
13attributesq}q(Udupnamesq]Uclassesq]Unamesq]Uidsq]Ubackrefsq]uUchildrenq]qcdocutils.nodes
14Text
15qX/Welcome to flex_extract_test’s documentation!q…q}q(hX-Welcome to flex_extract_test's documentation!qUparentq hubaUtagnameq!UtitleubXcodeq"h)q#}q$(hUh}q%(Udupnamesq&]Uclassesq']Ubackrefsq(]Uidsq)]Unamesq*]uh]q+hXAuto Generated Documentationq,…q-}q.(hXAuto Generated Documentationq/h h#ubah!Utitleq0ubuU
16domaindataq1}q2(Ustd}q3(U
17anonlabels}q4(Umodindexq5Upy-modindexU†Ugenindexq6h6U†Usearchq7h7U†uUobjectsq8}U        citations}Ulabels}q9(h5Upy-modindexUcsphinx.locale
18_TranslationProxy
19q:csphinx.locale
20mygettext
21q;UModule Indexq<†q=h;h<…q>†b‡h6h6Uh:h;UIndexq?†q@h;hqA†b‡h7h7Uh:h;USearch PageqB†qCh;hB…qD†b‡uUversionqEKU
22citation_refs}Uprogoptions}uUc}qF(h8}hEKuUpy}qG(h8}qH(XTools.Control.ControlqIh"XclassqJ†X Tools.interpret_args_and_controlqKh"XfunctionqL†XTools.getListAsStringqMh"XfunctionqN†XTools.normalexitqOh"XfunctionqP†XTools.Control.osqQh"X attributeqR†X
23Tools.ControlqSh"XclassqT†X
24Tools.cleanupqUh"XfunctionqV†XTools.Control.Control.tolistqWh"XmethodqX†XTools.silentremoveqYh"XfunctionqZ†X
25Tools.myerrorq[h"Xfunctionq\†X
26Tools.productq]h"Xfunctionq^†XTools.Control.Toolsq_h"X       attributeqX
27Tools.init128qah"Xfunctionqb†XToolsqch"Umoduleqd†XTools.toparamIdqeh"Xfunctionqf†XTools.Control.inspectqgh"X    attributeqh†uUmodulesqi}qjhc(h"UU‰tshEKuUjs}qk(h8}hi}hEKuUrst}ql(h8}hEKuUcpp}qm(Uroot_symbolcsphinx.domains.cpp
28Symbol
29qn)qo}qp(UtemplateParamsqqNh NUtemplateArgsqrNUdeclarationqsNUdocnameqtNU
30identifierquNh]ubhEKh}uuU
31glob_toctreesqvh]…RqwUimagesqxh)qyh]…RqzbU
32doctreedirq{XV/nas16/tmc/Anne/Interpolation/flexextract/flexextract/python/SphinxDoc/_build/doctreesq|Uversioning_conditionq}‰Utoc_fignumbersq~}U  temp_dataq}Uoriginal_image_uriq€}UversionqK4Usrcdirq‚XF/nas16/tmc/Anne/Interpolation/flexextract/flexextract/python/SphinxDocqƒUconfigq„csphinx.config
33Config
34q…)q†}q‡(Uexclude_patternsqˆ]q‰(U_buildqŠU   Thumbs.dbq‹U    .DS_StoreqŒeUpygments_styleqUsphinxqŽUhtmlhelp_basenameqUflex_extract_testdocU
35html_themeqUclassicq‘U
36master_docq’Uindexq“U
37source_suffixq”]q•U.rstq–aUtexinfo_documentsq—]q˜(h“Uflex_extract_testq™Xflex_extract_test DocumentationqšXAPq›h™U One line description of project.U
38MiscellaneousqœtqaU    copyrightqžX2018, APU
39html_sidebarsqŸ}q U**]q¡(Urelations.htmlq¢Usearchbox.htmlq£eshX7.1q¤U   man_pagesq¥]q¦(h“h™hš]q§h›aKtq¨aUtemplates_pathq©]qªU
40_templatesq«aUlatex_documentsq¬]q­(h“Uflex_extract_test.texX!flex\_extract\_test Documentationh›Umanualq®tq¯aUhtml_static_pathq°]q±U_staticq²aUlatex_elementsq³}Ulanguageq´NU overridesqµ}UprojectqXflex_extract_testU
41extensionsq·]q¸(Usphinx.ext.autodocq¹Usphinx.ext.coverageqºUsphinx.ext.viewcodeq»eUreleaseq¼h¤Usetupq½NubUmetadataq¾ccollections
42defaultdict
43q¿c__builtin__
44dict
45qÀ…RqÁ(h
46}qÂh"}qÃuUversionchangesqÄ}U_viewcode_modulesqÅ}qÆ(UControlqÇ(X£$#!/usr/bin/env python
47# -*- coding: utf-8 -*-
48#************************************************************************
49# TODO AP
50# - write a test class
51# - check documentation
52#************************************************************************
53"""
54@Author: Leopold Haimberger (University of Vienna)
55
56@Date: November 2015
57
58@ChangeHistory:
59   February 2018 - Anne Philipp (University of Vienna):
60        - applied PEP8 style guide
61        - added documentation
62        - applied some minor modifications in programming style/structure
63        - moved Control class in a file for its own
64
65@License:
66    (C) Copyright 2015-2018.
67
68    This software is licensed under the terms of the Apache Licence Version 2.0
69    which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
70
71@Requirements:
72    A standard python 2.6 or 2.7 installation
73
74@Description:
75    The Control files are the steering part of the FLEXPART extraction
76    software. All necessary parameters needed to retrieve the data fields
77    from the MARS archive for driving FLEXPART are set in a Control file.
78    Some specific parameters like the start and end dates can be overwritten
79    by the command line parameters, but in generel all parameters needed
80    for a complete set of fields for FLEXPART can be set in the Control files.
81
82"""
83# ------------------------------------------------------------------------------
84# MODULES
85# ------------------------------------------------------------------------------
86import os
87import inspect
88import Tools
89# ------------------------------------------------------------------------------
90# CLASS
91# ------------------------------------------------------------------------------
92class Control:
93    '''
94    Class containing the information of the ECMWFDATA control file.
95
96    Contains all the parameters of control files, which are e.g.:
97    DAY1(start_date), DAY2(end_date), DTIME, MAXSTEP, TYPE, TIME,
98    STEP, CLASS(marsclass), STREAM, NUMBER, EXPVER, GRID, LEFT,
99    LOWER, UPPER, RIGHT, LEVEL, LEVELIST, RESOL, GAUSS, ACCURACY,
100    OMEGA, OMEGADIFF, ETA, ETADIFF, DPDETA, SMOOTH, FORMAT,
101    ADDPAR, WRF, CWC, PREFIX, ECSTORAGE, ECTRANS, ECFSDIR,
102    MAILOPS, MAILFAIL, GRIB2FLEXPART, FLEXPARTDIR,
103    BASETIME, DATE_CHUNK, DEBUG, INPUTDIR, OUTPUTDIR, FLEXPART_ROOT_SCRIPTS
104
105    For more information about format and content of the parameter
106    see documentation.
107
108    '''
109
110    def __init__(self, filename):
111        '''
112        @Description:
113            Initialises the instance of Control class and defines and
114            assign all controlfile variables. Set default values if
115            parameter was not in CONTROL file.
116
117        @Input:
118            self: instance of Control class
119                Description see class documentation.
120
121            filename: string
122                Name of control file.
123
124        @Return:
125            <nothing>
126        '''
127
128        # read whole CONTROL file
129        with open(filename) as f:
130            fdata = f.read().split('\n')
131
132        # go through every line and store parameter
133        # as class variable
134        for ldata in fdata:
135            data = ldata.split()
136            if len(data) > 1:
137                if 'm_' in data[0].lower():
138                    data[0] = data[0][2:]
139                if data[0].lower() == 'class':
140                    data[0] = 'marsclass'
141                if data[0].lower() == 'day1':
142                    data[0] = 'start_date'
143                if data[0].lower() == 'day2':
144                    data[0] = 'end_date'
145                if data[0].lower() == 'addpar':
146                    if '/' in data[1]:
147                        # remove leading '/' sign from addpar content
148                        if data[1][0] == '/':
149                            data[1] = data[1][1:]
150                        dd = data[1].split('/')
151                        data = [data[0]]
152                        for d in dd:
153                            data.append(d)
154                    pass
155                if len(data) == 2:
156                    if '$' in data[1]:
157                        setattr(self, data[0].lower(), data[1])
158                        while '$' in data[1]:
159                            i = data[1].index('$')
160                            j = data[1].find('{')
161                            k = data[1].find('}')
162                            var = os.getenv(data[1][j+1:k])
163                            if var is not None:
164                                data[1] = data[1][:i] + var + data[1][k+1:]
165                            else:
166                                Tools.myerror(None,
167                                              'Could not find variable ' +
168                                              data[1][j+1:k] +
169                                              ' while reading ' +
170                                              filename)
171                        setattr(self, data[0].lower() + '_expanded', data[1])
172                    else:
173                        if data[1].lower() != 'none':
174                            setattr(self, data[0].lower(), data[1])
175                        else:
176                            setattr(self, data[0].lower(), None)
177                elif len(data) > 2:
178                    setattr(self, data[0].lower(), (data[1:]))
179            else:
180                pass
181
182        # check a couple of necessary attributes if they contain values
183        # otherwise set default values
184        if not hasattr(self, 'start_date'):
185            self.start_date = None
186        if not hasattr(self, 'end_date'):
187            self.end_date = self.start_date
188        if not hasattr(self, 'accuracy'):
189            self.accuracy = 24
190        if not hasattr(self, 'omega'):
191            self.omega = '0'
192        if not hasattr(self, 'cwc'):
193            self.cwc = '0'
194        if not hasattr(self, 'omegadiff'):
195            self.omegadiff = '0'
196        if not hasattr(self, 'etadiff'):
197            self.etadiff = '0'
198        if not hasattr(self, 'levelist'):
199            if not hasattr(self, 'level'):
200                print 'Warning: neither levelist nor level \
201                       specified in CONTROL file'
202            else:
203                self.levelist = '1/to/' + self.level
204        else:
205            if 'to' in self.levelist:
206                self.level = self.levelist.split('/')[2]
207            else:
208                self.level = self.levelist.split('/')[-1]
209
210        if not hasattr(self, 'maxstep'):
211            # find out maximum step
212            self.maxstep = 0
213            for s in self.step:
214                if int(s) > self.maxstep:
215                    self.maxstep = int(s)
216        else:
217            self.maxstep = int(self.maxstep)
218
219        if not hasattr(self, 'prefix'):
220            self.prefix = 'EN'
221        if not hasattr(self, 'makefile'):
222            self.makefile = None
223        if not hasattr(self, 'basetime'):
224            self.basetime = None
225        if not hasattr(self, 'date_chunk'):
226            self.date_chunk = '3'
227        if not hasattr(self, 'grib2flexpart'):
228            self.grib2flexpart = '0'
229
230        # script directory
231        self.ecmwfdatadir = os.path.dirname(os.path.abspath(inspect.getfile(
232            inspect.currentframe()))) + '/../'
233        # Fortran source directory
234        self.exedir = self.ecmwfdatadir + 'src/'
235
236        # FLEXPART directory
237        if not hasattr(self, 'flexpart_root_scripts'):
238            self.flexpart_root_scripts = self.ecmwfdatadir
239
240        return
241
242    def __str__(self):
243        '''
244        @Description:
245            Prepares a single string with all the comma seperated Control
246            class attributes including their values.
247
248            Example:
249            {'kids': 0, 'name': 'Dog', 'color': 'Spotted',
250             'age': 10, 'legs': 2, 'smell': 'Alot'}
251
252        @Input:
253            self: instance of Control class
254                Description see class documentation.
255
256        @Return:
257            string of Control class attributes with their values
258        '''
259
260        attrs = vars(self)
261
262        return ', '.join("%s: %s" % item for item in attrs.items())
263
264    def tolist(self):
265        '''
266        @Description:
267            Just generates a list of strings containing the attributes and
268            assigned values except the attributes "_expanded", "exedir",
269            "ecmwfdatadir" and "flexpart_root_scripts".
270
271        @Input:
272            self: instance of Control class
273                Description see class documentation.
274
275        @Return:
276            l: list
277                A sorted list of the all Control class attributes with
278                their values except the attributes "_expanded", "exedir",
279                "ecmwfdatadir" and "flexpart_root_scripts".
280        '''
281        attrs = vars(self)
282        l = list()
283        for item in attrs.items():
284            if '_expanded' in item[0]:
285                pass
286            elif 'exedir' in item[0]:
287                pass
288            elif 'flexpart_root_scripts' in item[0]:
289                pass
290            elif 'ecmwfdatadir' in item[0]:
291                pass
292            else:
293                if type(item[1]) is list:
294                    stot = ''
295                    for s in item[1]:
296                        stot += s + ' '
297
298                    l.append("%s %s" % (item[0], stot))
299                else:
300#AP syntax error with doubled %s ???
301                    l.append("%s %s" % item)
302        return sorted(l)
303qÈ}qÉ(XControlqÊXclassqËK/M‡XControl.__str__XdefqÌKÅKڇXControl.__init__XdefqÍKAKćXControl.tolistXdefqÎKÛM‡u}cdocutils.nodes
304reprunicode
305qÏXToolsqЅqÑ}qÒbtUTools(X×>#!/usr/bin/env python
306# -*- coding: utf-8 -*-
307#************************************************************************
308# TODO AP
309#AP
310# -
311#************************************************************************
312"""
313
314"""
315# ------------------------------------------------------------------------------
316# MODULES
317# ------------------------------------------------------------------------------
318from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter
319import os
320import errno
321import sys
322import glob
323from numpy import *
324from gribapi import *
325import Control
326
327# ------------------------------------------------------------------------------
328# FUNCTIONS
329# ------------------------------------------------------------------------------
330
331def interpret_args_and_control():
332    '''
333    @Description:
334        Assigns the command line arguments and reads control file
335        content. Apply default values for non mentioned arguments.
336
337    @Input:
338        <nothing>
339
340    @Return:
341        args: instance of ArgumentParser
342            Contains the commandline arguments from script/program call.
343
344        c: instance of class Control
345            Contains all necessary information of a control file. The parameters
346            are: DAY1, DAY2, DTIME, MAXSTEP, TYPE, TIME, STEP, CLASS, STREAM,
347            NUMBER, EXPVER, GRID, LEFT, LOWER, UPPER, RIGHT, LEVEL, LEVELIST,
348            RESOL, GAUSS, ACCURACY, OMEGA, OMEGADIFF, ETA, ETADIFF, DPDETA,
349            SMOOTH, FORMAT, ADDPAR, WRF, CWC, PREFIX, ECSTORAGE, ECTRANS,
350            ECFSDIR, MAILOPS, MAILFAIL, GRIB2FLEXPART, DEBUG, INPUTDIR,
351            OUTPUTDIR, FLEXPART_ROOT_SCRIPTS
352            For more information about format and content of the parameter see
353            documentation.
354
355    '''
356    parser = ArgumentParser(description='Retrieve FLEXPART input from \
357                            ECMWF MARS archive',
358                            formatter_class=ArgumentDefaultsHelpFormatter)
359
360    # the most important arguments
361    parser.add_argument("--start_date", dest="start_date",
362                        help="start date YYYYMMDD")
363    parser.add_argument("--end_date", dest="end_date",
364                        help="end_date YYYYMMDD")
365    parser.add_argument("--date_chunk", dest="date_chunk", default=None,
366                        help="# of days to be retrieved at once")
367
368    # some arguments that override the default in the control file
369    parser.add_argument("--basetime", dest="basetime",
370                        help="base such as 00/12 (for half day retrievals)")
371    parser.add_argument("--step", dest="step",
372                        help="steps such as 00/to/48")
373    parser.add_argument("--levelist", dest="levelist",
374                        help="Vertical levels to be retrieved, e.g. 30/to/60")
375    parser.add_argument("--area", dest="area",
376                        help="area defined as north/west/south/east")
377
378    # set the working directories
379    parser.add_argument("--inputdir", dest="inputdir", default=None,
380                        help="root directory for storing intermediate files")
381    parser.add_argument("--outputdir", dest="outputdir", default=None,
382                        help="root directory for storing output files")
383    parser.add_argument("--flexpart_root_scripts", dest="flexpart_root_scripts",
384                        help="FLEXPART root directory (to find grib2flexpart \
385                        and COMMAND file)\n\ Normally ECMWFDATA resides in \
386                        the scripts directory of the FLEXPART distribution")
387
388    # this is only used by prepareFLEXPART.py to rerun a postprocessing step
389    parser.add_argument("--ppid", dest="ppid",
390                        help="Specify parent process id for \
391                        rerun of prepareFLEXPART")
392
393    # arguments for job submission to ECMWF, only needed by submit.py
394    parser.add_argument("--job_template", dest='job_template',
395                        default="job.temp",
396                        help="job template file for submission to ECMWF")
397    parser.add_argument("--queue", dest="queue",
398                        help="queue for submission to ECMWF \
399                        (e.g. ecgate or cca )")
400    parser.add_argument("--controlfile", dest="controlfile",
401                        default='CONTROL.temp',
402                        help="file with control parameters")
403    parser.add_argument("--debug", dest="debug", default=0,
404                        help="Debug mode - leave temporary files intact")
405
406    args = parser.parse_args()
407
408    # create instance of Control for specified controlfile
409    # and assign the parameters (and default values if necessary)
410    try:
411        c = Control.Control(args.controlfile)
412    except IOError:
413        try:
414            c = Control.Control(localpythonpath + args.controlfile)
415        except:
416            print('Could not read control file "' + args.controlfile + '"')
417            print('Either it does not exist or its syntax is wrong.')
418            print('Try "' + sys.argv[0].split('/')[-1] +
419                  ' -h" to print usage information')
420            exit(1)
421
422    # check for having at least a starting date
423    if  args.start_date is None and getattr(c, 'start_date') is None:
424        print('start_date specified neither in command line nor \
425               in control file ' + args.controlfile)
426        print('Try "' + sys.argv[0].split('/')[-1] +
427              ' -h" to print usage information')
428        exit(1)
429
430    # save all existing command line parameter to the Control instance
431    # if parameter is not specified through the command line or CONTROL file
432    # set default values
433    if args.start_date is not None:
434        c.start_date = args.start_date
435    if args.end_date is not None:
436        c.end_date = args.end_date
437    if c.end_date is None:
438        c.end_date = c.start_date
439    if args.date_chunk is not None:
440        c.date_chunk = args.date_chunk
441
442    if not hasattr(c, 'debug'):
443        c.debug = args.debug
444
445    if args.inputdir is None and args.outputdir is None:
446        c.inputdir = '../work'
447        c.outputdir = '../work'
448    else:
449        if args.inputdir is not None:
450            c.inputdir = args.inputdir
451        if args.outputdir is None:
452            c.outputdir = args.inputdir
453        if args.outputdir is not None:
454            c.outputdir = args.outputdir
455        if args.inputdir is None:
456            c.inputdir = args.outputdir
457
458    if hasattr(c, 'outputdir') is False and args.outputdir is None:
459        c.outputdir = c.inputdir
460    else:
461        if args.outputdir is not None:
462            c.outputdir = args.outputdir
463
464    if args.area is not None:
465        afloat = '.' in args.area
466        l = args.area.split('/')
467        if afloat:
468            for i in range(len(l)):
469                l[i] = str(int(float(l[i]) * 1000))
470        c.upper, c.left, c.lower, c.right = l
471
472    # NOTE: basetime activates the ''operational mode''
473    if args.basetime is not None:
474        c.basetime = args.basetime
475
476    if args.step is not None:
477        l = args.step.split('/')
478        if 'to' in args.step.lower():
479            if 'by' in args.step.lower():
480                ilist = arange(int(l[0]), int(l[2]) + 1, int(l[4]))
481                c.step = ['{:0>3}'.format(i) for i in ilist]
482            else:
483                myerror(None, args.step + ':\n' +
484                        'please use "by" as well if "to" is used')
485        else:
486            c.step = l
487
488    if args.levelist is not None:
489        c.levelist = args.levelist
490        if 'to' in c.levelist:
491            c.level = c.levelist.split('/')[2]
492        else:
493            c.level = c.levelist.split('/')[-1]
494
495    if args.flexpart_root_scripts is not None:
496        c.flexpart_root_scripts = args.flexpart_root_scripts
497
498    return args, c
499
500
501def cleanup(c):
502    '''
503    @Description:
504        Remove all files from intermediate directory
505        (inputdir from control file).
506
507    @Input:
508        c: instance of class Control
509            Contains all the parameters of control files, which are e.g.:
510            DAY1(start_date), DAY2(end_date), DTIME, MAXSTEP, TYPE, TIME,
511            STEP, CLASS(marsclass), STREAM, NUMBER, EXPVER, GRID, LEFT,
512            LOWER, UPPER, RIGHT, LEVEL, LEVELIST, RESOL, GAUSS, ACCURACY,
513            OMEGA, OMEGADIFF, ETA, ETADIFF, DPDETA, SMOOTH, FORMAT,
514            ADDPAR, WRF, CWC, PREFIX, ECSTORAGE, ECTRANS, ECFSDIR,
515            MAILOPS, MAILFAIL, GRIB2FLEXPART, FLEXPARTDIR, BASETIME
516            DATE_CHUNK, DEBUG, INPUTDIR, OUTPUTDIR, FLEXPART_ROOT_SCRIPTS
517
518            For more information about format and content of the parameter
519            see documentation.
520
521    @Return:
522        <nothing>
523    '''
524
525    print("cleanup")
526
527    cleanlist = glob.glob(c.inputdir + "/*")
528    for cl in cleanlist:
529        if c.prefix not in cl:
530            silentremove(cl)
531        if c.ecapi is False and (c.ectrans == '1' or c.ecstorage == '1'):
532            silentremove(cl)
533
534    print("Done")
535
536    return
537
538
539def myerror(c, message='ERROR'):
540    '''
541    @Description:
542        Prints a specified error message which can be passed to the function
543        before exiting the program.
544
545    @Input:
546        c: instance of class Control
547            Contains all the parameters of control files, which are e.g.:
548            DAY1(start_date), DAY2(end_date), DTIME, MAXSTEP, TYPE, TIME,
549            STEP, CLASS(marsclass), STREAM, NUMBER, EXPVER, GRID, LEFT,
550            LOWER, UPPER, RIGHT, LEVEL, LEVELIST, RESOL, GAUSS, ACCURACY,
551            OMEGA, OMEGADIFF, ETA, ETADIFF, DPDETA, SMOOTH, FORMAT,
552            ADDPAR, WRF, CWC, PREFIX, ECSTORAGE, ECTRANS, ECFSDIR,
553            MAILOPS, MAILFAIL, GRIB2FLEXPART, FLEXPARTDIR, BASETIME
554            DATE_CHUNK, DEBUG, INPUTDIR, OUTPUTDIR, FLEXPART_ROOT_SCRIPTS
555
556            For more information about format and content of the parameter
557            see documentation.
558
559        message: string, optional
560            Error message. Default value is "ERROR".
561
562    @Return:
563        <nothing>
564    '''
565    # uncomment if user wants email notification directly from python
566    #try:
567        #target = c.mailfail
568    #except AttributeError:
569        #target = os.getenv('USER')
570
571    #if(type(target) is not list):
572        #target = [target]
573
574    print(message)
575
576    # uncomment if user wants email notification directly from python
577    #for t in target:
578    #p = subprocess.Popen(['mail','-s ECMWFDATA v7.0 ERROR', os.path.expandvars(t)],
579    #                     stdin = subprocess.PIPE, stdout = subprocess.PIPE,
580    #                     stderr = subprocess.PIPE, bufsize = 1)
581    #tr = '\n'.join(traceback.format_stack())
582    #pout = p.communicate(input = message+'\n\n'+tr)[0]
583    #print 'Email sent to '+os.path.expandvars(t) # +' '+pout.decode()
584
585    exit(1)
586
587    return
588
589
590def normalexit(c, message='Done!'):
591    '''
592    @Description:
593        Prints a specific exit message which can be passed to the function.
594
595    @Input:
596        c: instance of class Control
597            Contains all the parameters of control files, which are e.g.:
598            DAY1(start_date), DAY2(end_date), DTIME, MAXSTEP, TYPE, TIME,
599            STEP, CLASS(marsclass), STREAM, NUMBER, EXPVER, GRID, LEFT,
600            LOWER, UPPER, RIGHT, LEVEL, LEVELIST, RESOL, GAUSS, ACCURACY,
601            OMEGA, OMEGADIFF, ETA, ETADIFF, DPDETA, SMOOTH, FORMAT,
602            ADDPAR, WRF, CWC, PREFIX, ECSTORAGE, ECTRANS, ECFSDIR,
603            MAILOPS, MAILFAIL, GRIB2FLEXPART, FLEXPARTDIR, BASETIME
604            DATE_CHUNK, DEBUG, INPUTDIR, OUTPUTDIR, FLEXPART_ROOT_SCRIPTS
605
606            For more information about format and content of the parameter
607            see documentation.
608
609        message: string, optional
610            Message for exiting program. Default value is "Done!".
611
612    @Return:
613        <nothing>
614
615    '''
616    # Uncomment if user wants notification directly from python
617    #try:
618        #target = c.mailops
619        #if(type(target) is not list):
620            #target = [target]
621        #for t in target:
622            #p = subprocess.Popen(['mail','-s ECMWFDATA v7.0 normal exit',
623            #                      os.path.expandvars(t)],
624            #                      stdin = subprocess.PIPE,
625            #                      stdout = subprocess.PIPE,
626            #                      stderr = subprocess.PIPE, bufsize = 1)
627            #pout = p.communicate(input = message+'\n\n')[0]
628            #print pout.decode()
629    #except:
630        #pass
631
632    print(message)
633
634    return
635
636
637def product(*args, **kwds):
638    '''
639    @Description:
640        This method is taken from an example at the ECMWF wiki website.
641        https://software.ecmwf.int/wiki/display/GRIB/index.py; 2018-03-16
642
643        This method combines the single characters of the passed arguments
644        with each other. So that each character of each argument value
645        will be combined with each character of the other arguments as a tuple.
646
647        Example:
648        product('ABCD', 'xy') --> Ax Ay Bx By Cx Cy Dx Dy
649        product(range(2), repeat = 3) --> 000 001 010 011 100 101 110 111
650
651    @Input:
652        *args: tuple
653            Positional arguments (arbitrary number).
654
655        **kwds: dictionary
656            Contains all the keyword arguments from *args.
657
658    @Return:
659        prod: tuple
660            Return will be done with "yield". A tuple of combined arguments.
661            See example in description above.
662    '''
663
664    pools = map(tuple, args) * kwds.get('repeat', 1)
665    result = [[]]
666    for pool in pools:
667        result = [x + [y] for x in result for y in pool]
668    for prod in result:
669        yield tuple(prod)
670
671    return
672
673
674def silentremove(filename):
675    '''
676    @Description:
677        Removes the file which name is passed to the function if
678        it exists. The function does not fail if the file does not
679        exist.
680
681    @Input:
682        filename: string
683            The name of the file to be removed without notification.
684
685    @Return:
686        <nothing>
687    '''
688    try:
689        os.remove(filename)
690    except OSError as e:
691        # this would be "except OSError, e:" before Python 2.6
692        if e.errno is not  errno.ENOENT:
693            # errno.ENOENT  =  no such file or directory
694            raise  # re-raise exception if a different error occured
695
696    return
697
698
699def init128(fn):
700    '''
701    @Description:
702        Opens and reads the grib file with table 128 information.
703
704    @Input:
705        fn: string
706            Path to file of ECMWF grib table number 128.
707
708    @Return:
709        table128: dictionary
710            Contains the ECMWF grib table 128 information.
711            The key is the parameter number and the value is the
712            short name of the parameter.
713    '''
714    table128 = dict()
715    with open(fn) as f:
716        fdata = f.read().split('\n')
717    for data in fdata:
718        if data[0] != '!':
719            table128[data[0:3]] = data[59:64].strip()
720
721    return table128
722
723
724def toparamId(pars, table):
725    '''
726    @Description:
727        Transform parameter names to parameter ids
728        with ECMWF grib table 128.
729
730    @Input:
731        pars: string
732            Addpar argument from control file in the format of
733            parameter names instead of ids. The parameter short
734            names are sepearted with "/" and they are passed as
735            one single string.
736
737        table: dictionary
738            Contains the ECMWF grib table 128 information.
739            The key is the parameter number and the value is the
740            short name of the parameter.
741
742    @Return:
743        ipar: list of integer
744            List of addpar parameters from control file transformed to
745            parameter ids in the format of integer.
746    '''
747    cpar = pars.upper().split('/')
748    ipar = []
749    for par in cpar:
750        found = False
751        for k, v in table.iteritems():
752            if par == k or par == v:
753                ipar.append(int(k))
754                found = True
755                break
756        if found is False:
757            print('Warning: par ' + par + ' not found in table 128')
758
759    return ipar
760
761def getListAsString(listobj):
762    '''
763    @Description:
764    '''
765    return ", ".join( str(l) for l in listobj)}qÓ(XproductXdefMMMp‡XmyerrorXdefKëM‡XgetListAsStringXdefMÉM·XsilentremoveXdefMrM‰‡X     toparamIdXdefM¤MȇXcleanupXdefKÅKé‡X
766normalexitXdefMMK‡Xinit128XdefM‹M¢‡Xinterpret_args_and_controlXdefKKÇu}qÔ(Xproducth"Xmyerrorh"XgetListAsStringh"Xsilentremoveh"toparamIdh"Xcleanuph"X
767normalexith"Xinit128h"Xinterpret_args_and_controlh"uhÏXToolsqՅqÖ}q×btuUtoc_num_entriesqØ}qÙ(h
768Kh"KuUnumbered_toctreesqÚh]…RqÛU
769found_docsqÜh]qÝ(XindexqÞh"e…RqßU
770longtitlesqà}qá(h
771hh"h#uUdependenciesqâh¿h…Rqã(hÞh]…Rqäh"h]qå(X</opt/anaconda/lib/python2.7/site-packages/gribapi/gribapi.pyqæXA/opt/anaconda/lib/python2.7/site-packages/numpy/core/_internal.pyqçXA/opt/anaconda/lib/python2.7/site-packages/numpy/lib/polynomial.pyqèX;/opt/anaconda/lib/python2.7/site-packages/numpy/__init__.pyqéX?/opt/anaconda/lib/python2.7/site-packages/numpy/core/records.pyqêX'/opt/anaconda/lib/python2.7/argparse.pyqëXD/opt/anaconda/lib/python2.7/site-packages/numpy/core/defchararray.pyqìXF/opt/anaconda/lib/python2.7/site-packages/numpy/matrixlib/defmatrix.pyqíX?/opt/anaconda/lib/python2.7/site-packages/numpy/core/numeric.pyqîX;/opt/anaconda/lib/python2.7/site-packages/numpy/_globals.pyqïXA/opt/anaconda/lib/python2.7/site-packages/numpy/core/getlimits.pyqðX../Tools.pyqñX
772../Control.pyqòXB/opt/anaconda/lib/python2.7/site-packages/numpy/lib/_datasource.pyqóXD/opt/anaconda/lib/python2.7/site-packages/numpy/lib/function_base.pyqôX;/opt/anaconda/lib/python2.7/site-packages/gribapi/errors.pyqõXC/opt/anaconda/lib/python2.7/site-packages/numpy/lib/index_tricks.pyqöX>/opt/anaconda/lib/python2.7/site-packages/numpy/core/machar.pyq÷X>/opt/anaconda/lib/python2.7/site-packages/numpy/core/memmap.pyqøe…RqùuUtoctree_includesqú}qûh
773]qüXcodeqýasUincludedqþh]…RqÿUtocsr}r(h
774cdocutils.nodes
775bullet_list
776r)r}r(hUh}r(h]h]h]h]h]uh]r(cdocutils.nodes
777list_item
778r)r}(hUh}r
779(h]h]h]h]h]uh jh]r(csphinx.addnodes
780compact_paragraph
781r)r
782}r(hUh}r(h]h]h]h]h]uh jh]rcdocutils.nodes
783reference
784r)r}r(hUh}r(U
785anchornameUh]h]h]Urefurih
786h]h]Uinternalˆuh j
787h]rhX/Welcome to flex_extract_test’s documentation!r…r}r(hhh jubah!U   referencerubah!Ucompact_paragraphrubj)r}r(hUh}r(h]h]h]h]h]uh jh]rcsphinx.addnodes
788toctree
789r)r }r!(hUh jUsourcer"XP/nas16/tmc/Anne/Interpolation/flexextract/flexextract/python/SphinxDoc/index.rsth!Utoctreeh}r#(UnumberedKU
790includehidden‰Uparenth
791h]Uglob‰h]h]U
792titlesonly‰h]UmaxdepthKUentries]r$Nhý†r%aUincludefiles]r&hýaUhidden‰UcaptionhÏX Contents:r'…r(}r)bU
793rawcaptionj(h]uUliner*K h]ubah!Ubullet_listr+ubeh!U        list_itemr,ubj)r-}r.(hUh}r/(h]h]h]h]h]uh jh]r0j)r1}r2(hUh}r3(h]h]h]h]h]uh j-h]r4j)r5}r6(hUh}r7(U
794anchornameU#indices-and-tablesh]h]h]Urefurih
795h]h]Uinternalˆuh j1h]r8hXIndices and tablesr9…r:}r;(hXIndices and tablesh j5ubah!jubah!jubah!j,ubeh!j+ubh"j)r<}r=(hUh}r>(h&]h']h(]h)]h*]uh]r?j)r@}rA(hUh}rB(h&]h']h(]h)]h*]uh j<h]rCj)rD}rE(hUh}rF(h&]h']h(]h)]h*]uh j@h]rGj)rH}rI(hUh}rJ(U
796anchornameUUrefurih"h)]h(]h&]h']h*]Uinternalˆuh jDh]rKhXAuto Generated DocumentationrL…rM}rN(hh/h jHubah!U referencerOubah!Ucompact_paragraphrPubah!U       list_itemrQubah!Ubullet_listrRubuUindexentriesrS}rT(h
797]h"]rU((UsinglerVXTools (module)Xmodule-ToolsUNtrW(jVXcleanup() (in module Tools)hUUNtrX(jVX#getListAsString() (in module Tools)hMUNtrY(jVXinit128() (in module Tools)haUNtrZ(jVX.interpret_args_and_control() (in module Tools)hKUNtr[(jVXmyerror() (in module Tools)h[UNtr\(jVXnormalexit() (in module Tools)hOUNtr](jVXproduct() (in module Tools)h]UNtr^(jVX silentremove() (in module Tools)hYUNtr_(jVXtoparamId() (in module Tools)heUNtr`(jVXControl (class in Tools)hSUNtra(jVX Control.Control (class in Tools)hIUNtrb(jVX'tolist() (Tools.Control.Control method)hWUNtrc(jVXTools (Tools.Control attribute)h_UNtrd(jVX!inspect (Tools.Control attribute)hgUNtre(jVXos (Tools.Control attribute)hQUNtrfeuUall_docsrg}rh(h
798GAÖ»ÐÙÌæÅh"GAֻѱî³uUsettingsri}rj(Urfc_base_urlUhttps://tools.ietf.org/html/rkUcloak_email_addressesˆUpep_base_urlU https://www.python.org/dev/peps/rlU
799halt_levelKUsectsubtitle_xform‰Usmart_quotesˆUembed_stylesheet‰Utrim_footnote_reference_space‰Udoctitle_xform‰UenvhU
800language_codeUenrmUfile_insertion_enabledˆUgettext_compactˆUinput_encodingU      utf-8-sigrnuUref_contextro}Ufiles_to_rebuildrp}rqhýh]rrh
801a…RrssUtoc_secnumbersrt}Uversioning_compareru‰U_nitpick_ignorervh]…RrwU      _warnfuncrxNub.
Note: See TracBrowser for help on using the repository browser.
hosted by ZAMG