Skip to content
Snippets Groups Projects
Commit f06188a9 authored by Eddie McWhirter's avatar Eddie McWhirter
Browse files

Move math from value formatter to data formatter.

parent 00d62c45
No related branches found
No related tags found
No related merge requests found
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
from cStringIO import StringIO from cStringIO import StringIO
from geomagio import ChannelConverter from geomagio import ChannelConverter
import numpy import numpy
from obspy.core import Stream
import PCDCPParser import PCDCPParser
from datetime import datetime from datetime import datetime
...@@ -71,18 +72,19 @@ class PCDCPWriter(object): ...@@ -71,18 +72,19 @@ class PCDCPWriter(object):
""" """
buf = [] buf = []
# create new stream
timeseriesLocal = Stream()
# Use a copy of the trace so that we don't modify the original. # Use a copy of the trace so that we don't modify the original.
timeseriesLocal = timeseries.copy() for trace in timeseries:
traceLocal = trace.copy()
if traceLocal.stats.channel == 'D':
traceLocal.data = \
ChannelConverter.get_minutes_from_radians(traceLocal.data)
if timeseriesLocal.select(channel='D'): traceLocal.data = \
d = timeseriesLocal.select(channel='D') numpy.round(numpy.multiply(traceLocal.data, 100)).astype(int)
d[0].data = ChannelConverter.get_minutes_from_radians(d[0].data)
# TODO - is this doing anything? timeseriesLocal.append(traceLocal)
i = 0
for trace in timeseriesLocal:
timeseriesLocal[i].trace = numpy.round(numpy.multiply(trace, 100))
i += 1
traces = [timeseriesLocal.select(channel=c)[0] for c in channels] traces = [timeseriesLocal.select(channel=c)[0] for c in channels]
starttime = float(traces[0].stats.starttime) starttime = float(traces[0].stats.starttime)
...@@ -116,8 +118,7 @@ class PCDCPWriter(object): ...@@ -116,8 +118,7 @@ class PCDCPWriter(object):
return '{0:0>4d} {2: >8d} {3: >8d} {4: >8d} {5: >8d}\n'.format( return '{0:0>4d} {2: >8d} {3: >8d} {4: >8d} {5: >8d}\n'.format(
totalMinutes, int(time.microsecond / 1000), totalMinutes, int(time.microsecond / 1000),
*[self.empty_value if numpy.isnan(val) else int(round( *[self.empty_value if numpy.isnan(val) else val
val * 100))
for val in values]) for val in values])
@classmethod @classmethod
......
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