def test_get_obs_e_from_obs(self): """geomag.ChannelConverterTest.test_get_obs_e_from_obs() ``e`` is the seconday (east) component of the observatory vector ``h``. ``e`` is calculated using ``h`` * tan(``d``) where ``d`` is the declination angle of the observatory. """ # Call get_obs_e_from_obs using h,d of 2, 30. # Expect e to be 2 * tan(30) h = 2 d = 30 * D2R e = channel.get_obs_e_from_obs(h, d) assert_almost_equal(e, 2 * tan(30 * D2R), 8, 'Expect e to be 2 * tan(30).', True)
def __get_obs_e_from_obs(obs): """Get trace containing observatory E component. Returns E if found, otherwise computes E from H,D. Parameters ---------- obs : obspy.core.Stream observatory components (E) or (H, D). Returns ------- obspy.core.Trace observatory component E. """ try: e = obs.select(channel='E')[0] except: h = obs.select(channel='H')[0] d = obs.select(channel='D')[0] e = __get_trace('E', d.stats, ChannelConverter.get_obs_e_from_obs(h.data, d.data)) return e