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

Clean up comments and code in PCDCPWriter.

parent 099be8ff
No related branches found
No related tags found
No related merge requests found
......@@ -26,30 +26,29 @@ class PCDCPWriter(object):
Channels to be written from timeseries object.
"""
stats = timeseries[0].stats
out.write(self._format_header(stats, channels))
out.write(self._format_header(stats))
out.write(self._format_data(timeseries, channels))
def _format_header(self, name, value):
def _format_header(self, stats):
"""format headers for PCDCP file
Parameters
----------
name : str
the name to be written
value : str
the value to written.
stats : List
An object with the header values to be written.
Returns
-------
str
a string formatted to be a single header line in a PCDCP file
A string formatted to be a single header line in a PCDCP file.
"""
buf = []
observatory = name.station
year = str(name.starttime.year)
yearday = str(name.starttime.julday).zfill(3)
date = name.starttime.strftime("%d-%b-%y")
space = ' '
observatory = stats.station
year = str(stats.starttime.year)
yearday = str(stats.starttime.julday).zfill(3)
date = stats.starttime.strftime("%d-%b-%y")
buf.append(observatory + ' ' + year + ' ' + yearday + ' ' +
date + ' HEZF 0.01nT File Version 2.00\n')
......@@ -60,10 +59,15 @@ class PCDCPWriter(object):
Parameters
----------
timeseries : obspy.core.Stream
stream containing traces with channel listed in channels
channels : sequence
list and order of channel values to output.
timeseries : obspy.core.Stream
Stream containing traces with channel listed in channels
channels : sequence
List and order of channel values to output.
Returns
-------
str
A string formatted to be the data lines in a PCDCP file.
"""
buf = []
if timeseries.select(channel='D'):
......@@ -86,11 +90,11 @@ class PCDCPWriter(object):
Parameters
----------
time : datetime
timestamp for values
values : sequence
list and order of channel values to output.
if value is NaN, self.empty_value is output in its place.
time : datetime
Timestamp for values.
values : sequence
List and order of channel values to output.
If value is NaN, self.empty_value is output in its place.
Returns
-------
......@@ -99,8 +103,8 @@ class PCDCPWriter(object):
"""
tt = time.timetuple()
totalMinutes = int(tt.tm_hour * 60 + tt.tm_min)
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),
*[self.empty_value if numpy.isnan(val) else int(round(val*100))
for val in values])
......@@ -113,7 +117,10 @@ class PCDCPWriter(object):
Parameters
----------
timeseries : obspy.core.Stream
timeseries : obspy.core.Stream
Stream containing traces with channel listed in channels
channels : sequence
List and order of channel values to output.
Returns
-------
......
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