diff --git a/geomagio/iaga2002/IAGA2002Parser.py b/geomagio/iaga2002/IAGA2002Parser.py index e81610d4bc6c04d96627860a4c1c991fce997fff..637e7b79c1ecf089698082ae3ae66c808209d1a8 100644 --- a/geomagio/iaga2002/IAGA2002Parser.py +++ b/geomagio/iaga2002/IAGA2002Parser.py @@ -103,10 +103,13 @@ class IAGA2002Parser(object): key = 'sensor_orientation' elif key_upper == 'DIGITAL SAMPLING': key = 'sensor_sampling_rate' - if value.find('second') != -1: - value = 1 / float(value.replace('second', '').strip()) - elif value.find('Hz') != -1: - value = float(value.replace('Hz', '').strip()) + try: + if value.find('second') != -1: + value = 1 / float(value.replace('second', '').strip()) + elif value.find('Hz') != -1: + value = float(value.replace('Hz', '').strip()) + except: + return elif key_upper == 'DATA INTERVAL TYPE': key = 'data_interval_type' elif key_upper == 'DATA TYPE': diff --git a/geomagio/iaga2002/IAGA2002Writer.py b/geomagio/iaga2002/IAGA2002Writer.py index 6737274e90becb2be42b565267d2c6d072d0dcd2..decb592333efc100e63448b11a87fbbb060e391d 100644 --- a/geomagio/iaga2002/IAGA2002Writer.py +++ b/geomagio/iaga2002/IAGA2002Writer.py @@ -102,7 +102,7 @@ class IAGA2002Writer(object): an array containing formatted strings of header data. """ comments = [] - if 'declination_base' in stats: + if 'declination_base' in stats and stats.declination_base is not None: comments.append('DECBAS {:<8d}' '(Baseline declination value in tenths of minutes East' ' (0-216,000)).'.format(stats.declination_base)) @@ -118,7 +118,7 @@ class IAGA2002Writer(object): ' INTERMAGNET DVD.') comments.append('Go to www.intermagnet.org for details on' + ' obtaining this product.') - if 'conditions_of_use' in stats: + if 'conditions_of_use' in stats and stats.conditions_of_use is not None: comments.append('CONDITIONS OF USE: ' + stats.conditions_of_use) # generate comment output buf = []