From 773654c3f88981b020b2a861ecc2a17cf3a7456e Mon Sep 17 00:00:00 2001 From: Jeremy Fee <jmfee@usgs.gov> Date: Thu, 20 Sep 2018 10:35:21 -0600 Subject: [PATCH] Trap errors when elevation is not correctly set --- geomagio/imfjson/IMFJSONWriter.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/geomagio/imfjson/IMFJSONWriter.py b/geomagio/imfjson/IMFJSONWriter.py index e8323c43f..91c6f5aa9 100644 --- a/geomagio/imfjson/IMFJSONWriter.py +++ b/geomagio/imfjson/IMFJSONWriter.py @@ -122,8 +122,11 @@ class IMFJSONWriter(object): coords[0] = float(stats.geodetic_longitude) if 'geodetic_latitude' in stats: coords[1] = float(stats.geodetic_latitude) - if 'elevation' in stats: - coords[2] = float(stats.elevation) + try: + if 'elevation' in stats: + coords[2] = float(stats.elevation) + except (KeyError, ValueError, TypeError): + pass imo['coordinates'] = coords intermag['imo'] = imo intermag['reported_orientation'] = ''.join(channels) -- GitLab