Changeset 70fee58 in flex_extract.git for source/python/classes/EcFlexpart.py


Ignore:
Timestamp:
Oct 12, 2018, 1:17:12 PM (6 years ago)
Author:
Anne Philipp <anne.philipp@…>
Branches:
master, ctbto, dev
Children:
785b882
Parents:
5827ff6
Message:

some bug corrections, minor code improvements

File:
1 edited

Legend:

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

    raa275fc r70fee58  
    8585                     codes_get_values, codes_set_values, codes_set,
    8686                     codes_write, codes_release, codes_new_from_index,
    87                      codes_index_release)
     87                     codes_index_release, codes_index_get)
    8888
    8989# software specific classes and modules from flex_extract
     
    136136        self.types = dict()
    137137
    138         if c.maxstep > len(c.type):    # Pure forecast mode
     138        # Pure forecast mode
     139        if c.maxstep > len(c.type) and 'AN' not in c.type:
    139140            c.type = [c.type[0]]
    140141            c.step = ['{:0>3}'.format(int(c.step[0]))]
     
    168169                    btlist = [13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 0]
    169170
    170                 if ((ty.upper() == 'AN' and
    171                      int(c.time[i]) % int(c.dtime) ==0) or
    172                     (ty.upper() != 'AN' and
    173                      int(c.step[i]) % int(c.dtime) == 0 and
    174                      int(c.step[i]) % int(c.dtime) == 0) ) and \
     171                if ((ty.upper() == 'AN' and (int(c.time[i]) % int(c.dtime)) == 0) or
     172                    (ty.upper() != 'AN' and (int(c.step[i]) % int(c.dtime)) == 0 and
     173                     (int(c.step[i]) % int(c.dtime) == 0)) ) and \
    175174                    (int(c.time[i]) in btlist or c.maxstep > 24):
    176175
     
    434433            #index_vals.append(grib_index_get(iid, key))
    435434            #print(index_vals[-1])
    436             key_vals = grib_index_get(iid, key)
     435            key_vals = codes_index_get(iid, key)
    437436            print(key_vals)
    438437            # have to sort the steps for disaggregation,
     
    532531                if isinstance(pv, str):
    533532                    continue
    534                 retr_param_dict['type'] = '' + ftype
     533                retr_param_dict['type'] = ftype
    535534                retr_param_dict['time'] = self.types[ftype]['times']
    536535                retr_param_dict['step'] = self.types[ftype]['steps']
     
    538537                retr_param_dict['stream'] = self.stream
    539538                retr_param_dict['target'] = \
    540                     self._mk_targetname(ftype, pk,
     539                    self._mk_targetname(ftype,
     540                                        pk,
    541541                                        retr_param_dict['date'].split('/')[0])
    542542                retr_param_dict['param'] = pv[0]
     
    689689
    690690        loader = TemplateLoader(_config.PATH_TEMPLATES, auto_reload=False)
    691         compile_template = loader.load(_config.TEMPFILE_NAMELIST,
     691        namelist_template = loader.load(_config.TEMPFILE_NAMELIST,
    692692                                       cls=NewTextTemplate)
    693693
     
    701701        maxb = int((area[0] - area[2]) / grid[0]) + 1
    702702
    703         stream = compile_template.generate(
     703        stream = namelist_template.generate(
    704704            maxl = str(maxl),
    705705            maxb = str(maxb),
     
    12161216        print(self.outputfilelist)
    12171217
    1218         if c.format.lower() == 'grib2':
    1219             for ofile in self.outputfilelist:
     1218        for ofile in self.outputfilelist:
     1219            ofile = os.path.join(self.inputdir, ofile)
     1220
     1221            if c.format.lower() == 'grib2':
    12201222                p = subprocess.check_call(['grib_set', '-s', 'edition=2, \
    12211223                                           productDefinitionTemplateNumber=8',
     
    12231225                p = subprocess.check_call(['mv', ofile + '_2', ofile])
    12241226
    1225         if c.ectrans and not c.ecapi:
    1226             for ofile in self.outputfilelist:
     1227            if c.ectrans and not c.ecapi:
    12271228                p = subprocess.check_call(['ectrans', '-overwrite', '-gateway',
    12281229                                           c.gateway, '-remote', c.destination,
    12291230                                           '-source', ofile])
    12301231
    1231         if c.ecstorage and not c.ecapi:
    1232             for ofile in self.outputfilelist:
     1232            if c.ecstorage and not c.ecapi:
    12331233                p = subprocess.check_call(['ecp', '-o', ofile,
    12341234                                           os.path.expandvars(c.ecfsdir)])
    12351235
    1236         if c.outputdir != c.inputdir:
    1237             for ofile in self.outputfilelist:
     1236            if c.outputdir != c.inputdir:
    12381237                p = subprocess.check_call(['mv',
    12391238                                           os.path.join(c.inputdir, ofile),
Note: See TracChangeset for help on using the changeset viewer.
hosted by ZAMG