CLI Tools¶
gwframe provides a comprehensive command-line interface for manipulating GWF
files without writing Python code. All commands support both single files and
batch processing of directories.
Common Options¶
All commands support these common patterns:
- File or directory input: Pass individual files or directories
- Batch processing: Use glob patterns like
data/*.gwf - Recursive processing: Use
-r/--recursiveto process subdirectories - In-place editing: Use
-i/--in-placeto modify files directly - Output control: Specify output directory with
-o/--output-dir
Tip
Use gwframe COMMAND --help to see detailed help for any command.
Commands¶
rename - Rename Channels¶
Rename channels within frame files while preserving all other data.
Usage:
Options:
-m, --map TEXT- Channel mapping in formatOLD=>NEW(required, can specify multiple)-o, --output-dir PATH- Output directory or file-i, --in-place- Modify files in place-r, --recursive- Recurse into subdirectories
Examples:
Rename a single channel in one file:
Rename multiple channels:
Process entire directory:
In-place rename (modifies originals):
combine - Combine Channels¶
Merge channels from multiple sources covering the same time period. Useful for combining data from different acquisition systems or adding calibrated channels to raw data files.
Usage:
Options:
-o, --output-dir PATH- Output directory (required)-k, --keep TEXT- Only include these channels (can specify multiple)-d, --drop TEXT- Exclude these channels (can specify multiple)
Examples:
Combine two files:
Combine directories (matches frame files by time):
Combine with channel filtering (keep only specific channels):
Combine and drop unwanted channels:
Warning
All sources must cover the same time ranges. Mismatched time ranges will cause an error.
select - Keep Specific Channels¶
Keep only specified channels in frame files, removing all others.
Usage:
Options:
-c, --channel TEXT- Channel(s) to keep (required, can specify multiple)-o, --output-dir PATH- Output directory or file-i, --in-place- Modify files in place-r, --recursive- Recurse into subdirectories
Examples:
Keep a single channel:
Keep multiple channels:
Process directory and keep only selected channels:
In-place selection (modifies originals):
drop - Remove Channels¶
Remove specified channels from frame files. This is the inverse of select.
Usage:
Options:
-c, --channel TEXT- Channel(s) to drop (required, can specify multiple)-o, --output-dir PATH- Output directory or file-i, --in-place- Modify files in place-r, --recursive- Recurse into subdirectories
Examples:
Drop single channel:
Drop multiple channels:
Process directory and drop channels:
In-place removal (modifies originals):
resize - Change Frame Duration¶
Split or combine frames to achieve a target duration. Used to convert between different frame lengths (e.g., 64s → 4s).
Usage:
Options:
-d, --duration FLOAT- Target frame duration in seconds (required)-o, --output-dir PATH- Output directory or file-i, --in-place- Modify files in place-r, --recursive- Recurse into subdirectories
Examples:
Split 64-second frames into 4-second frames:
Combine 1-second frames into 16-second frames:
Convert entire directory:
Note
- The total duration of input data must be evenly divisible by the target duration
- All channels in the frame will be resized together
- Frame metadata (GPS time, run number, etc.) is preserved
impute - Replace Values¶
Replace specific values (like NaN, -999, or sentinel values) with a fill value.
Usage:
Options:
-r, --replace-value FLOAT- Value to replace (default: NaN)-f, --fill-value FLOAT- Replacement value (default: 0.0)-c, --channel TEXT- Specific channel(s) to impute (if omitted, processes all channels)-o, --output-dir PATH- Output directory or file-i, --in-place- Modify files in place--recursive- Recurse into subdirectories
Examples:
Replace NaN with zeros (default behavior):
Replace specific sentinel value:
Impute only specific channels:
gwframe impute data.gwf -o clean.gwf \
--fill-value 0.0 \
--channel L1:STRAIN \
--channel L1:LSC-DARM
Process directory and replace -inf values:
Warning
The fill value is cast to the dtype of each channel, so precision may be lost for integer channels.
replace - Update Channel Data¶
Replace channel data in base files with updated versions from other files.
Usage:
Options:
-u, --update PATH- Source of updated channel data (required)-o, --output-dir PATH- Output directory (required)-c, --channel TEXT- Specific channel(s) to replace (if omitted, replaces all matching channels)-r, --recursive- Recurse into subdirectories
Examples:
Replace all matching channels from update file:
Replace only specific channel:
Replace data in entire directory (matches by filename/time):
Replace multiple specific channels:
Use Cases
- Data fixes: Replace corrupted segments with corrected data
- Reprocessing: Update specific channels while keeping others unchanged
recompress - Change Compression¶
Rewrite frame files with different compression settings.
Usage:
Options:
-c, --compression TEXT- Compression type (default: ZERO_SUPPRESS_OTHERWISE_GZIP)RAW- No compression (fastest, largest)GZIP- Standard gzip compressionDIFF_GZIP- Differentiate then gzip (good for slowly-varying data)ZERO_SUPPRESS_OTHERWISE_GZIP- Zero-suppression with gzip fallback (recommended)-l, --level INT- Compression level 0-9 (default: 6, higher = more compression)-o, --output-dir PATH- Output directory or file-i, --in-place- Modify files in place-r, --recursive- Recurse into subdirectories
Examples:
Maximum compression for archival:
Re-compress entire directory with optimal settings:
inspect - Inspect Frame Files¶
Display metadata and channel information for a GWF file. Supports tiered verbosity to progressively reveal more detail.
Usage:
Verbosity levels:
| Flag | Level | Shows |
|---|---|---|
| (none) | 0 | File summary: GPS range, frame/channel counts, compression, file size |
-v |
1 | Add channel listing with types (adc/proc/sim) |
-vv |
2 | Add per-frame table with GPS start, duration, run, frame number |
-vvv |
3 | Replace simple channel listing with detailed table (sample rate, dtype, units, sample count) |
Examples:
Quick file summary:
List all channels with their types:
Show channels and per-frame metadata:
Full detail including sample rates, dtypes, and units:
Tip
Lower verbosity levels read only file-level metadata (fast even for large files).
Level 3 (-vvv) reads channel headers to extract per-channel details.
Error Handling¶
Common errors and solutions:
"Channel not found"¶
Solution: List available channels withinspect:
"Time ranges don't match"¶
Solution: Usecombine only with files covering identical time spans. Check with:
import gwframe
for file in ["file1.gwf", "file2.gwf"]:
info = gwframe.read(file, channel_list=True)
print(f"{file}: {info}")