Changeset 2d56c04 in flex_extract.git


Ignore:
Timestamp:
Nov 27, 2018, 11:34:34 PM (4 months ago)
Author:
Anne Philipp <anne.philipp@…>
Branches:
dev
Children:
6cda7c1
Parents:
d8785f8
Message:

automatic detection of grid and area component formats (1/1000 or normal degree format)

Location:
source/python
Files:
3 edited

Legend:

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

    rd8785f8 r2d56c04  
    327327        # otherwise program is not allowed to run
    328328        if not self.start_date:
    329             print('start_date specified neither in command line nor \
    330                    in CONTROL file ' +  self.controlfile)
     329            print('start_date specified neither in command line nor '
     330                  'in CONTROL file ' +  self.controlfile)
    331331            print('Try "' + sys.argv[0].split('/')[-1] +
    332332                  ' -h" to print usage information')
     
    365365            print('Check parameter "LEVEL" or the max level of "LEVELIST"!')
    366366            sys.exit(1)
    367 
    368         # if area was provided (only from commandline)
    369         # decompose area into its 4 components
    370         if self.area:
    371             components = self.area.split('/')
    372             # convert float to integer coordinates
    373             if '.' in self.area:
    374                 components = [str(int(float(item) * 1000))
    375                               for i, item in enumerate(components)]
    376             self.upper, self.left, self.lower, self.right = components
    377367
    378368        # prepare step list if "/" signs are found
     
    386376            elif 'to' in self.step.lower() and 'by' not in self.step.lower():
    387377                my_error(self.mailfail, self.step + ':\n' +
    388                          'if "to" is used in steps parameter, \
    389                          please use "by" as well')
     378                         'if "to" is used in steps parameter, '
     379                         'please use "by" as well')
    390380            else:
    391381                self.step = steps
     
    427417           not self.gateway or not self.destination or \
    428418           not self.ecuid or not self.ecgid:
    429             print('\nEnvironment variables GATEWAY, DESTINATION, ECUID and \
    430                    ECGID were not set properly!')
    431             print('Please check for existence of file "ECMWF_ENV" in the \
    432                    python directory!')
     419            print('\nEnvironment variables GATEWAY, DESTINATION, ECUID and '
     420                  'ECGID were not set properly!')
     421            print('Please check for existence of file "ECMWF_ENV" in the '
     422                  'python directory!')
    433423            sys.exit(1)
    434424
     
    484474            print('Use default value "12" for flux forecast!')
    485475            self.accmaxstep='12'
     476
     477        # if area was provided (only from commandline)
     478        # decompose area into its 4 components
     479        if self.area:
     480            components = self.area.split('/')
     481            self.upper, self.left, self.lower, self.right = components
     482
     483        # convert grid and area components to correct format and input
     484        if 'N' in self.grid:  # Gaussian output grid
     485            self.area = 'G'
     486        else:
     487            # check on grid format
     488            if float(self.grid) / 100. >= 0.5:
     489                # grid is defined in 1/1000 degrees; old method
     490                self.grid = '{}/{}'.format(float(self.grid) / 1000.,
     491                                           float(self.grid) / 1000.)
     492                self.area = '{}/{}/{}/{}'.format(float(self.upper) / 1000.,
     493                                                 float(self.left) / 1000.,
     494                                                 float(self.lower) / 1000.,
     495                                                 float(self.right) / 1000.)
     496            elif float(self.grid) / 100. < 0.5:
     497                # grid is defined in normal degree; new method
     498                self.grid = '{}/{}'.format(float(self.grid), float(self.grid))
     499                self.area = '{}/{}/{}/{}'.format(float(self.upper),
     500                                                 float(self.left),
     501                                                 float(self.lower),
     502                                                 float(self.right))
    486503
    487504        return
  • source/python/classes/EcFlexpart.py

    rd43706b r2d56c04  
    194194        self.glevelist = '1/to/' + c.level
    195195        self.gaussian = c.gaussian
    196 
    197         if 'N' in c.grid:  # Gaussian output grid
    198             self.grid = c.grid
    199             self.area = 'G'
    200         else:
    201             self.grid = '{}/{}'.format(int(c.grid) / 1000., int(c.grid) / 1000.)
    202             self.area = '{}/{}/{}/{}'.format(int(c.upper) / 1000.,
    203                                              int(c.left) / 1000.,
    204                                              int(c.lower) / 1000.,
    205                                              int(c.right) / 1000.)
    206 
     196        self.grid = c.grid
     197        self.area = c.area
    207198        self.outputfilelist = []
    208199
     
    11071098                         is set to 1 in CONTROL file')
    11081099
     1100            # write out all output to log file before starting fortran programm
     1101            sys.stdout.flush()
     1102
    11091103            # Fortran program creates file fort.15 (with u,v,etadot,t,sp,q)
    11101104            p = subprocess.check_call([os.path.join(
  • source/python/mods/tools.py

    r786cfd6 r2d56c04  
    106106        return True
    107107    return False
    108 
    109 
    110108
    111109def get_cmdline_arguments():
Note: See TracChangeset for help on using the changeset viewer.
hosted by ZAMG