API Reference#
Blast#
- class lightguide.blast.Blast(data: ndarray, start_time: datetime, sampling_rate: float, start_channel: int = 0, channel_spacing: float = 0.0, unit: Literal['strain rate', 'strain', 'acceleration', 'velocity', 'displacement'] = 'strain rate')[source]#
Bases:
object
A Blast represents a time-space patch from a DAS recording.
- afk_filter(exponent: float = 0.8, window_size: int = 16, overlap: int = 7, normalize_power: bool = False) None [source]#
Apply adaptive frequency filter (AFK) in-place.
The adaptive frequency filter (AFK) can be used to suppress incoherent noise in DAS data and other spatially coherent data sets.
- as_traces() list[pyrocko.trace.Trace] [source]#
Converts the data in the Blast object into Pyrocko’s Trace format.
- Returns:
- A list of Pyrocko Trace instances,
one for each channel in the data.
- Return type:
list[Trace]
- bandpass(min_freq: float, max_freq: float, order: int = 4, demean: bool = True, zero_phase: bool = False) None [source]#
Apply band-pass filter in-place using a Butterworth filter.
- Parameters:
min_freq (float) – Lower corner of the band pass filter in Hz.
max_freq (float) – Upper corner of the band pass filter in Hz.
order (int, optional) – Order of the filter. Defaults to 4.
demean (bool, optional) – Remove mean before filtering. Defaults to True.
zero_phase (bool, optional) – Use zero phase filter. Defaults to True.
- decimate(factor: int, demean: bool = True) None [source]#
Decimate in time-domain by a factor, in-place.
- detrend(type: Literal['linear', 'constant'] = 'linear') None [source]#
Demean and detrend in time-domain in-place.
- Parameters:
type (Literal["linear", "constant"], optional) – he type of detrending.
'linear' (If type ==) –
'constant' (to data is subtracted from data. If type ==) –
:param : :param only the mean of data is subtracted.. Defaults to “linear”.:
- follow_phase(pick_time: datetime, pick_channel: int, window_size: int | tuple[int, int] = 50, threshold: float = 0.5, max_shift: int = 20) tuple[numpy.ndarray, list[datetime.datetime], numpy.ndarray] [source]#
Follow a phase pick through a Blast.
This function leverages the spatial coherency of a DAS data set. Following a phase through iterative cross-correlation of neighboring traces:
Get windowed root pick template.
Calculate normalized cross correlate with downwards neighbor.
Evaluate maximum x-correlation in allowed window (max_shift).
Update template trace and go to 2.
Repeat for upward neighbors.
- Parameters:
pick_time (datetime) – Initial pick in the data set.
pick_channel (int) – Corresponding channel for the initial pick.
window_size (int | tuple[int, int], optional) – Window size around the pick for the correlation template. If an integer is given it is the half-width. A Tuple gives pre- and post-windows. Defaults to 50.
threshold (float, optional) – Picking threshold for the cross correlation. Defaults to 5e-1.
max_shift (int, optional) – Maximum allowed shift in samples for neighboring picks. Defaults to 20.
- Returns:
- Tuple of channel number,
pick time and maximum correlation coefficient.
- Return type:
- classmethod from_miniseed(file: Union[Path, str], channel_spacing: float = 4.0) Blast [source]#
Load Blast from miniSEED.
- classmethod from_pyrocko(traces: list[pyrocko.trace.Trace], channel_spacing: float = 4.0) Blast [source]#
Create Blast from a list of Pyrocko traces.
- Parameters:
- Raises:
ValueError – If input is odd.
- Returns:
Assembled Blast.
- Return type:
- get_trace(channel: int) ndarray [source]#
Get data from a singular channel.
- Parameters:
channel (int) – Channel number.
- Returns:
1D Trace.
- Return type:
np.ndarray
- highpass(cutoff_freq: float, order: int = 4, demean: bool = True, zero_phase: bool = False) None [source]#
Apply high-pass filter in-place using a Butterworth filter.
- lowpass(cutoff_freq: float, order: int = 4, demean: bool = True, zero_phase: bool = False) None [source]#
Apply low-pass filter in-place using a Butterworth filter.
- mute_median(level: float = 3.0) None [source]#
Mute signals in the data above a threshold in-place.
- Parameters:
level (float, optional) – Median level to mute. Defaults to 3.0.
- plot(axes: plt.Axes | None = None, normalize_traces: bool = True, cmap: str | Colormap = 'seismic', show_date: bool = False, show_channel: bool = False) image.AxesImage [source]#
Plot data of the blast.
- Parameters:
axes (plt.Axes | None, optional) – Optional axis to plot into. If not given, plt.show() is called. Defaults to None.
normalize_traces (bool, optional) – Normalize traces in time dimension. Defaults to True.
cmap (str | Colormap, optional) – Matplotlib colormap. Defaults to “seismic”.
show_date (bool, optional) – Shot absolute dates in UTC. Defaults to False.
show_channel (bool, optional) – Show channels instead of meters. Defaults to False.
- Returns:
Decorated axes.
- Return type:
image.AxesImage
- save_mseed(filename: Union[Path, str]) None [source]#
Save the Blast as miniSeed.
- Parameters:
filename (PathStr) – File to write to.
- taper(alpha: float = 0.05) None [source]#
Taper in time-domain and in-place with a Tukey window.
- Parameters:
alpha (float, optional) – Shape parameter of the Tukey window, representing the fraction of the window inside the cosine tapered region. If zero, the Tukey window is equivalent to a rectangular window. If one, the Tukey window is equivalent to a Hann window. Defaults to 0.05.
- to_relative_displacement(detrend: bool = True) Blast [source]#
Convert the traces to relative displacement.
- trim_channels(begin: int = 0, end: int = -1) Blast [source]#
Trim the Blast to channels and return a copy.
Pack#
- class lightguide.blast.Pack(blasts: Optional[Iterable[Blast]] = None)[source]#
Bases:
object
- afk_filter(exponent: float = 0.8, window_size: int = 16, overlap: int = 7, normalize_power: bool = False) None #
Apply adaptive frequency filter (AFK) in-place.
The adaptive frequency filter (AFK) can be used to suppress incoherent noise in DAS data and other spatially coherent data sets.
- bandpass(min_freq: float, max_freq: float, order: int = 4, demean: bool = True, zero_phase: bool = False) None #
Apply band-pass filter in-place using a Butterworth filter.
- Parameters:
min_freq (float) – Lower corner of the band pass filter in Hz.
max_freq (float) – Upper corner of the band pass filter in Hz.
order (int, optional) – Order of the filter. Defaults to 4.
demean (bool, optional) – Remove mean before filtering. Defaults to True.
zero_phase (bool, optional) – Use zero phase filter. Defaults to True.
- detrend(type: Literal['linear', 'constant'] = 'linear') None #
Demean and detrend in time-domain in-place.
- Parameters:
type (Literal["linear", "constant"], optional) – he type of detrending.
'linear' (If type ==) –
'constant' (to data is subtracted from data. If type ==) –
:param : :param only the mean of data is subtracted.. Defaults to “linear”.:
- highpass(cutoff_freq: float, order: int = 4, demean: bool = True, zero_phase: bool = False) None #
Apply high-pass filter in-place using a Butterworth filter.
- lowpass(cutoff_freq: float, order: int = 4, demean: bool = True, zero_phase: bool = False) None #
Apply low-pass filter in-place using a Butterworth filter.
- mute_median(level: float = 3.0) None #
Mute signals in the data above a threshold in-place.
- Parameters:
level (float, optional) – Median level to mute. Defaults to 3.0.
- taper(alpha: float = 0.05) None #
Taper in time-domain and in-place with a Tukey window.
- Parameters:
alpha (float, optional) – Shape parameter of the Tukey window, representing the fraction of the window inside the cosine tapered region. If zero, the Tukey window is equivalent to a rectangular window. If one, the Tukey window is equivalent to a Hann window. Defaults to 0.05.
- trim_time(begin: float = 0.0, end: float = -1.0) Blast #
Trim channel to time frame and return a copy.
- Parameters:
- Raises:
ValueError – Raised when begin and end are ill behaved.
- Returns:
Trimmed Pack.
- Return type: