krischer / instaseis

Instant high-frequency seismograms from an AxiSEM database
http://instaseis.net
Other
51 stars 23 forks source link

Failed instaseis test on scientific linux #38

Closed aringler-usgs closed 8 years ago

aringler-usgs commented 8 years ago

Hello

I was going to try out instaseis, but I am running into some initial install test problems. If this is something I likely messed up please let me know so I can figure out what I am doing wrong. Let me know if you need other information. Thanks for making a program like this available.

Here is a bit of information: [aringler@igskgacggsaslrs instaseis]$ uname -r 3.10.0-327.13.1.el7.x86_64

import obspy obspy.version u'1.0.1' import numpy numpy.version '1.7.1'

[aringler@igskgacggsaslrs instaseis]$ python -m instaseis.tests ============================================================================================ test session starts ============================================================================================ platform linux2 -- Python 2.7.5, pytest-2.9.1, py-1.4.31, pluggy-0.3.1 rootdir: /home/aringler/data_stuff/newsyncomp/instaseis, inifile: collected 334 items

instaseis/tests/test_buffer.py . instaseis/tests/test_code_formatting.py . instaseis/tests/test_instaseis.py ............F.....FF....FF........ instaseis/tests/test_receiver.py ........... instaseis/tests/test_remote_instaseis_db.py ......... instaseis/tests/test_rotations.py .......... instaseis/tests/test_server.py ................................................................................................................................................................................................................ instaseis/tests/test_server_finite_source.py ....FFFFFFFF.............. instaseis/tests/test_source.py ..............F.............. instaseis/tests/test_syngine_instaseis_client.py ... instaseis/tests/test_wrappers.py ..

================================================================================================= FAILURES ================================================================================================== ____ test_finitesource ____

def test_finite_source():
    """
    incremental tests of bwd mode with source force
    """
    from obspy.signal.filter import lowpass
    instaseis_bwd = InstaseisDB(os.path.join(DATA, "100s_db_bwd_displ_only"))

    receiver = Receiver(latitude=42.6390, longitude=74.4940)

    source = Source(
        latitude=89.91, longitude=0.0, depth_in_m=12000,
        m_rr=4.710000e+24 / 1E7,
        m_tt=3.810000e+22 / 1E7,
        m_pp=-4.740000e+24 / 1E7,
        m_rt=3.990000e+23 / 1E7,
        m_rp=-8.050000e+23 / 1E7,
        m_tp=-1.230000e+24 / 1E7)

    dt = instaseis_bwd.info.dt
    sliprate = np.zeros(1000)
    sliprate[0] = 1.
    sliprate = lowpass(sliprate, 1./100., 1./dt, corners=4)

    source.set_sliprate(sliprate, dt, time_shift=0., normalize=True)

    # We can only do a dt that is a clean multiple of the original dt as
    # otherwise we will have small time shifts.
    dt = instaseis_bwd.info.dt / 4
    st_fin = instaseis_bwd.get_seismograms_finite_source(
        sources=[source], receiver=receiver,
        components=('Z', 'N', 'E', 'R', 'T'), dt=dt,
      kernelwidth=1)

instaseis/tests/test_instaseis.py:647:


instaseis/base_instaseis_db.py:429: in get_seismograms_finite_source return_obspy_stream=False, remove_source_shift=False)


self = <instaseis.instaseis_db.InstaseisDB object at 0x7fd0f10>, source = <instaseis.source.Source object at 0x7fd4250>, receiver = <instaseis.source.Receiver object at 0x7fd4210> components = ('Z', 'N', 'E', 'R', 'T'), kind = 'displacement', remove_source_shift = False, reconvolve_stf = True, return_obspy_stream = False, dt = None, kernelwidth = 12

def get_seismograms(self, source, receiver, components=("Z", "N", "E"),
                    kind='displacement', remove_source_shift=True,
                    reconvolve_stf=False, return_obspy_stream=True,
                    dt=None, kernelwidth=12):
    """
        Extract seismograms from the Green's function database.

        :param source: The source definition.
        :type source: :class:`instaseis.source.Source` or
            :class:`instaseis.source.ForceSource`
        :param receiver: The seismic receiver.
        :type receiver: :class:`instaseis.source.Receiver`
        :type components: tuple of str, optional
        :param components: Which components to calculate. Must be a tuple
            containing any combination of ``"Z"``, ``"N"``, ``"E"``,
            ``"R"``, and ``"T"``.
        :type kind: str, optional
        :param kind: The desired units of the seismogram:
            ``"displacement"``, ``"velocity"``, or ``"acceleration"``.
        :type remove_source_shift: bool, optional
        :param remove_source_shift: Cut all samples before the peak of the
            source time function. This has the effect that the first sample
            is the origin time of the source.
        :type reconvolve_stf: bool, optional
        :param reconvolve_stf: Deconvolve the source time function used in
            the AxiSEM run and convolve with the STF attached to the source.
            For this to be stable, the new STF needs to bandlimited.
        :type return_obspy_stream: bool, optional
        :param return_obspy_stream: Return format is either an
            :class:`obspy.core.stream.Stream` object or a dictionary
            containing the raw NumPy arrays.
        :type dt: float, optional
        :param dt: Desired sampling rate of the seismograms. Resampling is done
            using a Lanczos kernel.
        :type kernelwidth: int, optional
        :param kernelwidth: The width of the sinc kernel used for resampling in
            terms of the original sampling interval. Best choose something
            between 10 and 20.

        :returns: Multi component seismograms.
        :rtype: A :class:`obspy.core.stream.Stream` object or a dictionary
            with NumPy arrays as values.
        """
    source, receiver = self._get_seismograms_sanity_checks(
        source=source, receiver=receiver, components=components, kind=kind)

    # Call the _get_seismograms() method of the respective implementation.
    data = self._get_seismograms(source=source, receiver=receiver,
                                 components=components)

    if dt is None:
        dt_out = self.info.dt
    else:
        dt_out = dt

    stf_deconv_map = {
        0: self.info.sliprate,
        1: self.info.slip}

    # Can never be negative with the current logic.
    n_derivative = KIND_MAP[kind] - STF_MAP[self.info.stf]

    if isinstance(source, ForceSource):
        n_derivative += 1

    if reconvolve_stf and remove_source_shift:
        raise ValueError("'remove_source_shift' argument not "
                         "compatible with 'reconvolve_stf'.")

    # Calculate the final time information about the seismograms.
    time_information = _get_seismogram_times(
        info=self.info, origin_time=source.origin_time, dt=dt,
        kernelwidth=kernelwidth, remove_source_shift=remove_source_shift,
        reconvolve_stf=reconvolve_stf)

    for comp in components:
        if reconvolve_stf:
            if source.dt is None or source.sliprate is None:
                raise ValueError("source has no source time function")

            if STF_MAP[self.info.stf] not in [0, 1]:
                raise NotImplementedError(
                    'deconvolution not implemented for stf %s'
                    % (self.info.stf))

            stf_deconv_f = np.fft.rfft(
                stf_deconv_map[STF_MAP[self.info.stf]],
                n=self.info.nfft)

            if abs((source.dt - self.info.dt) / self.info.dt) > 1e-7:
                raise ValueError("dt of the source not compatible")

            stf_conv_f = np.fft.rfft(source.sliprate,
                                     n=self.info.nfft)

            if source.time_shift is not None:
                stf_conv_f *= \
                    np.exp(- 1j * np.fft.rfftfreq(self.info.nfft) *
                         2. * np.pi * source.time_shift / self.info.dt)

E AttributeError: 'module' object has no attribute 'rfftfreq'

instaseis/base_instaseis_db.py:297: AttributeError _ test_time_settings_with_resample_stf[/home/aringler/data_stuff/newsyncomp/instaseis/instaseis/tests/data/100s_dbfwd]

db = <instaseis.instaseis_db.InstaseisDB object at 0x7fc6c10>

@pytest.mark.parametrize("db", DBS)
def test_time_settings_with_resample_stf(db):
    """
    Test the time settings with resampling an stf. In that case the rules
    are pretty simple: The first sample will always be set to the origin time.
    """
    from obspy.signal.filter import lowpass

    origin_time = obspy.UTCDateTime(2015, 1, 1, 1, 1)

    db = InstaseisDB(db)

    receiver = Receiver(latitude=42.6390, longitude=74.4940)
    source = Source(
        latitude=89.91, longitude=0.0, depth_in_m=12000,
        m_rr=4.710000e+24 / 1E7,
        m_tt=3.810000e+22 / 1E7,
        m_pp=-4.740000e+24 / 1E7,
        m_rt=3.990000e+23 / 1E7,
        m_rp=-8.050000e+23 / 1E7,
        m_tp=-1.230000e+24 / 1E7,
        origin_time=origin_time)

    dt = db.info.dt
    sliprate = np.zeros(1000)
    sliprate[0] = 1.
    sliprate = lowpass(sliprate, 1./100., 1./dt, corners=4)

    source.set_sliprate(sliprate, dt, time_shift=0., normalize=True)

    # Using both reconvolve stf and remove source shift results in an error.
    with pytest.raises(ValueError) as err:
        db.get_seismograms(
            source=source, receiver=receiver,
            components=('Z', 'N', 'E', 'R', 'T'), dt=0.1, reconvolve_stf=True,
            remove_source_shift=True)
    assert isinstance(err.value, ValueError)
    assert err.value.args[0] == ("'remove_source_shift' argument not "
                                 "compatible with 'reconvolve_stf'.")

    # No matter the dt, the first sample will always be set to the origin time.
    st = db.get_seismograms(
        source=source, receiver=receiver,
        components=('Z', 'N', 'E', 'R', 'T'), reconvolve_stf=True,
      remove_source_shift=False)

instaseis/tests/test_instaseis.py:920:


self = <instaseis.instaseis_db.InstaseisDB object at 0x7fc6c10>, source = <instaseis.source.Source object at 0x7fd1550>, receiver = <instaseis.source.Receiver object at 0x7fd18d0> components = ('Z', 'N', 'E', 'R', 'T'), kind = 'displacement', remove_source_shift = False, reconvolve_stf = True, return_obspy_stream = True, dt = None, kernelwidth = 12

def get_seismograms(self, source, receiver, components=("Z", "N", "E"),
                    kind='displacement', remove_source_shift=True,
                    reconvolve_stf=False, return_obspy_stream=True,
                    dt=None, kernelwidth=12):
    """
        Extract seismograms from the Green's function database.

        :param source: The source definition.
        :type source: :class:`instaseis.source.Source` or
            :class:`instaseis.source.ForceSource`
        :param receiver: The seismic receiver.
        :type receiver: :class:`instaseis.source.Receiver`
        :type components: tuple of str, optional
        :param components: Which components to calculate. Must be a tuple
            containing any combination of ``"Z"``, ``"N"``, ``"E"``,
            ``"R"``, and ``"T"``.
        :type kind: str, optional
        :param kind: The desired units of the seismogram:
            ``"displacement"``, ``"velocity"``, or ``"acceleration"``.
        :type remove_source_shift: bool, optional
        :param remove_source_shift: Cut all samples before the peak of the
            source time function. This has the effect that the first sample
            is the origin time of the source.
        :type reconvolve_stf: bool, optional
        :param reconvolve_stf: Deconvolve the source time function used in
            the AxiSEM run and convolve with the STF attached to the source.
            For this to be stable, the new STF needs to bandlimited.
        :type return_obspy_stream: bool, optional
        :param return_obspy_stream: Return format is either an
            :class:`obspy.core.stream.Stream` object or a dictionary
            containing the raw NumPy arrays.
        :type dt: float, optional
        :param dt: Desired sampling rate of the seismograms. Resampling is done
            using a Lanczos kernel.
        :type kernelwidth: int, optional
        :param kernelwidth: The width of the sinc kernel used for resampling in
            terms of the original sampling interval. Best choose something
            between 10 and 20.

        :returns: Multi component seismograms.
        :rtype: A :class:`obspy.core.stream.Stream` object or a dictionary
            with NumPy arrays as values.
        """
    source, receiver = self._get_seismograms_sanity_checks(
        source=source, receiver=receiver, components=components, kind=kind)

    # Call the _get_seismograms() method of the respective implementation.
    data = self._get_seismograms(source=source, receiver=receiver,
                                 components=components)

    if dt is None:
        dt_out = self.info.dt
    else:
        dt_out = dt

    stf_deconv_map = {
        0: self.info.sliprate,
        1: self.info.slip}

    # Can never be negative with the current logic.
    n_derivative = KIND_MAP[kind] - STF_MAP[self.info.stf]

    if isinstance(source, ForceSource):
        n_derivative += 1

    if reconvolve_stf and remove_source_shift:
        raise ValueError("'remove_source_shift' argument not "
                         "compatible with 'reconvolve_stf'.")

    # Calculate the final time information about the seismograms.
    time_information = _get_seismogram_times(
        info=self.info, origin_time=source.origin_time, dt=dt,
        kernelwidth=kernelwidth, remove_source_shift=remove_source_shift,
        reconvolve_stf=reconvolve_stf)

    for comp in components:
        if reconvolve_stf:
            if source.dt is None or source.sliprate is None:
                raise ValueError("source has no source time function")

            if STF_MAP[self.info.stf] not in [0, 1]:
                raise NotImplementedError(
                    'deconvolution not implemented for stf %s'
                    % (self.info.stf))

            stf_deconv_f = np.fft.rfft(
                stf_deconv_map[STF_MAP[self.info.stf]],
                n=self.info.nfft)

            if abs((source.dt - self.info.dt) / self.info.dt) > 1e-7:
                raise ValueError("dt of the source not compatible")

            stf_conv_f = np.fft.rfft(source.sliprate,
                                     n=self.info.nfft)

            if source.time_shift is not None:
                stf_conv_f *= \
                    np.exp(- 1j * np.fft.rfftfreq(self.info.nfft) *
                         2. * np.pi * source.time_shift / self.info.dt)

