util

Utility functions for the OwlPy library.

exception ArangeError[source]

Bases: Exception

arange2(start, stop, step, dtype=<class 'float'>, epsilon=1e-06, error='raise')[source]

Return evenly spaced numbers over a specified interval.

Like numpy.arange() but returning floating point numbers by default and with defined behaviour when stepsize is inconsistent with interval bounds. It is considered inconsistent if the difference between the closest multiple of step and stop is larger than epsilon * step. Inconsistencies are handled according to the error parameter. If it is set to 'raise' an exception of type ArangeError is raised. If it is set to 'round', 'floor', or 'ceil', stop is silently changed to the closest, the next smaller, or next larger multiple of step, respectively.

This function has been adapted from Pyrocko (pyrocko.util.arange2).

get_traces_data_as_array(traces)[source]

Merge data samples from multiple traces into a 2D array.

Parameters

traces (list of obspy.Trace or pyrocko.Trace objects) – Input waveforms.

Raises

OwlPyError if traces have different time span, sample rate or data type, or if traces is an empty list.

Returns

2D array as data[itrace, isample].

Return type

numpy.ndarray