Skip to content

Commit c18d940

Browse files
committed
Update test_aurora_processing.py
1 parent adcbd5d commit c18d940

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed

tests/processing/aurora/test_aurora_processing.py

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,75 @@ def tearDownClass(self):
8888
close_open_files()
8989

9090

91+
class TestProcessRRCompare(unittest.TestCase):
92+
@classmethod
93+
def setUpClass(self):
94+
self.mth5_path = MTH5_PATH.joinpath("test12rr.h5")
95+
if not self.mth5_path.exists():
96+
self.mth5_path = create_test12rr_h5()
97+
98+
# process with mtpy
99+
self.ap = AuroraProcessing()
100+
self.ap.local_station_id = "test1"
101+
self.ap.local_mth5_path = self.mth5_path
102+
self.ap.remote_station_id = "test2"
103+
self.ap.remote_mth5_path = self.mth5_path
104+
self.processed = self.ap.process(
105+
sample_rates=1, merge=True, save_to_mth5=True
106+
)
107+
self.mt_obj_new = self.processed[1]["tf"]
108+
109+
# process with aurora infrastructure
110+
self.run_summary = RunSummary()
111+
self.run_summary.from_mth5s([self.mth5_path])
112+
self.kernel_dataset = KernelDataset()
113+
self.kernel_dataset.from_run_summary(
114+
self.run_summary, "test1", "test2"
115+
)
116+
cc = ConfigCreator()
117+
self.config = cc.create_from_kernel_dataset(self.kernel_dataset)
118+
## need to set same config parameters
119+
self.ap._set_decimation_level_parameters(
120+
self.config,
121+
**self.ap.default_window_parameters["low"],
122+
)
123+
124+
self.tf_obj = process_mth5(self.config, self.kernel_dataset)
125+
self.tf_obj.tf_id = self.kernel_dataset.processing_id
126+
self.tf_obj.station_metadata.transfer_function.runs_processed = (
127+
self.tf_obj.station_metadata.run_list
128+
)
129+
self.mt_obj_legacy = MT(survey_metadata=self.tf_obj.survey_metadata)
130+
self.mt_obj_legacy._transfer_function = self.tf_obj._transfer_function
131+
132+
self.mt_obj_legacy.survey_metadata.id = (
133+
self.mt_obj_new.survey_metadata.id
134+
)
135+
136+
def test_tfs_equal(self):
137+
self.assertEqual(self.mt_obj_new, self.mt_obj_legacy)
138+
139+
def test_tf_id(self):
140+
self.assertEqual(self.mt_obj_new.tf_id, self.ap.processing_id)
141+
142+
def test_tf_in_mth5(self):
143+
with MTH5() as m:
144+
m.open_mth5(self.mth5_path)
145+
tf_df = m.tf_summary.to_dataframe()
146+
with self.subTest("station is in tf_summary"):
147+
self.assertIn("test1", tf_df.station.tolist())
148+
with self.subTest("tf's are equal"):
149+
tf = m.get_transfer_function("test1", "test1-rr_test2_sr1")
150+
self.assertEqual(self.tf_obj, tf)
151+
152+
def test_processed_dict(self):
153+
self.assertTrue(self.processed[1]["processed"])
154+
155+
@classmethod
156+
def tearDownClass(self):
157+
close_open_files()
158+
159+
91160
# =============================================================================
92161
# run
93162
# =============================================================================

0 commit comments

Comments
 (0)