E AttributeError: 'module' object has no attribute 'rfftfreq'

instaseis/base_instaseisdb.py:297: AttributeError ____ test_time_settings_with_resample_stf[/home/aringler/data_stuff/newsyncomp/instaseis/instaseis/tests/data/100s_db_bwd_displ_only] __

db = <instaseis.instaseis_db.InstaseisDB object at 0x7faba50>

@pytest.mark.parametrize("db", DBS)
def test_time_settings_with_resample_stf(db):
    """
    Test the time settings with resampling an stf. In that case the rules
    are pretty simple: The first sample will always be set to the origin time.
    """
    from obspy.signal.filter import lowpass

    origin_time = obspy.UTCDateTime(2015, 1, 1, 1, 1)

    db = InstaseisDB(db)

    receiver = Receiver(latitude=42.6390, longitude=74.4940)
    source = Source(
        latitude=89.91, longitude=0.0, depth_in_m=12000,
        m_rr=4.710000e+24 / 1E7,
        m_tt=3.810000e+22 / 1E7,
        m_pp=-4.740000e+24 / 1E7,
        m_rt=3.990000e+23 / 1E7,
        m_rp=-8.050000e+23 / 1E7,
        m_tp=-1.230000e+24 / 1E7,
        origin_time=origin_time)

    dt = db.info.dt
    sliprate = np.zeros(1000)
    sliprate[0] = 1.
    sliprate = lowpass(sliprate, 1./100., 1./dt, corners=4)

    source.set_sliprate(sliprate, dt, time_shift=0., normalize=True)

    # Using both reconvolve stf and remove source shift results in an error.
    with pytest.raises(ValueError) as err:
        db.get_seismograms(
            source=source, receiver=receiver,
            components=('Z', 'N', 'E', 'R', 'T'), dt=0.1, reconvolve_stf=True,
            remove_source_shift=True)
    assert isinstance(err.value, ValueError)
    assert err.value.args[0] == ("'remove_source_shift' argument not "
                                 "compatible with 'reconvolve_stf'.")

    # No matter the dt, the first sample will always be set to the origin time.
    st = db.get_seismograms(
        source=source, receiver=receiver,
        components=('Z', 'N', 'E', 'R', 'T'), reconvolve_stf=True,
      remove_source_shift=False)

instaseis/tests/test_instaseis.py:920:


self = <instaseis.instaseis_db.InstaseisDB object at 0x7faba50>, source = <instaseis.source.Source object at 0x7fa9ed0>, receiver = <instaseis.source.Receiver object at 0x7fa9fd0> components = ('Z', 'N', 'E', 'R', 'T'), kind = 'displacement', remove_source_shift = False, reconvolve_stf = True, return_obspy_stream = True, dt = None, kernelwidth = 12

def get_seismograms(self, source, receiver, components=("Z", "N", "E"),
                    kind='displacement', remove_source_shift=True,
                    reconvolve_stf=False, return_obspy_stream=True,
                    dt=None, kernelwidth=12):
    """
        Extract seismograms from the Green's function database.

        :param source: The source definition.
        :type source: :class:`instaseis.source.Source` or
            :class:`instaseis.source.ForceSource`
        :param receiver: The seismic receiver.
        :type receiver: :class:`instaseis.source.Receiver`
        :type components: tuple of str, optional
        :param components: Which components to calculate. Must be a tuple
            containing any combination of ``"Z"``, ``"N"``, ``"E"``,
            ``"R"``, and ``"T"``.
        :type kind: str, optional
        :param kind: The desired units of the seismogram:
            ``"displacement"``, ``"velocity"``, or ``"acceleration"``.
        :type remove_source_shift: bool, optional
        :param remove_source_shift: Cut all samples before the peak of the
            source time function. This has the effect that the first sample
            is the origin time of the source.
        :type reconvolve_stf: bool, optional
        :param reconvolve_stf: Deconvolve the source time function used in
            the AxiSEM run and convolve with the STF attached to the source.
            For this to be stable, the new STF needs to bandlimited.
        :type return_obspy_stream: bool, optional
        :param return_obspy_stream: Return format is either an
            :class:`obspy.core.stream.Stream` object or a dictionary
            containing the raw NumPy arrays.
        :type dt: float, optional
        :param dt: Desired sampling rate of the seismograms. Resampling is done
            using a Lanczos kernel.
        :type kernelwidth: int, optional
        :param kernelwidth: The width of the sinc kernel used for resampling in
            terms of the original sampling interval. Best choose something
            between 10 and 20.

        :returns: Multi component seismograms.
        :rtype: A :class:`obspy.core.stream.Stream` object or a dictionary
            with NumPy arrays as values.
        """
    source, receiver = self._get_seismograms_sanity_checks(
        source=source, receiver=receiver, components=components, kind=kind)

    # Call the _get_seismograms() method of the respective implementation.
    data = self._get_seismograms(source=source, receiver=receiver,
                                 components=components)

    if dt is None:
        dt_out = self.info.dt
    else:
        dt_out = dt

    stf_deconv_map = {
        0: self.info.sliprate,
        1: self.info.slip}

    # Can never be negative with the current logic.
    n_derivative = KIND_MAP[kind] - STF_MAP[self.info.stf]

    if isinstance(source, ForceSource):
        n_derivative += 1

    if reconvolve_stf and remove_source_shift:
        raise ValueError("'remove_source_shift' argument not "
                         "compatible with 'reconvolve_stf'.")

    # Calculate the final time information about the seismograms.
    time_information = _get_seismogram_times(
        info=self.info, origin_time=source.origin_time, dt=dt,
        kernelwidth=kernelwidth, remove_source_shift=remove_source_shift,
        reconvolve_stf=reconvolve_stf)

    for comp in components:
        if reconvolve_stf:
            if source.dt is None or source.sliprate is None:
                raise ValueError("source has no source time function")

            if STF_MAP[self.info.stf] not in [0, 1]:
                raise NotImplementedError(
                    'deconvolution not implemented for stf %s'
                    % (self.info.stf))

            stf_deconv_f = np.fft.rfft(
                stf_deconv_map[STF_MAP[self.info.stf]],
                n=self.info.nfft)

            if abs((source.dt - self.info.dt) / self.info.dt) > 1e-7:
                raise ValueError("dt of the source not compatible")

            stf_conv_f = np.fft.rfft(source.sliprate,
                                     n=self.info.nfft)

            if source.time_shift is not None:
                stf_conv_f *= \
                    np.exp(- 1j * np.fft.rfftfreq(self.info.nfft) *
                         2. * np.pi * source.time_shift / self.info.dt)

