Skip to content
Snippets Groups Projects
Commit 4de356a4 authored by lkugler's avatar lkugler
Browse files

fix Attribute/KeyError

parent c4f2c004
No related branches found
No related tags found
No related merge requests found
...@@ -200,7 +200,7 @@ def _get_list_of_localizations(): ...@@ -200,7 +200,7 @@ def _get_list_of_localizations():
# set the other (unused) list to a dummy value # set the other (unused) list to a dummy value
l_loc_vert_scaleheight = [-1,] l_loc_vert_scaleheight = [-1,]
except AttributeError: # localization by scale height except KeyError: # localization by scale height
try: try:
loc_vert_scaleheight = obscfg["loc_vert_scaleheight"] loc_vert_scaleheight = obscfg["loc_vert_scaleheight"]
...@@ -210,16 +210,16 @@ def _get_list_of_localizations(): ...@@ -210,16 +210,16 @@ def _get_list_of_localizations():
# set the other (unused) list to a dummy value # set the other (unused) list to a dummy value
l_loc_vert_km = [-1,] l_loc_vert_km = [-1,]
except AttributeError: except KeyError:
# do we have vertical localization? # do we have vertical localization?
# check parameter horiz_dist_only == true # check parameter horiz_dist_only == true
if exp.dart_nml['&location_nml']['horiz_dist_only'][0] == '.true.': if exp.dart_nml['&location_nml']['horiz_dist_only'] == '.true.':
# no vertical localization # no vertical localization
l_loc_vert_km.append(-1) l_loc_vert_km.append(-1)
l_loc_vert_scaleheight.append(-1) l_loc_vert_scaleheight.append(-1)
else: else:
raise ValueError('Neither `loc_vert_km` nor `loc_vert_scaleheight` defined in obscfg.') raise ValueError('DART namelist requires vertical localization, but neither `loc_vert_km` nor `loc_vert_scaleheight` are defined in obscfg.')
return l_obstypes, l_loc_horiz_rad, l_loc_vert_km, l_loc_vert_scaleheight return l_obstypes, l_loc_horiz_rad, l_loc_vert_km, l_loc_vert_scaleheight
...@@ -341,4 +341,4 @@ def write_namelist(just_prior_values=False): ...@@ -341,4 +341,4 @@ def write_namelist(just_prior_values=False):
append_file(cluster.dart_rundir + "/input.nml", rttov_nml) append_file(cluster.dart_rundir + "/input.nml", rttov_nml)
# alternatively, we could do this in cfg.py or the template input.nml in DART's model/wrf/work folder # alternatively, we could do this in cfg.py or the template input.nml in DART's model/wrf/work folder
return nml # in case we want to access namelist settings in python return nml # in case we want to access namelist settings in python
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment