Skip to content
Snippets Groups Projects
Commit 95a46324 authored by Claycomb, Abram Earl's avatar Claycomb, Abram Earl
Browse files

added comments to ipynb, changed constructor, ...

parent c8d07dfb
No related branches found
No related tags found
No related merge requests found
This diff is collapsed.
...@@ -28,6 +28,19 @@ contained in the statefile. ...@@ -28,6 +28,19 @@ contained in the statefile.
--output-iaga-stdout --output-iaga-stdout
### Statefile Example Content
This is the content of /etc/adjusted/adjbou_state_.json:
{"M32": -0.011809351484171948, "M41": -0.0, "M44": 1.0, "PC": -22,
"M24": -0.84581925813504188, "M43": 0.0,
"M34": 905.38008857968441, "M33": 0.99618690124939757,
"M21": 0.16680172992706568, "M22": 0.98791620101212796,
"M23": -0.0049868332295851525, "M11": 0.98342757670906167,
"M42": -0.0, "M13": 0.027384986324932026,
"M12": -0.15473074200902157, "M14": -1276.1646811919759,
"M31": -0.006725053082782385}
### Library Notes ### Library Notes
> Note: this library internally represents data gaps as NaN, and > Note: this library internally represents data gaps as NaN, and
......
...@@ -12,13 +12,16 @@ import sys ...@@ -12,13 +12,16 @@ import sys
class AdjustedAlgorithm(Algorithm): class AdjustedAlgorithm(Algorithm):
"""Adjusted Data Algorithm""" """Adjusted Data Algorithm"""
def __init__(self, matrix=None, pier_correction=None, statefile=None): def __init__(self, matrix=None, pier_correction=None, statefile=None,
data_type=None, location=None):
Algorithm.__init__(self, inchannels=('H', 'E', 'Z', 'F'), Algorithm.__init__(self, inchannels=('H', 'E', 'Z', 'F'),
outchannels=('X', 'Y', 'Z', 'F')) outchannels=('X', 'Y', 'Z', 'F'))
# state variables # state variables
self.matrix = matrix self.matrix = matrix
self.pier_correction = pier_correction self.pier_correction = pier_correction
self.statefile = statefile self.statefile = statefile
self.data_type = data_type
self.location = location
if (matrix is None): if (matrix is None):
self.load_state() self.load_state()
...@@ -85,8 +88,7 @@ class AdjustedAlgorithm(Algorithm): ...@@ -85,8 +88,7 @@ class AdjustedAlgorithm(Algorithm):
with open(self.statefile, 'w') as f: with open(self.statefile, 'w') as f:
f.write(json.dumps(data)) f.write(json.dumps(data))
@classmethod def create_trace(self, channel, stats, data):
def create_trace(cls, channel, stats, data):
"""Utility to create a new trace object. """Utility to create a new trace object.
Parameters Parameters
...@@ -104,9 +106,16 @@ class AdjustedAlgorithm(Algorithm): ...@@ -104,9 +106,16 @@ class AdjustedAlgorithm(Algorithm):
trace containing data and metadata. trace containing data and metadata.
""" """
stats = Stats(stats) stats = Stats(stats)
stats.data_type = 'adjusted' if self.data_type is None:
stats.location = 'A0' stats.data_type = 'adjusted'
trace = super(AdjustedAlgorithm, cls).create_trace(channel, stats, else:
stats.data_type = self.data_type
if self.data_type is None:
stats.location = 'A0'
else:
stats.location = self.location
trace = super(AdjustedAlgorithm, self).create_trace(channel, stats,
data) data)
return trace return trace
......
...@@ -10,6 +10,7 @@ def test_construct(): ...@@ -10,6 +10,7 @@ def test_construct():
""" """
matrix = None matrix = None
pier_correction = None pier_correction = None
# load adjusted data transform matrix and pier correction
a = adj(matrix, pier_correction, 'etc/adjusted/adjbou_state_.json') a = adj(matrix, pier_correction, 'etc/adjusted/adjbou_state_.json')
assert_almost_equals(a.matrix[0, 0], 9.83427577e-01, 6) assert_almost_equals(a.matrix[0, 0], 9.83427577e-01, 6)
...@@ -24,8 +25,10 @@ def test_process(): ...@@ -24,8 +25,10 @@ def test_process():
""" """
matrix = None matrix = None
pier_correction = None pier_correction = None
# load adjusted data transform matrix and pier correction
a = adj(matrix, pier_correction, 'etc/adjusted/adjbou_state_.json') a = adj(matrix, pier_correction, 'etc/adjusted/adjbou_state_.json')
# load boulder Jan 16 files from /etc/ directory
hezf_iaga2002_file = open('etc/adjusted/BOU201601vmin.min') hezf_iaga2002_file = open('etc/adjusted/BOU201601vmin.min')
hezf_iaga2002_string = hezf_iaga2002_file.read() hezf_iaga2002_string = hezf_iaga2002_file.read()
xyzf_iaga2002_file = open('etc/adjusted/BOU201601adj.min') xyzf_iaga2002_file = open('etc/adjusted/BOU201601adj.min')
...@@ -34,11 +37,15 @@ def test_process(): ...@@ -34,11 +37,15 @@ def test_process():
hezf = factory.parse_string(hezf_iaga2002_string) hezf = factory.parse_string(hezf_iaga2002_string)
xyzf = factory.parse_string(xyzf_iaga2002_string) xyzf = factory.parse_string(xyzf_iaga2002_string)
# process hezf (raw) channels with loaded transform
adj_bou = a.process(hezf) adj_bou = a.process(hezf)
# unpack channels from loaded adjusted data file
x = xyzf.select(channel='X')[0] x = xyzf.select(channel='X')[0]
y = xyzf.select(channel='Y')[0] y = xyzf.select(channel='Y')[0]
z = xyzf.select(channel='Z')[0] z = xyzf.select(channel='Z')[0]
f = xyzf.select(channel='F')[0] f = xyzf.select(channel='F')[0]
# unpack channels from adjusted processing of raw data
x_adj = adj_bou.select(channel='X')[0] x_adj = adj_bou.select(channel='X')[0]
y_adj = adj_bou.select(channel='Y')[0] y_adj = adj_bou.select(channel='Y')[0]
z_adj = adj_bou.select(channel='Z')[0] z_adj = adj_bou.select(channel='Z')[0]
......
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