E AttributeError: 'module' object has no attribute 'rfftfreq'

instaseis/base_instaseisdb.py:297: AttributeError ____ test_get_time_information_reconvolve_stf[/home/aringler/data_stuff/newsyncomp/instaseis/instaseis/tests/data/100s_dbfwd] ____

db = <instaseis.instaseis_db.InstaseisDB object at 0x7ab4f10>

@pytest.mark.parametrize("db", DBS)
def test_get_time_information_reconvolve_stf(db):
    """
    Tests the _get_seismogram_times() function but with reconvolve_stf = True.
    In that case time shifts and what not are no longer applied.
    """
    from obspy.signal.filter import lowpass
    db = InstaseisDB(db)

    origin_time = obspy.UTCDateTime(2015, 1, 1, 1, 1)

    source = Source(latitude=4., longitude=3.0, depth_in_m=0,
                    m_rr=4.71e+17, m_tt=3.81e+17, m_pp=-4.74e+17,
                    m_rt=3.99e+17, m_rp=-8.05e+17, m_tp=-1.23e+17,
                    origin_time=origin_time)
    receiver = Receiver(latitude=10., longitude=20., depth_in_m=0)
    dt = db.info.dt
    sliprate = np.zeros(1000)
    sliprate[0] = 1.
    sliprate = lowpass(sliprate, 1./100., 1./dt, corners=4)

    source.set_sliprate(sliprate, dt, time_shift=0., normalize=True)

    # remove_source_shift and reconvolve_stf cannot be true at the same time.
    par = {"remove_source_shift": True,
           "reconvolve_stf": True,
           "dt": None,
           "kernelwidth": 5}
    with pytest.raises(ValueError) as err:
        _get_seismogram_times(info=db.info, origin_time=origin_time, **par)
    assert err.value.args[0] == (
        "'remove_source_shift' argument not compatible with 'reconvolve_stf'.")

    par = {"remove_source_shift": False,
           "reconvolve_stf": True,
           "dt": None,
           "kernelwidth": 5}
    tr = db.get_seismograms(source=source, receiver=receiver,
                          components=["Z"], **par)[0]

instaseis/tests/test_instaseis.py:1254:


self = <instaseis.instaseis_db.InstaseisDB object at 0x7ab4f10>, source = <instaseis.source.Source object at 0x787a4d0>, receiver = <instaseis.source.Receiver object at 0x787a5d0>, components = ['Z'] kind = 'displacement', remove_source_shift = False, reconvolve_stf = True, return_obspy_stream = True, dt = None, kernelwidth = 5

def get_seismograms(self, source, receiver, components=("Z", "N", "E"),
                    kind='displacement', remove_source_shift=True,
                    reconvolve_stf=False, return_obspy_stream=True,
                    dt=None, kernelwidth=12):
    """
        Extract seismograms from the Green's function database.

        :param source: The source definition.
        :type source: :class:`instaseis.source.Source` or
            :class:`instaseis.source.ForceSource`
        :param receiver: The seismic receiver.
        :type receiver: :class:`instaseis.source.Receiver`
        :type components: tuple of str, optional
        :param components: Which components to calculate. Must be a tuple
            containing any combination of ``"Z"``, ``"N"``, ``"E"``,
            ``"R"``, and ``"T"``.
        :type kind: str, optional
        :param kind: The desired units of the seismogram:
            ``"displacement"``, ``"velocity"``, or ``"acceleration"``.
        :type remove_source_shift: bool, optional
        :param remove_source_shift: Cut all samples before the peak of the
            source time function. This has the effect that the first sample
            is the origin time of the source.
        :type reconvolve_stf: bool, optional
        :param reconvolve_stf: Deconvolve the source time function used in
            the AxiSEM run and convolve with the STF attached to the source.
            For this to be stable, the new STF needs to bandlimited.
        :type return_obspy_stream: bool, optional
        :param return_obspy_stream: Return format is either an
            :class:`obspy.core.stream.Stream` object or a dictionary
            containing the raw NumPy arrays.
        :type dt: float, optional
        :param dt: Desired sampling rate of the seismograms. Resampling is done
            using a Lanczos kernel.
        :type kernelwidth: int, optional
        :param kernelwidth: The width of the sinc kernel used for resampling in
            terms of the original sampling interval. Best choose something
            between 10 and 20.

        :returns: Multi component seismograms.
        :rtype: A :class:`obspy.core.stream.Stream` object or a dictionary
            with NumPy arrays as values.
        """
    source, receiver = self._get_seismograms_sanity_checks(
        source=source, receiver=receiver, components=components, kind=kind)

    # Call the _get_seismograms() method of the respective implementation.
    data = self._get_seismograms(source=source, receiver=receiver,
                                 components=components)

    if dt is None:
        dt_out = self.info.dt
    else:
        dt_out = dt

    stf_deconv_map = {
        0: self.info.sliprate,
        1: self.info.slip}

    # Can never be negative with the current logic.
    n_derivative = KIND_MAP[kind] - STF_MAP[self.info.stf]

    if isinstance(source, ForceSource):
        n_derivative += 1

    if reconvolve_stf and remove_source_shift:
        raise ValueError("'remove_source_shift' argument not "
                         "compatible with 'reconvolve_stf'.")

    # Calculate the final time information about the seismograms.
    time_information = _get_seismogram_times(
        info=self.info, origin_time=source.origin_time, dt=dt,
        kernelwidth=kernelwidth, remove_source_shift=remove_source_shift,
        reconvolve_stf=reconvolve_stf)

    for comp in components:
        if reconvolve_stf:
            if source.dt is None or source.sliprate is None:
                raise ValueError("source has no source time function")

            if STF_MAP[self.info.stf] not in [0, 1]:
                raise NotImplementedError(
                    'deconvolution not implemented for stf %s'
                    % (self.info.stf))

            stf_deconv_f = np.fft.rfft(
                stf_deconv_map[STF_MAP[self.info.stf]],
                n=self.info.nfft)

            if abs((source.dt - self.info.dt) / self.info.dt) > 1e-7:
                raise ValueError("dt of the source not compatible")

            stf_conv_f = np.fft.rfft(source.sliprate,
                                     n=self.info.nfft)

            if source.time_shift is not None:
                stf_conv_f *= \
                    np.exp(- 1j * np.fft.rfftfreq(self.info.nfft) *
                         2. * np.pi * source.time_shift / self.info.dt)

E AttributeError: 'module' object has no attribute 'rfftfreq'

instaseis/base_instaseis_db.py:297: AttributeError ___ test_get_time_information_reconvolve_stf[/home/aringler/data_stuff/newsyncomp/instaseis/instaseis/tests/data/100s_db_bwd_displ_only] ____

db = <instaseis.instaseis_db.InstaseisDB object at 0x584eed0>

@pytest.mark.parametrize("db", DBS)
def test_get_time_information_reconvolve_stf(db):
    """
    Tests the _get_seismogram_times() function but with reconvolve_stf = True.
    In that case time shifts and what not are no longer applied.
    """
    from obspy.signal.filter import lowpass
    db = InstaseisDB(db)

    origin_time = obspy.UTCDateTime(2015, 1, 1, 1, 1)

    source = Source(latitude=4., longitude=3.0, depth_in_m=0,
                    m_rr=4.71e+17, m_tt=3.81e+17, m_pp=-4.74e+17,
                    m_rt=3.99e+17, m_rp=-8.05e+17, m_tp=-1.23e+17,
                    origin_time=origin_time)
    receiver = Receiver(latitude=10., longitude=20., depth_in_m=0)
    dt = db.info.dt
    sliprate = np.zeros(1000)
    sliprate[0] = 1.
    sliprate = lowpass(sliprate, 1./100., 1./dt, corners=4)

    source.set_sliprate(sliprate, dt, time_shift=0., normalize=True)

    # remove_source_shift and reconvolve_stf cannot be true at the same time.
    par = {"remove_source_shift": True,
           "reconvolve_stf": True,
           "dt": None,
           "kernelwidth": 5}
    with pytest.raises(ValueError) as err:
        _get_seismogram_times(info=db.info, origin_time=origin_time, **par)
    assert err.value.args[0] == (
        "'remove_source_shift' argument not compatible with 'reconvolve_stf'.")

    par = {"remove_source_shift": False,
           "reconvolve_stf": True,
           "dt": None,
           "kernelwidth": 5}
    tr = db.get_seismograms(source=source, receiver=receiver,
                          components=["Z"], **par)[0]

instaseis/tests/test_instaseis.py:1254:


self = <instaseis.instaseis_db.InstaseisDB object at 0x584eed0>, source = <instaseis.source.Source object at 0x58fff50>, receiver = <instaseis.source.Receiver object at 0x58ffc50>, components = ['Z'] kind = 'displacement', remove_source_shift = False, reconvolve_stf = True, return_obspy_stream = True, dt = None, kernelwidth = 5

def get_seismograms(self, source, receiver, components=("Z", "N", "E"),
                    kind='displacement', remove_source_shift=True,
                    reconvolve_stf=False, return_obspy_stream=True,
                    dt=None, kernelwidth=12):
    """
        Extract seismograms from the Green's function database.

        :param source: The source definition.
        :type source: :class:`instaseis.source.Source` or
            :class:`instaseis.source.ForceSource`
        :param receiver: The seismic receiver.
        :type receiver: :class:`instaseis.source.Receiver`
        :type components: tuple of str, optional
        :param components: Which components to calculate. Must be a tuple
            containing any combination of ``"Z"``, ``"N"``, ``"E"``,
            ``"R"``, and ``"T"``.
        :type kind: str, optional
        :param kind: The desired units of the seismogram:
            ``"displacement"``, ``"velocity"``, or ``"acceleration"``.
        :type remove_source_shift: bool, optional
        :param remove_source_shift: Cut all samples before the peak of the
            source time function. This has the effect that the first sample
            is the origin time of the source.
        :type reconvolve_stf: bool, optional
        :param reconvolve_stf: Deconvolve the source time function used in
            the AxiSEM run and convolve with the STF attached to the source.
            For this to be stable, the new STF needs to bandlimited.
        :type return_obspy_stream: bool, optional
        :param return_obspy_stream: Return format is either an
            :class:`obspy.core.stream.Stream` object or a dictionary
            containing the raw NumPy arrays.
        :type dt: float, optional
        :param dt: Desired sampling rate of the seismograms. Resampling is done
            using a Lanczos kernel.
        :type kernelwidth: int, optional
        :param kernelwidth: The width of the sinc kernel used for resampling in
            terms of the original sampling interval. Best choose something
            between 10 and 20.

        :returns: Multi component seismograms.
        :rtype: A :class:`obspy.core.stream.Stream` object or a dictionary
            with NumPy arrays as values.
        """
    source, receiver = self._get_seismograms_sanity_checks(
        source=source, receiver=receiver, components=components, kind=kind)

    # Call the _get_seismograms() method of the respective implementation.
    data = self._get_seismograms(source=source, receiver=receiver,
                                 components=components)

    if dt is None:
        dt_out = self.info.dt
    else:
        dt_out = dt

    stf_deconv_map = {
        0: self.info.sliprate,
        1: self.info.slip}

    # Can never be negative with the current logic.
    n_derivative = KIND_MAP[kind] - STF_MAP[self.info.stf]

    if isinstance(source, ForceSource):
        n_derivative += 1

    if reconvolve_stf and remove_source_shift:
        raise ValueError("'remove_source_shift' argument not "
                         "compatible with 'reconvolve_stf'.")

    # Calculate the final time information about the seismograms.
    time_information = _get_seismogram_times(
        info=self.info, origin_time=source.origin_time, dt=dt,
        kernelwidth=kernelwidth, remove_source_shift=remove_source_shift,
        reconvolve_stf=reconvolve_stf)

    for comp in components:
        if reconvolve_stf:
            if source.dt is None or source.sliprate is None:
                raise ValueError("source has no source time function")

            if STF_MAP[self.info.stf] not in [0, 1]:
                raise NotImplementedError(
                    'deconvolution not implemented for stf %s'
                    % (self.info.stf))

            stf_deconv_f = np.fft.rfft(
                stf_deconv_map[STF_MAP[self.info.stf]],
                n=self.info.nfft)

            if abs((source.dt - self.info.dt) / self.info.dt) > 1e-7:
                raise ValueError("dt of the source not compatible")

            stf_conv_f = np.fft.rfft(source.sliprate,
                                     n=self.info.nfft)

            if source.time_shift is not None:
                stf_conv_f *= \
                    np.exp(- 1j * np.fft.rfftfreq(self.info.nfft) *
                         2. * np.pi * source.time_shift / self.info.dt)

E AttributeError: 'module' object has no attribute 'rfftfreq'

instaseis/base_instaseisdb.py:297: AttributeError test_finite_source_retrieval[/home/aringler/data_stuff/newsyncomp/instaseis/instaseis/tests/data/100s_db_bwd_displ_only-/home/aringler/data_stuff/newsyncomp/instaseis/instaseis/tests/data/nepal.param] __

reciprocal_clients = <instaseis.tests.tornado_testing_fixtures.AsyncClient object at 0xa863490>, usgs_param = '/home/aringler/data_stuff/newsyncomp/instaseis/instaseis/tests/data/nepal.param'

