Signal Organization Overview

The shakelab.signals.base module provides functionality for basic waveform analysis.

ShakeLab provides three fundamental classes to manage and manipulate seismic waveform data: Record, Stream, and StreamCollection. These classes are designed to handle individual recordings, collections of non-contigous recordings from a single stream (e.g. from a single station and a specific channel), and collections of multiple streams, respectively.

Record Class

The Record class is the base element for seismic data management within ShakeLab. It represents a single continuous recording block, encapsulating both the waveform data and associated metadata, such as sampling rate, start time, and location.

It includes various methods for working with seismic signals, such as convolution, deconvolution, filtering, and various waveform analysis metrics.

Stream Class

The Stream class represents a collection of Record objects that belong to the same data stream, typically from the same seismic channel or station. The Stream class can handle both continuous and segmented data, managing gaps between Record objects if necessary.

A Stream object allows for operations that involve multiple Record objects, such as merging records, extracting specific time windows, and appending new data. Each Stream is associated with a single channel or station, but it may consist of multiple Record objects, especially if there are gaps in the data.

StreamCollection Class

The StreamCollection class represents a collection of Stream objects, essentially grouping multiple seismic channels or stations into a single collection. This class is useful for handling data from multiple sources simultaneously, allowing for operations across different streams.

The StreamCollection class acts as a container for multiple Stream objects, providing the ability to manage and process data from multiple seismic channels or stations collectively. Operations can be performed on the entire collection, such as merging streams or applying common processing steps across all contained streams.

Relationships Between Classes

  • A `StreamCollection` object contains multiple `Stream` objects, each corresponding to a different seismic channel or station.

  • Each `Stream` object contains a list of `Record` objects, representing different segments or time windows of data from the same channel or station.

  • `Record` is the foundational class, holding the actual waveform data and metadata. Multiple Record objects are grouped into a Stream, and multiple Stream objects are further grouped into a StreamCollection.

Here is a conceptual example of how these classes might be used together:

Python
from shakelab.signals.base import Record, Stream, StreamCollection

# Create a single Record
record1 = Record(data=[1, 2, 3, 4],
                 delta=0.01,
                 time='2024-01-01T00:00:00',
                 sid='NET.STA1..HHZ')

# Create another Record
record2 = Record(data=[5, 6, 7, 8],
                 delta=0.01,
                 time='2024-01-01T00:01:00',
                 sid='NET.STA2..HHZ')

# Create a StreamCollection and add the Records
stream_collection = StreamCollection()
stream_collection.append(record1)
stream_collection.append(record2)

# Ge information about Streams in the StreamCollection
stream_collection.info()

This setup allows for flexible and scalable management of seismic data, whether working with individual records, grouped streams, or entire collections of streams.