pyrocko.response

Frequency response parameterizations useful as transfer functions in signal processing.

Classes

AnalogFilterResponse(b, a, **kwargs)

Frequency response of an analog filter.

ButterworthResponse(*args, **kwargs)

Butterworth frequency response.

DelayResponse(*args, **kwargs)

Frequency response of a time delay.

DifferentiationResponse([n, gain])

The differentiation response, optionally multiplied by a constant gain.

DigitalFilterResponse(b, a, deltat[, drop_phase])

Frequency response of an analog filter.

DigitalPoleZeroResponse([zeros, poles, ...])

Evaluates frequency response from digital filter pole-zero representation.

Evalresp(respfile[, trace, target, nslc_id, ...])

Calls evalresp and generates values of the instrument response transfer function.

FrequencyResponse(*args, **kwargs)

Base class for parameterized frequency responses.

FrequencyResponseCheckpoint(**kwargs)

Undocumented.

Gain(*args, **kwargs)

A flat frequency response.

IntegrationResponse([n, gain])

The integration response, optionally multiplied by a constant gain.

InvalidResponse(message)

Frequency response returning NaN for all frequencies.

InverseEvalresp(respfile, trace[, target])

Calls evalresp and generates values of the inverse instrument response for deconvolution of instrument response.

MultiplyResponse([responses])

Multiplication of several FrequencyResponse objects.

PoleZeroResponse([zeros, poles, constant])

Evaluates frequency response from pole-zero representation.

SampledResponse(frequencies, values[, left, ...])

Interpolates frequency response given at a set of sampled frequencies.

class FrequencyResponseCheckpoint(**kwargs)[source]

Bases: Object

Undocumented.

frequency

float

value

float

class FrequencyResponse(*args, **kwargs)[source]

Bases: Object

Base class for parameterized frequency responses.

checkpoints

list of FrequencyResponseCheckpoint objects, default: []

evaluate(freqs)[source]

Evaluate the response at given frequencies.

Parameters:

freqs (numpy.ndarray of shape (N,) and dtype float) – Frequencies [Hz].

Returns:

Complex coefficients of the response.

Return type:

numpy.ndarray of shape (N,) and dtype complex

evaluate1(freq)[source]

Evaluate the response at a single frequency.

Parameters:

freq – Frequency [Hz].

Returns:

Complex response coefficient.

Return type:

complex

is_scalar()[source]

Check if this is a flat response.

get_scalar()[source]

Get factor if this is a flat response.

get_fmax()[source]

Get maximum frequency for which the response is defined.

Returns:

None if the response has no upper limit, otherwise the maximum frequency in [Hz] for which the response is valid is returned.

Return type:

float or None

property summary

Short summary with key information about the response object.

class Gain(*args, **kwargs)[source]

Bases: FrequencyResponse

A flat frequency response.

constant

complex, default: (1+0j)

class Evalresp(respfile, trace=None, target='dis', nslc_id=None, time=None, stages=None, **kwargs)[source]

Bases: FrequencyResponse

Calls evalresp and generates values of the instrument response transfer function.

Parameters:
  • respfile – response file in evalresp format

  • trace – trace for which the response is to be extracted from the file

  • target'dis' for displacement or 'vel' for velocity

respfile

str

nslc_id

tuple of 4 str objects, default: (None, None, None, None)

target

str, default: 'dis'

instant

float

stages

tuple of 2 int objects, optional

class InverseEvalresp(respfile, trace, target='dis', **kwargs)[source]

Bases: FrequencyResponse

Calls evalresp and generates values of the inverse instrument response for deconvolution of instrument response.

Parameters:
  • respfile – response file in evalresp format

  • trace – trace for which the response is to be extracted from the file

  • target'dis' for displacement or 'vel' for velocity

respfile

str

nslc_id

tuple of 4 str objects, default: (None, None, None, None)

target

str, default: 'dis'

instant

float

class PoleZeroResponse(zeros=None, poles=None, constant=1 + 0j, **kwargs)[source]

Bases: FrequencyResponse

Evaluates frequency response from pole-zero representation.

Parameters:
                  (j*2*pi*f - zeros[0]) * (j*2*pi*f - zeros[1]) * ...
T(f) = constant * ----------------------------------------------------
                  (j*2*pi*f - poles[0]) * (j*2*pi*f - poles[1]) * ...

The poles and zeros should be given as angular frequencies, not in Hz.

zeros

list of complex objects, default: []

poles

list of complex objects, default: []

constant

complex, default: (1+0j)

get_scalar()[source]

Get factor if this is a flat response.

class DigitalPoleZeroResponse(zeros=None, poles=None, constant=1 + 0j, deltat=None, **kwargs)[source]

Bases: FrequencyResponse

Evaluates frequency response from digital filter pole-zero representation.

Parameters:

The poles and zeros should be given as angular frequencies, not in Hz.

zeros

list of complex objects, default: []

poles

list of complex objects, default: []

constant

complex, default: (1+0j)

deltat

float

get_scalar()[source]

Get factor if this is a flat response.

class ButterworthResponse(*args, **kwargs)[source]

Bases: FrequencyResponse

Butterworth frequency response.

Parameters:
  • corner – corner frequency of the response

  • order – order of the response

  • type – either high or low

corner

float, default: 1.0

order

int, default: 4

type

str (pyrocko.guts.StringChoice), default: 'low'

class SampledResponse(frequencies, values, left=None, right=None, **kwargs)[source]

Bases: FrequencyResponse

Interpolates frequency response given at a set of sampled frequencies.

Parameters:
  • frequencies,values – frequencies and values of the sampled response function.

  • left,right – values to return when input is out of range. If set to None (the default) the endpoints are returned.

frequencies

numpy.ndarray (pyrocko.guts_array.Array)

values

numpy.ndarray (pyrocko.guts_array.Array)

left

complex, optional

right

complex, optional

inverse()[source]

Get inverse as a new SampledResponse object.

class IntegrationResponse(n=1, gain=1.0, **kwargs)[source]

Bases: FrequencyResponse

The integration response, optionally multiplied by a constant gain.

Parameters:
  • n – exponent (integer)

  • gain – gain factor (float)

            gain
T(f) = --------------
       (j*2*pi * f)^n
n

int, optional, default: 1

gain

float, optional, default: 1.0

class DifferentiationResponse(n=1, gain=1.0, **kwargs)[source]

Bases: FrequencyResponse

The differentiation response, optionally multiplied by a constant gain.

Parameters:
  • n – exponent (integer)

  • gain – gain factor (float)

T(f) = gain * (j*2*pi * f)^n
n

int, optional, default: 1

gain

float, optional, default: 1.0

class DigitalFilterResponse(b, a, deltat, drop_phase=False, **kwargs)[source]

Bases: FrequencyResponse

Frequency response of an analog filter.

(see scipy.signal.freqz()).

b

list of float objects, default: []

a

list of float objects, default: []

deltat

float

drop_phase

bool, default: False

class AnalogFilterResponse(b, a, **kwargs)[source]

Bases: FrequencyResponse

Frequency response of an analog filter.

(see scipy.signal.freqs()).

b

list of float objects, default: []

a

list of float objects, default: []

class MultiplyResponse(responses=None, **kwargs)[source]

Bases: FrequencyResponse

Multiplication of several FrequencyResponse objects.

responses

list of FrequencyResponse objects, default: []

get_scalar()[source]

Get factor if this is a flat response.

class DelayResponse(*args, **kwargs)[source]

Bases: FrequencyResponse

Frequency response of a time delay.

delay

float

Time delay [s]

class InvalidResponse(message)[source]

Bases: FrequencyResponse

Frequency response returning NaN for all frequencies.

When using FrequencyResponse.evaluate() for the first time after instantiation, the user supplied warning message is emitted.

message

str

Warning message to be emitted when the response is used.