@pytest.mark.parametrize("usgs_param", [USGS_PARAM_FILE_1, USGS_PARAM_FILE_2])
def test_finite_source_retrieval(reciprocal_clients, usgs_param):
    """
    Tests if the finite sources requested from the server are identical to
    the one requested with the local instaseis client with some required
    tweaks.
    """
    client = reciprocal_clients

    db = instaseis.open_db(client.filepath)

    basic_parameters = {
        "receiverlongitude": 11,
        "receiverlatitude": 22,
        "receiverdepthinmeters": 0,
        "format": "miniseed"}

    with io.open(usgs_param, "rb") as fh:
        body = fh.read()

    # default parameters
    params = copy.deepcopy(basic_parameters)
    request = client.fetch(_assemble_url('finite_source', **params),
                           method="POST", body=body)
  assert request.code == 200

E assert 400 == 200 E + where 400 = HTTPResponse(_body=None,buffer=<_io.BytesIO object at 0xa841890>,code=400,effe...client.HTTPRequest object at 0xa863d10>,request_time=1.1474609375,time_info={}).code

instaseis/tests/test_server_finite_source.py:140: AssertionError ------------------------------------------------------------------------------------------- Captured stderr call -------------------------------------------------------------------------------------------- WARNING:tornado.general:400 POST /finite_source?format=miniseed&receiverlongitude=11&receiverdepthinmeters=0&receiverlatitude=22 (127.0.0.1): Could not extract finite source seismograms. Make sure, the parameters are valid, and the depth settings are correct. WARNING:tornado.access:400 POST /finitesource?format=miniseed&receiverlongitude=11&receiverdepthinmeters=0&receiverlatitude=22 (127.0.0.1) 1144.13ms test_finite_source_retrieval[/home/aringler/data_stuff/newsyncomp/instaseis/instaseis/tests/data/100s_db_bwd_displ_only-/home/aringler/data_stuff/newsyncomp/instaseis/instaseis/tests/data/chile.param] __

reciprocal_clients = <instaseis.tests.tornado_testing_fixtures.AsyncClient object at 0xa83f510>, usgs_param = '/home/aringler/data_stuff/newsyncomp/instaseis/instaseis/tests/data/chile.param'

@pytest.mark.parametrize("usgs_param", [USGS_PARAM_FILE_1, USGS_PARAM_FILE_2])
def test_finite_source_retrieval(reciprocal_clients, usgs_param):
    """
    Tests if the finite sources requested from the server are identical to
    the one requested with the local instaseis client with some required
    tweaks.
    """
    client = reciprocal_clients

    db = instaseis.open_db(client.filepath)

    basic_parameters = {
        "receiverlongitude": 11,
        "receiverlatitude": 22,
        "receiverdepthinmeters": 0,
        "format": "miniseed"}

    with io.open(usgs_param, "rb") as fh:
        body = fh.read()

    # default parameters
    params = copy.deepcopy(basic_parameters)
    request = client.fetch(_assemble_url('finite_source', **params),
                           method="POST", body=body)
  assert request.code == 200

E assert 400 == 200 E + where 400 = HTTPResponse(_body=None,buffer=<_io.BytesIO object at 0xa86b5f0>,code=400,effe....HTTPRequest object at 0xa83ee10>,request_time=3.4118309020996094,time_info={}).code

instaseis/tests/test_server_finite_source.py:140: AssertionError ------------------------------------------------------------------------------------------- Captured stderr call -------------------------------------------------------------------------------------------- WARNING:tornado.general:400 POST /finite_source?format=miniseed&receiverlongitude=11&receiverdepthinmeters=0&receiverlatitude=22 (127.0.0.1): Could not extract finite source seismograms. Make sure, the parameters are valid, and the depth settings are correct. WARNING:tornado.access:400 POST /finitesource?format=miniseed&receiverlongitude=11&receiverdepthinmeters=0&receiverlatitude=22 (127.0.0.1) 3408.37ms test_finite_source_retrieval[/home/aringler/data_stuff/newsyncomp/instaseis/instaseis/tests/data/100s_db_bwd_strain_only-/home/aringler/datastuff/newsyncomp/instaseis/instaseis/tests/data/nepal.param]

reciprocal_clients = <instaseis.tests.tornado_testing_fixtures.AsyncClient object at 0xa856d50>, usgs_param = '/home/aringler/data_stuff/newsyncomp/instaseis/instaseis/tests/data/nepal.param'

@pytest.mark.parametrize("usgs_param", [USGS_PARAM_FILE_1, USGS_PARAM_FILE_2])
def test_finite_source_retrieval(reciprocal_clients, usgs_param):
    """
    Tests if the finite sources requested from the server are identical to
    the one requested with the local instaseis client with some required
    tweaks.
    """
    client = reciprocal_clients

    db = instaseis.open_db(client.filepath)

    basic_parameters = {
        "receiverlongitude": 11,
        "receiverlatitude": 22,
        "receiverdepthinmeters": 0,
        "format": "miniseed"}

    with io.open(usgs_param, "rb") as fh:
        body = fh.read()

    # default parameters
    params = copy.deepcopy(basic_parameters)
    request = client.fetch(_assemble_url('finite_source', **params),
                           method="POST", body=body)
  assert request.code == 200

E assert 400 == 200 E + where 400 = HTTPResponse(_body=None,buffer=<_io.BytesIO object at 0xa86b7d0>,code=400,effe....HTTPRequest object at 0xa83f110>,request_time=1.1254010200500488,time_info={}).code

instaseis/tests/test_server_finite_source.py:140: AssertionError ------------------------------------------------------------------------------------------- Captured stderr call -------------------------------------------------------------------------------------------- WARNING:tornado.general:400 POST /finite_source?format=miniseed&receiverlongitude=11&receiverdepthinmeters=0&receiverlatitude=22 (127.0.0.1): Could not extract finite source seismograms. Make sure, the parameters are valid, and the depth settings are correct. WARNING:tornado.access:400 POST /finitesource?format=miniseed&receiverlongitude=11&receiverdepthinmeters=0&receiverlatitude=22 (127.0.0.1) 1122.37ms test_finite_source_retrieval[/home/aringler/data_stuff/newsyncomp/instaseis/instaseis/tests/data/100s_db_bwd_strain_only-/home/aringler/datastuff/newsyncomp/instaseis/instaseis/tests/data/chile.param]

reciprocal_clients = <instaseis.tests.tornado_testing_fixtures.AsyncClient object at 0xa86f690>, usgs_param = '/home/aringler/data_stuff/newsyncomp/instaseis/instaseis/tests/data/chile.param'

