Skip to content

Commit

Permalink
Catch errors when writing out metadata values which might have specia…
Browse files Browse the repository at this point in the history
…l types and can't be safely cast (e.g. VALID_RANGE).
  • Loading branch information
duncanwp committed Jan 17, 2017
1 parent 8c9f5cf commit fa84fc7
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion cis/data_io/write_netcdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ def __add_metadata(var, data):
setattr(var, name, value)
for name, value in data.metadata.misc.items():
if name not in var.ncattrs():
setattr(var, name, value)
try:
setattr(var, name, value)
except ValueError:
logging.warning("Invalid value ({}) for {} attribute. Attribute not saved to {}.".format(value, name, var))
return var


Expand Down

0 comments on commit fa84fc7

Please sign in to comment.