TimeSeries

class TimeSeries(amplitude, dt_in_seconds)
__init__(amplitude, dt_in_seconds)

Initialize a TimeSeries object.

Parameters:
  • amplitude (iterable) – Amplitude of the time series at each time step.

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

Returns:

TimeSeries – Instantiated with amplitude and time step information.

Raises:

TypeError – If amplitude is not castable to ndarray, refer to error message(s) for specific details.

butterworth_filter(fcs_in_hz, order=5)

Apply Butterworth filter.

Parameters:
  • fcs_in_hz (tuple) – Butterworth filter’s corner frequencies in Hz. None can be used to specify a one-sided filter. For example a high pass filter at 3 Hz would be specified as fcs_in_hz=(3, None).

  • order (int, optional) – Butterworth filter order, default is 5.

Returns:

None – Filters amplitude attribute in-place.

detrend(type='linear')

Remove trend from TimeSeries.

Parameters:

type = {“constant”, “linear”}, optional – Type of detrend. If type == "linear" (default), the result of a linear least-squares fit to data is subtracted from data. If type == "constant", only the mean of data is subtracted.

Returns:

None – Performs inplace detrend on the amplitude attribute.

classmethod from_timeseries(timeseries)

Copy constructor for TimeSeries object.

Parameters:

timeseries (TimeSeries) – TimeSeries to be copied.

Returns:

TimeSeries – Copy of the provided TimeSeries object.

classmethod from_trace(trace)

Initialize a TimeSeries object from obspy Trace.

is_similar(other)

Check if other is similar to self.

split(window_length_in_seconds)

Split record into set of records.

Parameters:

window_length_in_seconds (float) – Duration of each split in seconds.

Returns:

list – List of TimeSeries objects, one per split.

Notes

The last sample of each window is repeated as the first sample of the following time window to ensure an intuitive number of windows. Without this, for example, a 10-minute record could not be broken into 10, 1-minute records.

trim(start_time, end_time)

Trim in the interval [start_time, end_time].

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

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

Returns:

None – Updates the attributes amplitude and n_samples.

Raises:

IndexError – If the start_time and/or end_time is illogical. Checks include start_time is less than zero, start_time is after end_time, or end_time is after the end of the record.

window(type='tukey', width=0.1)

Apply window to time series.

Parameters:
  • width ({0.-1.}) – Fraction of the time series to be windowed.

  • type ({“tukey”}, optional) – If type="tukey", a width of 0 is a rectangular window and 1 is a Hann window, default is 0.1 indicating a 5% taper off of both ends of the time series.

Returns:

None – Applies window to the amplitude attribute in-place.