@pytest.mark.parametrize("usgs_param", [USGS_PARAM_FILE_1, USGS_PARAM_FILE_2])
def test_finite_source_retrieval(reciprocal_clients, usgs_param):
    """
    Tests if the finite sources requested from the server are identical to
    the one requested with the local instaseis client with some required
    tweaks.
    """
    client = reciprocal_clients

    db = instaseis.open_db(client.filepath)

    basic_parameters = {
        "receiverlongitude": 11,
        "receiverlatitude": 22,
        "receiverdepthinmeters": 0,
        "format": "miniseed"}

    with io.open(usgs_param, "rb") as fh:
        body = fh.read()

    # default parameters
    params = copy.deepcopy(basic_parameters)
    request = client.fetch(_assemble_url('finite_source', **params),
                           method="POST", body=body)
  assert request.code == 200

E assert 400 == 200 E + where 400 = HTTPResponse(_body=None,buffer=<_io.BytesIO object at 0xa86ba10>,code=400,effe....HTTPRequest object at 0xa86fa50>,request_time=3.3807060718536377,time_info={}).code

instaseis/tests/test_server_finite_source.py:140: AssertionError ------------------------------------------------------------------------------------------- Captured stderr call -------------------------------------------------------------------------------------------- WARNING:tornado.general:400 POST /finite_source?format=miniseed&receiverlongitude=11&receiverdepthinmeters=0&receiverlatitude=22 (127.0.0.1): Could not extract finite source seismograms. Make sure, the parameters are valid, and the depth settings are correct. WARNING:tornado.access:400 POST /finite_source?format=miniseed&receiverlongitude=11&receiverdepthinmeters=0&receiverlatitude=22 (127.0.0.1) 3377.16ms _ test_more_complex_queries[/home/aringler/data_stuff/newsyncomp/instaseis/instaseis/tests/data/100s_db_bwd_displ_only-/home/aringler/datastuff/newsyncomp/instaseis/instaseis/tests/data/nepal.param]

reciprocal_clients_all_callbacks = <instaseis.tests.tornado_testing_fixtures.AsyncClient object at 0xa879a10>, usgs_param = '/home/aringler/data_stuff/newsyncomp/instaseis/instaseis/tests/data/nepal.param'

@pytest.mark.parametrize("usgs_param", [USGS_PARAM_FILE_1, USGS_PARAM_FILE_2])
def test_more_complex_queries(reciprocal_clients_all_callbacks,
                              usgs_param):
    """
    These are not exhaustive tests but test that the queries do something.
    Elsewhere they are tested in more details.

    Test phase relative offsets.

    + must be encoded with %2B
    - must be encoded with %2D
    """
    client = reciprocal_clients_all_callbacks

    basic_parameters = {
        "receiverlongitude": 11,
        "receiverlatitude": 22,
        "components": "Z",
        "format": "miniseed"}

    with io.open(usgs_param, "rb") as fh:
        body = fh.read()

    # default parameters
    params = copy.deepcopy(basic_parameters)
    params["dt"] = 2
    request = client.fetch(_assemble_url('finite_source', **params),
                           method="POST", body=body)
  assert request.code == 200

E assert 400 == 200 E + where 400 = HTTPResponse(_body=None,buffer=<_io.BytesIO object at 0xa86bb30>,code=400,effe....HTTPRequest object at 0xa84ab10>,request_time=0.9981319904327393,time_info={}).code

instaseis/tests/test_server_finite_source.py:384: AssertionError ------------------------------------------------------------------------------------------- Captured stderr call -------------------------------------------------------------------------------------------- WARNING:tornado.general:400 POST /finite_source?format=miniseed&dt=2&receiverlongitude=11&components=Z&receiverlatitude=22 (127.0.0.1): Could not extract finite source seismograms. Make sure, the parameters are valid, and the depth settings are correct. WARNING:tornado.access:400 POST /finite_source?format=miniseed&dt=2&receiverlongitude=11&components=Z&receiverlatitude=22 (127.0.0.1) 995.37ms _ test_more_complex_queries[/home/aringler/data_stuff/newsyncomp/instaseis/instaseis/tests/data/100s_db_bwd_displ_only-/home/aringler/datastuff/newsyncomp/instaseis/instaseis/tests/data/chile.param]

reciprocal_clients_all_callbacks = <instaseis.tests.tornado_testing_fixtures.AsyncClient object at 0xa86ff50>, usgs_param = '/home/aringler/data_stuff/newsyncomp/instaseis/instaseis/tests/data/chile.param'

@pytest.mark.parametrize("usgs_param", [USGS_PARAM_FILE_1, USGS_PARAM_FILE_2])
def test_more_complex_queries(reciprocal_clients_all_callbacks,
                              usgs_param):
    """
    These are not exhaustive tests but test that the queries do something.
    Elsewhere they are tested in more details.

    Test phase relative offsets.

    + must be encoded with %2B
    - must be encoded with %2D
    """
    client = reciprocal_clients_all_callbacks

    basic_parameters = {
        "receiverlongitude": 11,
        "receiverlatitude": 22,
        "components": "Z",
        "format": "miniseed"}

    with io.open(usgs_param, "rb") as fh:
        body = fh.read()

    # default parameters
    params = copy.deepcopy(basic_parameters)
    params["dt"] = 2
    request = client.fetch(_assemble_url('finite_source', **params),
                           method="POST", body=body)
  assert request.code == 200

E assert 400 == 200 E + where 400 = HTTPResponse(_body=None,buffer=<_io.BytesIO object at 0xa86bd10>,code=400,effe...t.HTTPRequest object at 0xa83f910>,request_time=3.368098020553589,time_info={}).code

instaseis/tests/test_server_finite_source.py:384: AssertionError ------------------------------------------------------------------------------------------- Captured stderr call -------------------------------------------------------------------------------------------- WARNING:tornado.general:400 POST /finite_source?format=miniseed&dt=2&receiverlongitude=11&components=Z&receiverlatitude=22 (127.0.0.1): Could not extract finite source seismograms. Make sure, the parameters are valid, and the depth settings are correct. WARNING:tornado.access:400 POST /finite_source?format=miniseed&dt=2&receiverlongitude=11&components=Z&receiverlatitude=22 (127.0.0.1) 3364.18ms test_more_complex_queries[/home/aringler/data_stuff/newsyncomp/instaseis/instaseis/tests/data/100s_db_bwd_strain_only-/home/aringler/datastuff/newsyncomp/instaseis/instaseis/tests/data/nepal.param]

reciprocal_clients_all_callbacks = <instaseis.tests.tornado_testing_fixtures.AsyncClient object at 0xa86f910>, usgs_param = '/home/aringler/data_stuff/newsyncomp/instaseis/instaseis/tests/data/nepal.param'

