def test_rotation_to_zne(self): """ Weak test for rotation of arbitrarily rotated components to ZNE. """ st = read(os.path.join(self.path, "II_COCO_three_channel_borehole.mseed")) # Read the SEED file and rotate the Traces with the information stored # in the SEED file. p = Parser(os.path.join(self.path, "dataless.seed.II_COCO")) st_r = p.rotate_to_zne(st) # Still three channels left. self.assertEqual(len(st_r), 3) # Extract the components for easier assertions. This also asserts that # the channel renaming worked. tr_z = st.select(channel="BHZ")[0] tr_1 = st.select(channel="BH1")[0] tr_2 = st.select(channel="BH2")[0] tr_r_z = st_r.select(channel="BHZ")[0] tr_r_n = st_r.select(channel="BHN")[0] tr_r_e = st_r.select(channel="BHE")[0] # Convert all components to float for easier assertions. tr_z.data = np.require(tr_z.data, dtype=np.float64) tr_1.data = np.require(tr_1.data, dtype=np.float64) tr_2.data = np.require(tr_2.data, dtype=np.float64) # The total energy should not be different. energy_before = np.sum((tr_z.data ** 2) + (tr_1.data ** 2) + (tr_2.data ** 2)) energy_after = np.sum((tr_r_z.data ** 2) + (tr_r_n.data ** 2) + (tr_r_e.data ** 2)) self.assertTrue(np.allclose(energy_before, energy_after)) # The vertical channel should not have changed at all. np.testing.assert_array_equal(tr_z.data, tr_r_z.data) # The other two are only rotated by 2 degree so should also not have # changed much but at least a little bit. And the components should be # renamed. self.assertTrue(np.allclose(tr_1, tr_r_n, rtol=10E-3)) # The east channel carries very little energy for this particular # example. Thus it changes quite a lot even for this very subtle # rotation. The energy comparison should still ensure a sensible # result. self.assertTrue(np.allclose(tr_2, tr_r_e, atol=tr_r_e.max() / 4.0))
def test_rotation_to_zne(self): """ Weak test for rotation of arbitrarily rotated components to ZNE. """ st = read( os.path.join(self.path, "II_COCO_three_channel_borehole.mseed")) # Read the SEED file and rotate the Traces with the information stored # in the SEED file. p = Parser(os.path.join(self.path, "dataless.seed.II_COCO")) st_r = p.rotate_to_zne(st) # Still three channels left. self.assertEqual(len(st_r), 3) # Extract the components for easier assertions. This also asserts that # the channel renaming worked. tr_z = st.select(channel="BHZ")[0] tr_1 = st.select(channel="BH1")[0] tr_2 = st.select(channel="BH2")[0] tr_r_z = st_r.select(channel="BHZ")[0] tr_r_n = st_r.select(channel="BHN")[0] tr_r_e = st_r.select(channel="BHE")[0] # Convert all components to float for easier assertions. tr_z.data = np.require(tr_z.data, dtype=np.float64) tr_1.data = np.require(tr_1.data, dtype=np.float64) tr_2.data = np.require(tr_2.data, dtype=np.float64) # The total energy should not be different. energy_before = np.sum((tr_z.data**2) + (tr_1.data**2) + (tr_2.data**2)) energy_after = np.sum((tr_r_z.data**2) + (tr_r_n.data**2) + (tr_r_e.data**2)) self.assertTrue(np.allclose(energy_before, energy_after)) # The vertical channel should not have changed at all. np.testing.assert_allclose(tr_z.data, tr_r_z.data, rtol=1e-10) # The other two are only rotated by 2 degree so should also not have # changed much but at least a little bit. And the components should be # renamed. self.assertTrue(np.allclose(tr_1, tr_r_n, rtol=10E-3)) # The east channel carries very little energy for this particular # example. Thus it changes quite a lot even for this very subtle # rotation. The energy comparison should still ensure a sensible # result. self.assertTrue(np.allclose(tr_2, tr_r_e, atol=tr_r_e.max() / 4.0))