Skip to content
Snippets Groups Projects
Commit 3c5fba47 authored by Jeremy M Fee's avatar Jeremy M Fee
Browse files

Change how empty channels are detected and filtered

parent 7fea7947
No related branches found
No related tags found
No related merge requests found
......@@ -8,6 +8,9 @@ from datetime import datetime
EIGHTS = numpy.float64('88888.88')
NINES = numpy.float64('99999.99')
# placeholder channel name used when less than 4 channels are being written.
EMPTY_CHANNEL = 'NUL'
class IAGA2002Parser(object):
"""IAGA2002 parser.
......@@ -166,13 +169,12 @@ class IAGA2002Parser(object):
self.parse_comments()
self.times = self._parsedata[0]
for channel, data in zip(self.channels, self._parsedata[1:]):
#ignore empty channels
# ignore "empty" channels
if channel == EMPTY_CHANNEL:
continue
data = numpy.array(data, dtype=numpy.float64)
data[data == EIGHTS] = numpy.nan
data[data == NINES] = numpy.nan
# filter empty values
if data.count(numpy.nan) == len(data):
continue
self.data[channel] = data
self._parsedata = None
......
......@@ -14,8 +14,10 @@ class IAGA2002Writer(object):
"""IAGA2002 writer.
"""
def __init__(self, empty_value=IAGA2002Parser.NINES):
def __init__(self, empty_value=IAGA2002Parser.NINES,
empty_channel=IAGA2002Parser.EMPTY_CHANNEL):
self.empty_value = empty_value
self.empty_channel = empty_channel
def write(self, out, timeseries, channels):
"""write timeseries to iaga file
......@@ -232,7 +234,7 @@ class IAGA2002Writer(object):
def _pad_to_four_channels(self, timeseries, channels):
for x in range(len(channels), 4):
channel = 'NUL'
channel = self.empty_channel
channels.append(channel)
timeseries += create_empty_trace(timeseries[0], channel)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment