def test_readingSES3DFile(): """ Tests the actual reading of a SES3D file. """ filename = os.path.join(data_dir, "File_phi") st = read_SES3D(filename) assert len(st) == 1 tr = st[0] assert len(tr) == 3300 np.testing.assert_almost_equal(tr.stats.delta, 0.15) # Latitude in the file is actually the colatitude. np.testing.assert_almost_equal(tr.stats.ses3d.receiver_latitude, 90.0 - 107.84100) np.testing.assert_almost_equal(tr.stats.ses3d.receiver_longitude, -3.5212801) np.testing.assert_almost_equal(tr.stats.ses3d.receiver_depth_in_m, 0.0) np.testing.assert_almost_equal(tr.stats.ses3d.source_latitude, 90.0 - 111.01999) np.testing.assert_almost_equal(tr.stats.ses3d.source_longitude, -8.9499998) np.testing.assert_almost_equal(tr.stats.ses3d.source_depth_in_m, 20000) # Test head and tail of the actual data. Assume the rest to be correct # as well. np.testing.assert_array_equal(tr.data[:50], np.zeros(50, dtype="float32")) # The data is just copied from the actual file. np.testing.assert_almost_equal(tr.data[-9:], np.array([ 3.41214417E-07, 2.95646032E-07, 2.49543859E-07, 2.03108399E-07, 1.56527761E-07, 1.09975687E-07, 6.36098676E-08, 1.75719919E-08, -2.80116144E-08]))
def test_ComponentMapping(): """ Tests that the components are correctly mapped. """ filename_theta = os.path.join(data_dir, "File_theta") filename_phi = os.path.join(data_dir, "File_phi") filename_r = os.path.join(data_dir, "File_r") # The theta component is named X. tr_theta = read_SES3D(filename_theta)[0] assert tr_theta.stats.channel == "X" # The phi component goes from west to east. tr_phi = read_SES3D(filename_phi)[0] assert tr_phi.stats.channel == "Y" # The r-component points up. tr_r = read_SES3D(filename_r)[0] assert tr_r.stats.channel == "Z"
def test_OtherComponentsAreNotInverted(): """ The other components should not be inverted. """ filename_phi = os.path.join(data_dir, "File_phi") filename_r = os.path.join(data_dir, "File_r") tr_phi = read_SES3D(filename_phi)[0] assert tr_phi.stats.channel == "Y" phi_data = np.array([ 4.23160685E-07, 3.80973177E-07, 3.39335969E-07, 2.98305707E-07, 2.57921158E-07, 2.18206054E-07, 1.79171423E-07, 1.40820376E-07, 1.03153077E-07, 6.61708626E-08]) np.testing.assert_almost_equal(tr_phi.data[-10:], phi_data) tr_r = read_SES3D(filename_r)[0] assert tr_r.stats.channel == "Z" r_data = np.array([ 3.33445854E-07, 3.32186886E-07, 3.32869206E-07, 3.35317537E-07, 3.39320707E-07, 3.44629825E-07, 3.50957549E-07, 3.57983453E-07, 3.65361842E-07, 3.72732785E-07]) np.testing.assert_almost_equal(tr_r.data[-10:], r_data)
def test_SouthComponent(): """ Test the X component. """ filename = os.path.join(data_dir, "File_theta") tr = read_SES3D(filename)[0] assert tr.stats.channel == "X" # The data actually in the file. This points south. data = np.array([ 4.23160685E-07, 3.80973177E-07, 3.39335969E-07, 2.98305707E-07, 2.57921158E-07, 2.18206054E-07, 1.79171423E-07, 1.40820376E-07, 1.03153077E-07, 6.61708626E-08]) # Check. np.testing.assert_almost_equal(tr.data[-10:], data)
def test_readingSES3DFile_headonly(): """ Tests the headonly reading of a SES3D file. """ filename = os.path.join(data_dir, "File_phi") st = read_SES3D(filename, headonly=True) assert len(st) == 1 tr = st[0] assert tr.stats.npts == 3300 np.testing.assert_almost_equal(tr.stats.delta, 0.15) # Latitude in the file is actually the colatitude. np.testing.assert_almost_equal(tr.stats.ses3d.receiver_latitude, 90.0 - 107.84100) np.testing.assert_almost_equal(tr.stats.ses3d.receiver_longitude, -3.5212801) np.testing.assert_almost_equal(tr.stats.ses3d.receiver_depth_in_m, 0.0) np.testing.assert_almost_equal(tr.stats.ses3d.source_latitude, 90.0 - 111.01999) np.testing.assert_almost_equal(tr.stats.ses3d.source_longitude, -8.9499998) np.testing.assert_almost_equal(tr.stats.ses3d.source_depth_in_m, 20000) assert len(tr.data) == 0