inspect
File inspection and metadata functions.
ChannelInfo
dataclass
¶
Metadata about a single channel in a GWF file.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
Channel name (e.g., 'H1:LOSC-STRAIN') |
type |
str
|
Channel type: 'adc', 'proc', or 'sim' |
dtype |
dtype
|
NumPy dtype of the channel samples (e.g., |
sample_rate |
float
|
Sampling rate in Hz |
n_samples |
int
|
Number of samples in the channel |
unit |
str
|
Physical unit of the data (e.g., 'strain') |
get_channel_details ¶
Get detailed metadata for all channels in a GWF file.
Reads channel headers (without decompressing data) to extract sample rate, data type, sample count, and units for each channel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str or path - like
|
Path to the GWF file |
required |
frame_index
|
int
|
Frame index to read metadata from (default: 0) |
0
|
Returns:
| Name | Type | Description |
|---|---|---|
details |
list[ChannelInfo]
|
List of channel metadata, ordered by type (adc, proc, sim) |
Examples:
>>> details = gwframe.get_channel_details('data.gwf')
>>> for ch in details:
... print(f"{ch.name}: {ch.dtype_name} @ {ch.sample_rate} Hz")
Source code in gwframe/inspect.py
get_channels ¶
Get a list of all channels in a GWF file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str or path - like
|
Path to the GWF file |
required |
Returns:
| Name | Type | Description |
|---|---|---|
channels |
list[str]
|
List of all channel names |
Examples:
>>> channels = gwframe.get_channels('data.gwf')
>>> print(f"Found {len(channels)} channels")
>>> for channel in channels:
... print(channel)
Source code in gwframe/inspect.py
get_channels_by_type ¶
Get channel names grouped by type (adc, proc, sim).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str or path - like
|
Path to the GWF file |
required |
Returns:
| Name | Type | Description |
|---|---|---|
channels |
dict[str, list[str]]
|
Dictionary with keys 'adc', 'proc', 'sim' mapping to channel name lists |
Examples:
>>> by_type = gwframe.get_channels_by_type('data.gwf')
>>> print(f"ADC channels: {len(by_type['adc'])}")
>>> print(f"Proc channels: {len(by_type['proc'])}")
Source code in gwframe/inspect.py
get_info ¶
get_info(filename: str | PathLike[str]) -> FrameFileInfo
Get metadata about a GWF file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str or path - like
|
Path to the GWF file |
required |
Returns:
| Name | Type | Description |
|---|---|---|
info |
FrameFileInfo
|
Structured metadata containing: - num_frames: number of frames in file - channels: list of all channel names - frames: list of FrameInfo objects with complete frame metadata |
Examples:
>>> info = gwframe.get_info('data.gwf')
>>> print(f"File contains {info.num_frames} frames")
>>> print(f"Frame 0: {info.frames[0].name} at GPS {info.frames[0].start}")
>>> print(f"Channels: {', '.join(info.channels)}")