activetimeseries

ActiveTimeSeries class definition.

class ActiveTimeSeries(amplitude, dt, nstacks=1, delay=0)

Bases: TimeSeries

A class for working with active-source TimeSeries.

Variables:
  • amplitude (ndarray) – Recording’s amplitude, one per sample.

  • dt (float) – Time step between samples in seconds.

__init__(amplitude, dt, nstacks=1, delay=0)

Initialize an ActiveTimeSeries object.

Parameters:
  • amplitude (array-like) – Recording’s amplitude, one per sample. The first value is associated with time=0 seconds and the last is associate with time=(len(amplitude)-1)*dt seconds.

  • dt (float) – Time step between samples in seconds.

  • nstacks (int, optional) – Number of stacks used to produce amplitude, default is 1.

  • delay (float, optional) – Delay to the start of the record in seconds, default is 0.

Returns:

ActiveTimeSeries – Intialized ActiveTimeSeries object.

static crosscorr(a, b, correlate_kwargs=None, exclude='nsamples')

Cross correlation of two ActiveTimeSeries objects.

Parameters:
  • a (ActiveTimeSeries) – Base ActiveTimeSeries to which b is correlated.

  • b (ActiveTimeSeries) – ActiveTimeSeries correlated to a.

  • correlate_kwargs (dict, optional) – dict of keyword argument for the correlate function, see scipy.signal.correlate for details.

  • exclude (tuple, optional) – tuple of attributes to exclude in an is_similar comparison, default is (‘nsamples’).

Returns:

ndarray – Containing the cross correlation.

static crosscorr_shift(a, b, exclude=None)

Shift b so that it is maximally corrlated with a.

Parameters:
  • a (ActiveTimeSeries) – ActiveTimeSeries to which b will be correlated. a should be similar to b.

  • b (ActiveTimeSeries) – ActiveTimeSeries which will be shifted so that it is maximally correlated with a. b should be similar to a.

  • exclude (tuple, optional) – tuple of attributes to exclude in an is_similar comparison, default is (‘nsamples’).

Returns:

ndarray – Which represents the stack of the correlated and padded b onto a.

property delay
property df
classmethod from_activetimeseries(activetimeseries)
classmethod from_cross_stack(a, b)

Create ActiveTimeSeries from cross-correlation.

Cross-correlate b to a and shift b such that it is maximally correlated with a. Then stack the shifted version of b onto a.

Parameters:
  • a (ActiveTimeSeries) – ActiveTimeSeries to which b will be correlated and stacked. a should be similar to b.

  • b (ActiveTimeSeries) – ActiveTimeSeries which will be correlated with and stacked onto a. b should be similar to a.

Returns:

ActiveTimeSeries – Which represents the correlated and potentially zero-padded b stacked onto a.

classmethod from_trace(trace, nstacks=1, delay=0)

Create ActiveTimeSeries from a Trace object.

This method is more general than ActiveTimeSeries.from_trace_seg2(), as it does not attempt to extract any metadata from the Trace object.

Parameters:
  • trace (Trace) – Refer to obspy documentation for more information.

  • nstacks (int, optional) – Number of stacks the time series represents, default is 1, signifying a single unstacked time record.

  • delay (float {<=0.}, optional) – Denotes the pre-event delay, default is zero, meaning no pre-event noise was recorded.

Returns:

ActiveTimeSeries – Initialized with information from trace.

classmethod from_trace_seg2(trace)

Initialize from a SEG2 Trace object.

This method is similar to ActiveTimeSeries.from_trace() except that it extracts additional information from the Trace header. So only use this method if you have a seg2 file and the header information is correct.

Parameters:

trace (Trace) – Trace object from a correctly written seg2 file.

Returns:

ActiveTimeSeries – Instantiated with seg2 file.

property multiple
property n_stacks
property nstacks
stack_append(timeseries)

Stack (i.e., average) a new timeseries onto the current one.

Parameters:

timeseries (ActiveTimeSeries) – ActiveTimeSeries to be stacked onto the current object.

Returns:

None – Updates the attributes amplitude and nstacks.

Raises:

ValueError – If timeseries is not an ActiveTimeSeries or it cannot be stacked to the current object (i.e., the two are dissimilar).

property time

Time vector for ActiveTimeSeries.

trim(start_time, end_time)

Trim in the interval [start_time, end_time].

For more information see sigpropy.TimeSeries.trim().

Parameters:
  • start_time (float) – New time-zero in seconds.

  • end_time (float) – New end-time in seconds.

Returns:

None – Updates the attributes nsamples and delay.

zero_pad(df)

Append zeros to amp to achieve a desired frequency step.

Note for exact results, 1/(df*dt) must be an integer, otherwise a df close to the desired df will be returned.

Parameters:

df (float) – Desired frequency step in Hertz.

Returns:

None – Instead modifies attributes: amp, nsamples, multiple.

Raises:

ValueError – If df < 0 (i.e., non-positive).