def test_get_geo_from_mag(self): """geomag.ChannelConverterTest.test_get_geo_from_mag() ``X``, ``Y`` are the north component, and east component of the vector ``H`` which is an angle ``D`` from north. """ # Call get_geo_from_mag using H,D of 1, 45 degrees. Expect # X, Y to be cos_45, sin_45. h = 1 d = 30 * D2R (X, Y) = channel.get_geo_from_mag(h, d) assert_almost_equal(X, cos(30 * D2R), 8, 'Expect X to be cos(30).', True) assert_almost_equal(Y, sin(30 * D2R), 8, 'Expect Y to be sin(30).', True)
def get_geo_from_mag(mag): """Convert a stream to geographic coordinate system. Parameters ---------- stream : obspy.core.Stream stream containing observatory components H, D, Z, and F. Returns ------- obspy.core.Stream new stream object containing geographic components X, Y, Z, and F. """ h = mag.select(channel='H')[0] d = mag.select(channel='D')[0] z = mag.select(channel='Z')[0] f = mag.select(channel='F')[0] mag_h = h.data mag_d = d.data (geo_x, geo_y) = ChannelConverter.get_geo_from_mag(mag_h, mag_d) return obspy.core.Stream( (__get_trace('X', h.stats, geo_x), __get_trace('Y', d.stats, geo_y), z, f))
def get_geo_from_mag(mag): """Convert a stream to geographic coordinate system. Parameters ---------- stream : obspy.core.Stream stream containing observatory components H, D, Z, and F. Returns ------- obspy.core.Stream new stream object containing geographic components X, Y, Z, and F. """ h = mag.select(channel='H')[0] d = mag.select(channel='D')[0] z = mag.select(channel='Z')[0] f = mag.select(channel='F')[0] mag_h = h.data mag_d = d.data (geo_x, geo_y) = ChannelConverter.get_geo_from_mag(mag_h, mag_d) return obspy.core.Stream(( __get_trace('X', h.stats, geo_x), __get_trace('Y', d.stats, geo_y), z, f))