def test_get_mag_from_geo(self): """geomag.ChannelConverterTest.test_get_geo_y_from_obs() ``X`` and ``Y are the north and east components of the ``H`` total magnetic field horizontal vector. ``D`` is the angle from north of that vector. """ # Call get_mag_from_geo using X,Y of 3cos(30), 3sin(30). # Expect H to be 3, and D to be 30 degrees. X = 3 * cos(30 * D2R) Y = 3 * sin(30 * D2R) H, D = channel.get_mag_from_geo(X, Y) assert_almost_equal(H, 3, 8, 'Expect H to equal 3.', True) assert_almost_equal(D, 30 * D2R, 8, 'Expect D to be 30.', True)
def get_mag_from_geo(geo): """Convert a stream to magnetic coordinate system. Parameters ---------- geo: obspy.core.Stream stream containing observatory components X, Y, Z, and F. Returns ------- obspy.core.Stream new stream object containing magnetic components H, D, Z, and F. """ x = geo.select(channel='X')[0] y = geo.select(channel='Y')[0] z = geo.select(channel='Z')[0] f = geo.select(channel='F')[0] geo_x = x.data geo_y = y.data (mag_h, mag_d) = ChannelConverter.get_mag_from_geo(geo_x, geo_y) return obspy.core.Stream( (__get_trace('H', x.stats, mag_h), __get_trace('D', y.stats, mag_d), z, f))
def get_mag_from_geo(geo): """Convert a stream to magnetic coordinate system. Parameters ---------- geo: obspy.core.Stream stream containing observatory components X, Y, Z, and F. Returns ------- obspy.core.Stream new stream object containing magnetic components H, D, Z, and F. """ x = geo.select(channel='X')[0] y = geo.select(channel='Y')[0] z = geo.select(channel='Z')[0] f = geo.select(channel='F')[0] geo_x = x.data geo_y = y.data (mag_h, mag_d) = ChannelConverter.get_mag_from_geo(geo_x, geo_y) return obspy.core.Stream(( __get_trace('H', x.stats, mag_h), __get_trace('D', y.stats, mag_d), z, f))