Commit 8a652926 authored by brunner's avatar brunner
Browse files

No commit message

No commit message
parent 51679a51
......@@ -79,7 +79,7 @@ def validate_rc_methane(self):
self.istartkey
]
for k, v in self.tm_settings.iteritems():
for k, v in self.tm_settings.items():
if v == 'True' : self.tm_settings[k] = True
if v == 'False': self.tm_settings[k] = False
if 'date' in k : self.tm_settings[k] = to_datetime(v)
......@@ -93,7 +93,7 @@ def validate_rc_methane(self):
self.tm_settings[k] = to_datetime(v)
for key in needed_rc_items:
if not self.tm_settings.has_key(key):
if key not in self.tm_settings:
msg = 'Missing a required value in rc-file : %s' % key
logging.error(msg)
raise IOError(msg)
......
......@@ -110,7 +110,7 @@ class TM5ObservationOperator(ObservationOperator):
'istart' : self.transitionvalue,
'my.source.dirs' : newdirs,
'build.copy.dirs' : newdirs}
for k, v in self.tm_settings.iteritems():
for k, v in self.tm_settings.items():
if type(v) is str:
if v.find('ml60') > -1:
newitemsmeteo[k] = v.replace('ml60','ml91')
......@@ -146,7 +146,7 @@ class TM5ObservationOperator(ObservationOperator):
newrcfilename = os.path.join(self.tm_settings['rundir'], self.tm_settings['install.rc'])
#Use a TM5 restart file in the first cycle (instead of init file). Used now for the CO project.
if self.dacycle.has_key('da.obsoperator.restartfileinfirstcycle'):
if 'da.obsoperator.restartfileinfirstcycle' in self.dacycle:
restartfilename = self.dacycle['da.obsoperator.restartfileinfirstcycle']
targetdir = self.tm_settings[self.savedirkey]
create_dirs(targetdir)
......@@ -176,7 +176,7 @@ class TM5ObservationOperator(ObservationOperator):
"""
Compile TM5 model using setup_tm5 and the modified rc-file
"""
if self.dacycle.has_key('da.obsoperator.home'):
if 'da.obsoperator.home' in self.dacycle:
os.chdir(self.dacycle['da.obsoperator.home'])
logging.debug('Proceeding from TM5 root dir (%s)'% self.dacycle['da.obsoperator.home'])
else:
......@@ -237,7 +237,7 @@ class TM5ObservationOperator(ObservationOperator):
new_items[self.istartkey] = self.restartvalue
logging.debug('Resetting TM5 to perform restart')
else:
if not self.dacycle.has_key('da.obsoperator.restartfileinfirstcycle'):
if 'da.obsoperator.restartfileinfirstcycle' not in self.dacycle:
new_items[self.istartkey] = self.coldstartvalue # if not, start TM5 'cold'
logging.debug('Resetting TM5 to perform cold start')
else:
......@@ -315,7 +315,7 @@ class TM5ObservationOperator(ObservationOperator):
self.istartkey
]
for k, v in self.tm_settings.iteritems():
for k, v in self.tm_settings.items():
if v == 'True' : self.tm_settings[k] = True
if v == 'False': self.tm_settings[k] = False
if 'date' in k : self.tm_settings[k] = to_datetime(v)
......@@ -329,7 +329,7 @@ class TM5ObservationOperator(ObservationOperator):
self.tm_settings[k] = to_datetime(v)
for key in needed_rc_items:
if not self.tm_settings.has_key(key):
if key not in self.tm_settings:
msg = 'Missing a required value in rc-file : %s' % key
logging.error(msg)
raise IOError(msg)
......@@ -345,15 +345,15 @@ class TM5ObservationOperator(ObservationOperator):
"""
for k, v in newvalues.iteritems():
if self.tm_settings.has_key(k):
for k, v in newvalues.items():
if key in self.tm_settings:
# keep previous value
v_orig = self.tm_settings[k]
#replace with new
self.tm_settings[k] = v
#replace all instances of old with new, but only if it concerns a name of a path!!!
if os.path.exists(str(v)):
for k_old, v_old in self.tm_settings.iteritems():
for k_old, v_old in self.tm_settings.items():
if not isinstance(v_old, str):
continue
if str(v_orig) in str(v_old):
......@@ -392,7 +392,7 @@ class TM5ObservationOperator(ObservationOperator):
if not os.path.exists(obsfile):
msg = "The specified obs input file for the TM5 model to read from does not exist (%s), exiting..." % obsfile
logging.error(msg)
if not self.dacycle.has_key('forward.savestate.dir'):
if 'forward.savestate.dir' not in self.dacycle:
raise IOError(msg)
for n in range(int(self.dacycle['da.optimizer.nmembers'])):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment