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.
drop - Remove Channels¶
Remove specified channels from frame files, reducing file size and removing unnecessary data.
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:
Error Handling¶
Common errors and solutions:
"Channel not found"¶
Solution: Usegwframe Python API to list available channels:
"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}")