def test_get_obs_from_geo():
    """geomag.StreamConverter_test.test_get_obs_from_geo()

    The geographic stream containing the traces ''x'', ''y'', ''z'', and
    ''f'' converts to the observatory stream containing the traces
    ''h'', ''d'' or ''e'', ''z'', and ''f''.
    """
    geo = obspy.core.Stream()

    # Call get_geo_from_obs using a decbas of 15, a X stream of
    #   [cos(30), cos(45)], and a Y stream of [sin(30), sin(45)].
    #   Expect a H stream of [cos(15), cos(30)] and a
    #   E stream of [sin(15), sin(30)]
    DECBAS = 15 * D2I
    geo += __create_trace('X', [cos(30 * D2R), cos(45 * D2R)], DECBAS)
    geo += __create_trace('Y', [sin(30 * D2R), sin(45 * D2R)], DECBAS)
    geo += __create_trace('Z', [1, 1], DECBAS)
    geo += __create_trace('F', [1, 1], DECBAS)
    obs = StreamConverter.get_obs_from_geo(geo, True)
    H = obs.select(channel='H')[0].data
    E = obs.select(channel='E')[0].data
    D = obs.select(channel='D')[0].data
    assert_almost_equal(H, [cos(15 * D2R), cos(30 * D2R)], 9,
        'Expect H to equal [cos(15), cos(30)]', True)
    assert_almost_equal(E, [sin(15 * D2R), sin(30 * D2R)], 9,
        'Expect E to equal [sin(15), sin(30)', True)
    assert_almost_equal(D, [15 * D2R, 30 * D2R], 9,
        'Expect D to equal [15 degress, 30 degrees]', True)
示例#2
0
def test_get_obs_from_geo():
    """geomag.StreamConverter_test.test_get_obs_from_geo()

    The geographic stream containing the traces ''x'', ''y'', ''z'', and
    ''f'' converts to the observatory stream containing the traces
    ''h'', ''d'' or ''e'', ''z'', and ''f''.
    """
    geo = obspy.core.Stream()

    # Call get_geo_from_obs using a decbas of 15, a X stream of
    #   [cos(30), cos(45)], and a Y stream of [sin(30), sin(45)].
    #   Expect a H stream of [cos(15), cos(30)] and a
    #   E stream of [sin(15), sin(30)]
    DECBAS = 15 * D2I
    geo += __create_trace('X', [cos(30 * D2R), cos(45 * D2R)], DECBAS)
    geo += __create_trace('Y', [sin(30 * D2R), sin(45 * D2R)], DECBAS)
    geo += __create_trace('Z', [1, 1], DECBAS)
    geo += __create_trace('F', [1, 1], DECBAS)
    obs = StreamConverter.get_obs_from_geo(geo, True)
    H = obs.select(channel='H')[0].data
    E = obs.select(channel='E')[0].data
    D = obs.select(channel='D')[0].data
    assert_almost_equal(H, [cos(15 * D2R), cos(30 * D2R)], 9,
                        'Expect H to equal [cos(15), cos(30)]', True)
    assert_almost_equal(E, [sin(15 * D2R), sin(30 * D2R)], 9,
                        'Expect E to equal [sin(15), sin(30)', True)
    assert_almost_equal(D, [15 * D2R, 30 * D2R], 9,
                        'Expect D to equal [15 degress, 30 degrees]', True)
示例#3
0
    def process(self, timeseries):
        """converts a timeseries stream into a different coordinate system

        Parameters
        ----------
        informat: string
            indicates the input coordinate system.
        outformat: string
            indicates the output coordinate system.
        out_stream: obspy.core.Stream
            new stream object containing the converted coordinates.
        """
        self.check_stream(timeseries)
        out_stream = None
        if self.outformat == 'geo':
            if self.informat == 'geo':
                out_stream = timeseries
            elif self.informat == 'mag':
                out_stream = StreamConverter.get_geo_from_mag(timeseries)
            elif self.informat == 'obs' or self.informat == 'obsd':
                out_stream = StreamConverter.get_geo_from_obs(timeseries)
        elif self.outformat == 'mag':
            if self.informat == 'geo':
                out_stream = StreamConverter.get_mag_from_geo(timeseries)
            elif self.informat == 'mag':
                out_stream = timeseries
            elif self.informat == 'obs' or self.informat == 'obsd':
                out_stream = StreamConverter.get_mag_from_obs(timeseries)
        elif self.outformat == 'obs':
            if self.informat == 'geo':
                out_stream = StreamConverter.get_obs_from_geo(timeseries)
            elif self.informat == 'mag':
                out_stream = StreamConverter.get_obs_from_mag(timeseries)
            elif self.informat == 'obs' or self.informat == 'obsd':
                out_stream = StreamConverter.get_obs_from_obs(timeseries,
                        include_e=True)
        elif self.outformat == 'obsd':
            if self.informat == 'geo':
                out_stream = StreamConverter.get_obs_from_geo(timeseries,
                        include_d=True)
            elif self.informat == 'mag':
                out_stream = StreamConverter.get_obs_from_mag(timeseries,
                        include_d=True)
            elif self.informat == 'obs' or self.informat == 'obsd':
                out_stream = StreamConverter.get_obs_from_obs(timeseries,
                        include_d=True)
        return out_stream