Skip to content

Commit

Permalink
update modify parameter python script to accept changing pft names
Browse files Browse the repository at this point in the history
  • Loading branch information
glemieux committed Oct 3, 2024
1 parent 7c367e5 commit 204a061
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 16 deletions.
4 changes: 2 additions & 2 deletions parameter_files/fates_params_default.cdl
Original file line number Diff line number Diff line change
Expand Up @@ -951,8 +951,8 @@ data:
"broadleaf_evergreen_extratrop_shrub ",
"broadleaf_hydrodecid_extratrop_shrub ",
"broadleaf_colddecid_extratrop_shrub ",
"broadleaf_evergreen_extratrop_shrub ",
"broadleaf_colddecid_extratrop_shrub ",
" broadleaf_evergreen_arctic_shrub ",
" broadleaf_colddecid_arctic_shrub ",
"arctic_c3_grass ",
"cool_c3_grass ",
"c4_grass " ;
Expand Down
35 changes: 21 additions & 14 deletions tools/modify_fates_paramfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,22 +73,29 @@ def main():
outputval = np.fromstring(args.val, sep=',', dtype=np.float64)

else:

try:
outputval = np.float64(args.val)
if args.changeshape:
raise Exception
except:

# First check to see if we are modifying the pftname
if args.varname == 'fates_pftname':
rename_pft = True
else:
try:
print('output variable not interpretable as real. trying array')
outputval = np.fromstring(args.val, sep=',', dtype=np.float64)
if len(outputval) == 0:
raise RuntimeError('output variable needs to have size greater than zero')
outputval = np.float64(args.val)
if args.changeshape:
raise Exception
except:
if args.varname != 'fates_pftname':
raise RuntimeError('output variable not interpretable as real or array')
else:
rename_pft = True
try:
print('output variable not interpretable as real. trying array')
outputval = np.fromstring(args.val, sep=',', dtype=np.float64)
# Note that fromstring does not yet raise a ValueError for fates_pftname
# argument values. As such, the exception below will not trigger.
# Numpy warns that this will be a ValueError exception in a future update.
if len(outputval) == 0:
raise RuntimeError('output variable needs to have size greater than zero')
except:
if args.varname != 'fates_pftname':
raise RuntimeError('output variable not interpretable as real or array')
else:
rename_pft = True
#
#
try:
Expand Down

0 comments on commit 204a061

Please sign in to comment.