@pytest.mark.parametrize("usgs_param", [USGS_PARAM_FILE_1, USGS_PARAM_FILE_2])
def test_more_complex_queries(reciprocal_clients_all_callbacks,
                              usgs_param):
    """
    These are not exhaustive tests but test that the queries do something.
    Elsewhere they are tested in more details.

    Test phase relative offsets.

    + must be encoded with %2B
    - must be encoded with %2D
    """
    client = reciprocal_clients_all_callbacks

    basic_parameters = {
        "receiverlongitude": 11,
        "receiverlatitude": 22,
        "components": "Z",
        "format": "miniseed"}

    with io.open(usgs_param, "rb") as fh:
        body = fh.read()

    # default parameters
    params = copy.deepcopy(basic_parameters)
    params["dt"] = 2
    request = client.fetch(_assemble_url('finite_source', **params),
                           method="POST", body=body)
  assert request.code == 200

E assert 400 == 200 E + where 400 = HTTPResponse(_body=None,buffer=<_io.BytesIO object at 0xa874bf0>,code=400,effe....HTTPRequest object at 0xa405050>,request_time=1.0368800163269043,time_info={}).code

instaseis/tests/test_server_finite_source.py:384: AssertionError ------------------------------------------------------------------------------------------- Captured stderr call -------------------------------------------------------------------------------------------- WARNING:tornado.general:400 POST /finite_source?format=miniseed&dt=2&receiverlongitude=11&components=Z&receiverlatitude=22 (127.0.0.1): Could not extract finite source seismograms. Make sure, the parameters are valid, and the depth settings are correct. WARNING:tornado.access:400 POST /finite_source?format=miniseed&dt=2&receiverlongitude=11&components=Z&receiverlatitude=22 (127.0.0.1) 1032.88ms test_more_complex_queries[/home/aringler/data_stuff/newsyncomp/instaseis/instaseis/tests/data/100s_db_bwd_strain_only-/home/aringler/datastuff/newsyncomp/instaseis/instaseis/tests/data/chile.param]

reciprocal_clients_all_callbacks = <instaseis.tests.tornado_testing_fixtures.AsyncClient object at 0xa8575d0>, usgs_param = '/home/aringler/data_stuff/newsyncomp/instaseis/instaseis/tests/data/chile.param'

@pytest.mark.parametrize("usgs_param", [USGS_PARAM_FILE_1, USGS_PARAM_FILE_2])
def test_more_complex_queries(reciprocal_clients_all_callbacks,
                              usgs_param):
    """
    These are not exhaustive tests but test that the queries do something.
    Elsewhere they are tested in more details.

    Test phase relative offsets.

    + must be encoded with %2B
    - must be encoded with %2D
    """
    client = reciprocal_clients_all_callbacks

    basic_parameters = {
        "receiverlongitude": 11,
        "receiverlatitude": 22,
        "components": "Z",
        "format": "miniseed"}

    with io.open(usgs_param, "rb") as fh:
        body = fh.read()

    # default parameters
    params = copy.deepcopy(basic_parameters)
    params["dt"] = 2
    request = client.fetch(_assemble_url('finite_source', **params),
                           method="POST", body=body)
  assert request.code == 200

E assert 400 == 200 E + where 400 = HTTPResponse(_body=None,buffer=<_io.BytesIO object at 0xa874f50>,code=400,effe....HTTPRequest object at 0xa83e950>,request_time=3.2786619663238525,time_info={}).code

instaseis/tests/test_server_finite_source.py:384: AssertionError ------------------------------------------------------------------------------------------- Captured stderr call -------------------------------------------------------------------------------------------- WARNING:tornado.general:400 POST /finite_source?format=miniseed&dt=2&receiverlongitude=11&components=Z&receiverlatitude=22 (127.0.0.1): Could not extract finite source seismograms. Make sure, the parameters are valid, and the depth settings are correct. WARNING:tornado.access:400 POST /finite_source?format=miniseed&dt=2&receiverlongitude=11&components=Z&receiverlatitude=22 (127.0.0.1) 3273.61ms __ test_CMT_finite_source ___

def test_CMT_finite_source():
    """
    Tests computation of CMT solution
    """
    finitesource = FiniteSource.from_srf_file(SRF_FILE, True)
  finitesource.compute_centroid()

instaseis/tests/test_source.py:329:


self = <instaseis.source.FiniteSource object at 0x8edf050>, planet_radius = 6371000.0, dt = 5.0, nsamp = 144

def compute_centroid(self, planet_radius=6371e3, dt=None, nsamp=None):
    """
        computes the centroid moment tensor by summing over all pointsource
        weihted by their scalar moment
        """
    x = 0.0
    y = 0.0
    z = 0.0
    finite_M0 = self.M0
    finite_mij = np.zeros(6)
    finite_time_shift = 0.0  # time shift is now included in the sliprate

    if dt is None:
        dt = self[0].dt

    # estimate the number of samples needed from the pointsource with
    # longest time_shift
    if nsamp is None:
        ps_ts_max = max(self.pointsources, key=lambda x: x.time_shift)
        nsamp = int(ps_ts_max.time_shift / dt + len(ps_ts_max.sliprate))

    finite_sliprate = np.zeros(nsamp)
    nfft = next_pow_2(nsamp) * 2
    self.resample_sliprate(dt, nsamp)

    for ps in self.pointsources:
        x += ps.x(planet_radius) * ps.M0 / finite_M0
        y += ps.y(planet_radius) * ps.M0 / finite_M0
        z += ps.z(planet_radius) * ps.M0 / finite_M0

        # finite_time_shift += ps.time_shift * ps.M0 / finite_M0

        mij = rotations.rotate_symm_tensor_voigt_xyz_src_to_xyz_earth(
            ps.tensor_voigt, np.deg2rad(ps.longitude),
            np.deg2rad(ps.colatitude))
        finite_mij += mij

        # sum sliprates with time shift applied
        sliprate_f = np.fft.rfft(ps.sliprate, n=nfft)
        sliprate_f *= np.exp(- 1j * np.fft.rfftfreq(nfft) *
                           2. * np.pi * ps.time_shift / dt)

E AttributeError: 'module' object has no attribute 'rfftfreq'

instaseis/source.py:1462: AttributeError ================================================================================== 14 failed, 320 passed in 149.18 seconds ==================================================================================

krischer commented 8 years ago

I guess your numpy version does not include np.fft.rfftfreq? The latest master now includes a polyfill for older numpy versions. If you update it should work on your machine. Please reopen if not.

Cheers!

aringler-usgs commented 8 years ago

That did the trick. Sorry for not dealing with the obvious!

Thanks, Adam

On Fri, May 6, 2016 at 3:02 AM, Lion Krischer notifications@github.com wrote:

I guess your numpy version does not include np.fft.rfftfreq? The latest master now includes a polyfill for older numpy versions. If you update it should work on your machine. Please reopen if not.

Cheers!

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/krischer/instaseis/issues/38#issuecomment-217390156