Skip to main content

High-level Python library to work with gravitational-wave frame (GWF) files, based on framecpp

Project description

gwframe

High-level Python library to work with gravitational-wave frame (GWF) files, based on framecpp

ci license documentation pypi version


Resources

Installation

With pip:

pip install gwframe

Pre-built wheels are available for:

Platform Architecture Minimum Version
Linux x86_64, aarch64 glibc 2.34 (e.g., Debian 12, Ubuntu 21.10, Fedora 35, RHEL 9)
macOS x86_64 macOS 13 (Ventura)
macOS ARM64 macOS 15 (Sequoia)

With conda:

conda install -c conda-forge gwframe

Features

  • Multi-frame writing - Write multiple frames to a single file
  • Multi-channel support - Read all channels or specific lists with a single call
  • Masked array support - Detect and propagate invalid-data flags as NumPy masked arrays
  • Self-contained wheels - No external dependencies required for pip installation

Quickstart

Reading frames

import gwframe

# Read single channel
data = gwframe.read('data.gwf', 'L1:GWOSC-16KHZ_R1_STRAIN')
print(f"Read {len(data.array)} samples at {data.sample_rate} Hz")
print(f"Time range: {data.start} to {data.start + data.duration}")

# Read all channels
channels = gwframe.read('data.gwf', channels=None)
for name, timeseries in channels.items():
    print(f"{name}: {len(timeseries.array)} samples")

# Time-based slicing (automatically stitches multiple frames)
data = gwframe.read('multi_frame.gwf', 'L1:STRAIN',
                    start=1234567890.0, end=1234567900.0)

Writing single frames

import gwframe
import numpy as np

data = np.random.randn(16384)
gwframe.write('output.gwf', data, start=1234567890.0,
              sample_rate=16384, name='L1:TEST')

Writing multiple frames

import gwframe
import numpy as np

# Write multiple frames to a single file
with gwframe.FrameWriter('multi_frame.gwf') as writer:
    for i in range(20):
        data = np.random.randn(16384)
        writer.write(data, start=1234567890.0 + i,
                     sample_rate=16384, name='L1:TEST')

# Or without a context manager
writer = gwframe.FrameWriter('multi_frame.gwf')
writer.open()
for i in range(20):
    data = np.random.randn(16384)
    writer.write(data, start=1234567890.0 + i,
                 sample_rate=16384, name='L1:TEST')
writer.close()

Inspecting frames

From the command line:

gwframe inspect data.gwf            # file summary
gwframe inspect -v data.gwf         # + channel listing
gwframe inspect -vvv data.gwf       # + sample rates, dtypes, units

Or from Python:

import gwframe

# Get frame information
info = gwframe.get_info('data.gwf')
print(f"Number of frames: {info.num_frames}")
for frame in info.frames:
    print(f"Frame {frame.index}: {frame.name} at GPS {frame.start}, duration {frame.duration}s")

# List all channels
channels = gwframe.get_channels('data.gwf')
for channel in channels:
    print(channel)

Advanced: Full control with Frame objects

import gwframe
import numpy as np

# Create frame with multiple channels and metadata
frame = gwframe.Frame(
    start=1234567890.0,
    duration=1.0,
    name='L1',
    run=1
)

# Add channels
strain = np.random.randn(16384)
frame.add_channel('L1:STRAIN', strain,
                  sample_rate=16384,
                  unit='strain',
                  channel_type='proc')

aux = np.random.randn(1024).astype(np.float32)
frame.add_channel('L1:AUX', aux,
                  sample_rate=1024,
                  unit='counts',
                  channel_type='adc')

# Add metadata
frame.add_history('gwframe', 'Created with gwframe')

# Write with custom compression
frame.write('output.gwf', compression=gwframe.Compression.GZIP)

Handling invalid / masked data

ADC channels in GWF files can carry a data-valid flag indicating the entire channel is suspect. gwframe surfaces this through NumPy masked arrays:

import gwframe

# By default, reading a channel flagged invalid raises an error
try:
    data = gwframe.read('data.gwf', 'H1:ADC-CHANNEL')
except gwframe.InvalidDataError as e:
    print(e)  # suggests allow_invalid=True

# Allow invalid data — returns a masked array
data = gwframe.read('data.gwf', 'H1:ADC-CHANNEL', allow_invalid=True)
if isinstance(data.array, np.ma.MaskedArray):
    print(f"{data.array.count()} valid samples out of {len(data.array)}")

# Write a masked array — ADC channels preserve the flag,
# proc/sim channels warn that the mask is discarded
masked = np.ma.MaskedArray(values, mask=quality_mask)
frame = gwframe.Frame(start=1234567890.0, duration=1.0, name='H1')
frame.add_channel('H1:ADC-CHANNEL', masked,
                  sample_rate=16384, channel_type='adc')

# Control behavior when mask fidelity is lost
frame.add_channel('H1:PROC-CHANNEL', masked,
                  sample_rate=16384, channel_type='proc',
                  on_mask_loss='ignore')  # or 'warn' (default), 'raise'

CLI Tools

gwframe includes a command-line interface for common frame manipulation tasks:

# Inspect a frame file (add -v, -vv, -vvv for more detail)
gwframe inspect data.gwf

# Rename channels
gwframe rename input.gwf -o output.gwf -m "L1:OLD=>L1:NEW"

# Combine channels from multiple files
gwframe combine file1.gwf file2.gwf -o output/

# Keep only specific channels
gwframe select input.gwf -o output.gwf -c L1:STRAIN

# Remove unwanted channels
gwframe drop input.gwf -o output.gwf -c L1:UNWANTED

# Change frame duration
gwframe resize input.gwf -o output/ -d 4.0

# Replace NaN or sentinel values
gwframe impute input.gwf -o output.gwf --fill-value 0.0

# Update channel data from another file
gwframe replace base.gwf --update new.gwf -o output/ -c L1:STRAIN

# Change compression settings
gwframe recompress input.gwf -o output.gwf -c GZIP -l 9

All commands support batch processing with directories and glob patterns. See the CLI documentation for detailed usage and examples.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gwframe-0.3.1.tar.gz (6.2 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

gwframe-0.3.1-cp313-cp313-manylinux_2_34_x86_64.whl (18.7 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ x86-64

gwframe-0.3.1-cp313-cp313-manylinux_2_34_aarch64.whl (18.3 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ ARM64

gwframe-0.3.1-cp313-cp313-macosx_15_0_arm64.whl (4.5 MB view details)

Uploaded CPython 3.13macOS 15.0+ ARM64

gwframe-0.3.1-cp313-cp313-macosx_13_0_x86_64.whl (4.6 MB view details)

Uploaded CPython 3.13macOS 13.0+ x86-64

gwframe-0.3.1-cp312-cp312-manylinux_2_34_x86_64.whl (18.7 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

gwframe-0.3.1-cp312-cp312-manylinux_2_34_aarch64.whl (18.3 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ ARM64

gwframe-0.3.1-cp312-cp312-macosx_15_0_arm64.whl (4.5 MB view details)

Uploaded CPython 3.12macOS 15.0+ ARM64

gwframe-0.3.1-cp312-cp312-macosx_13_0_x86_64.whl (4.6 MB view details)

Uploaded CPython 3.12macOS 13.0+ x86-64

gwframe-0.3.1-cp311-cp311-manylinux_2_34_x86_64.whl (18.7 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.34+ x86-64

gwframe-0.3.1-cp311-cp311-manylinux_2_34_aarch64.whl (18.3 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.34+ ARM64

gwframe-0.3.1-cp311-cp311-macosx_15_0_arm64.whl (4.5 MB view details)

Uploaded CPython 3.11macOS 15.0+ ARM64

gwframe-0.3.1-cp311-cp311-macosx_13_0_x86_64.whl (4.6 MB view details)

Uploaded CPython 3.11macOS 13.0+ x86-64

gwframe-0.3.1-cp310-cp310-manylinux_2_34_x86_64.whl (18.7 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.34+ x86-64

gwframe-0.3.1-cp310-cp310-manylinux_2_34_aarch64.whl (18.3 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.34+ ARM64

gwframe-0.3.1-cp310-cp310-macosx_15_0_arm64.whl (4.5 MB view details)

Uploaded CPython 3.10macOS 15.0+ ARM64

gwframe-0.3.1-cp310-cp310-macosx_13_0_x86_64.whl (4.6 MB view details)

Uploaded CPython 3.10macOS 13.0+ x86-64

File details

Details for the file gwframe-0.3.1.tar.gz.

File metadata

  • Download URL: gwframe-0.3.1.tar.gz
  • Upload date:
  • Size: 6.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for gwframe-0.3.1.tar.gz
Algorithm Hash digest
SHA256 a09dd939ffaab8fe52a9252c9833fb223eafb6a475024b79513690c9261b07c2
MD5 3f778ea959a3928a6037a023b151cb42
BLAKE2b-256 0e9aba9663f8ec1904ac88c35256d04d7afc4c94781763640a1c24f5f71ed518

See more details on using hashes here.

File details

Details for the file gwframe-0.3.1-cp313-cp313-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for gwframe-0.3.1-cp313-cp313-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 917c328010aca753095829f39d451c01a5ad34c23622e4bb08c5ce18089d4c67
MD5 1e8ade56160063573d955afb7ef78ebe
BLAKE2b-256 996b9d16a1904a76a36b962d7a16b5a5f00c0365a32bfd4c65f549abe0ed6e99

See more details on using hashes here.

File details

Details for the file gwframe-0.3.1-cp313-cp313-manylinux_2_34_aarch64.whl.

File metadata

File hashes

Hashes for gwframe-0.3.1-cp313-cp313-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 4f5fc80c836fc85ecee70f9a99c354206fe45b60b22e0985eebd244584f75cd4
MD5 352fe6c15cc7c384c9ca553b960e2890
BLAKE2b-256 9e8e28a7ef1f302483c19488f3cc9096e7f36ec664861ac2025242060f8b8a03

See more details on using hashes here.

File details

Details for the file gwframe-0.3.1-cp313-cp313-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for gwframe-0.3.1-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 78ba6563df58f8b42d74b293e5590532bfaa37021f950613a013c018526a6742
MD5 82196ba82d083851ab2d516540a86566
BLAKE2b-256 7d2adf1d96ac9551b7503f66e8047597db0b34c51a09e49f8f38c275c834c37e

See more details on using hashes here.

File details

Details for the file gwframe-0.3.1-cp313-cp313-macosx_13_0_x86_64.whl.

File metadata

File hashes

Hashes for gwframe-0.3.1-cp313-cp313-macosx_13_0_x86_64.whl
Algorithm Hash digest
SHA256 1b4402931f54664acdaace6a56d9fc6bc43fa33a8ba1c550d0d76e20ef2d87e1
MD5 f3c3ad8979729cd91d1a0010531ab771
BLAKE2b-256 a22333a6c96a6081ec72385063f8e5f0980f7c66a71b4628639b65ed1835ee21

See more details on using hashes here.

File details

Details for the file gwframe-0.3.1-cp312-cp312-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for gwframe-0.3.1-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 a917243235fc42a013a77310fa0c1707a62a59ec99ba8f684509a50228428e44
MD5 e24ab95e7eda69dfcc4829b28cff424b
BLAKE2b-256 8a47bc39906f93026c309a5e13b909e805eb838aadff8a66dd417a950f54223c

See more details on using hashes here.

File details

Details for the file gwframe-0.3.1-cp312-cp312-manylinux_2_34_aarch64.whl.

File metadata

File hashes

Hashes for gwframe-0.3.1-cp312-cp312-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 d40ea389aec0cc1395347e83e051fba7ab5ae0eb3efa0ec18213b99ec49269b0
MD5 2bde5b570a1cbef8b502e7489b92f9ca
BLAKE2b-256 9c8e12b75eb4caa6bac568ce157998106db86611c9cf93a63b1e915088752368

See more details on using hashes here.

File details

Details for the file gwframe-0.3.1-cp312-cp312-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for gwframe-0.3.1-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 1f6116c35f7943cc66f0c1193d69037ae6c314d754c7532e9b28bddaa9d3ee17
MD5 234643af146483f10909aea144b5f808
BLAKE2b-256 b07a8000148e497c0cad919645ce27750bb0a23b7a58eff3584956f232367999

See more details on using hashes here.

File details

Details for the file gwframe-0.3.1-cp312-cp312-macosx_13_0_x86_64.whl.

File metadata

File hashes

Hashes for gwframe-0.3.1-cp312-cp312-macosx_13_0_x86_64.whl
Algorithm Hash digest
SHA256 998f1f866c0f9d9f6783ae13030491b049e8e22ea02796385d97a5644efc0b80
MD5 eebed72d8142863d86eefbf19e4f2bb5
BLAKE2b-256 573d295c303f4f05f93f9d052eb65dc1bb3be5e49918c738c088fbca3cdb5235

See more details on using hashes here.

File details

Details for the file gwframe-0.3.1-cp311-cp311-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for gwframe-0.3.1-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 2fb87399d61b3e6c400407a8d89a9858105e241ab3ba30764e57c18883d9dd11
MD5 79727ceeaf834184a7fe8da34fabfc94
BLAKE2b-256 6bf067b354869b3c3596cc870ce0d438ebf2746c1d9f05b042a57fccc5c42942

See more details on using hashes here.

File details

Details for the file gwframe-0.3.1-cp311-cp311-manylinux_2_34_aarch64.whl.

File metadata

File hashes

Hashes for gwframe-0.3.1-cp311-cp311-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 4c01023013cedaf844703118ba8b1edd693f052f6a18cefed40a08f72873c0c6
MD5 771cff3eaed153ed43238a005a545afa
BLAKE2b-256 5783e6b8ed8861bfc8a8259b31eb86b8cf70295bade3be1ccc7a5971fd68e75e

See more details on using hashes here.

File details

Details for the file gwframe-0.3.1-cp311-cp311-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for gwframe-0.3.1-cp311-cp311-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 2fe17d819c954cbc5156389698736545ab096312bac6674a73ae231fbb46bda0
MD5 6e9b1f7bc67134e1ec77a17310db165f
BLAKE2b-256 e00b76739dca6283deee02331fed87bdfdfa306287a1c02fec21c1d253ac8443

See more details on using hashes here.

File details

Details for the file gwframe-0.3.1-cp311-cp311-macosx_13_0_x86_64.whl.

File metadata

File hashes

Hashes for gwframe-0.3.1-cp311-cp311-macosx_13_0_x86_64.whl
Algorithm Hash digest
SHA256 459f83e3a1bb7b80b81abb142c5fbd5a512dc44d257dccfd844e5caebfbcb72d
MD5 174f6459efe32f842e5591e44afb0c52
BLAKE2b-256 d99e544239d0eb44ca227c5042fbaaf6c56a3c8e601c10a916f79688e394d6c6

See more details on using hashes here.

File details

Details for the file gwframe-0.3.1-cp310-cp310-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for gwframe-0.3.1-cp310-cp310-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 fa863365c682d1d538311afac9dd8983d0f03194bedf497f4751f521104dd586
MD5 a9ac879e68c22147158a0fa9cc03c67e
BLAKE2b-256 f82c36eff068d9c34ea517e6139b0c9729bf529cf535a22fff2f8a3f7c588d94

See more details on using hashes here.

File details

Details for the file gwframe-0.3.1-cp310-cp310-manylinux_2_34_aarch64.whl.

File metadata

File hashes

Hashes for gwframe-0.3.1-cp310-cp310-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 5afebb65bcce9b412c1c80ac9646789de00b1cc96b94ff871380f38b1b3b1641
MD5 3ea9084e79a5a7f4eb91651041370e84
BLAKE2b-256 689321195c258c2f873f07f577e2182119e84da64e3e2315497b6d7d3435dd7c

See more details on using hashes here.

File details

Details for the file gwframe-0.3.1-cp310-cp310-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for gwframe-0.3.1-cp310-cp310-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 e8bbfc50a11a547d65cd7381cff2fe7aa201027c1a450d0c27bcc24d37e2b996
MD5 18a71f6ee12293534d7d71d7e1eb8c91
BLAKE2b-256 2c0efabfdf9468c7d6d70238ccf65f423c7d949206a673b7144ef28bae6dcae9

See more details on using hashes here.

File details

Details for the file gwframe-0.3.1-cp310-cp310-macosx_13_0_x86_64.whl.

File metadata

File hashes

Hashes for gwframe-0.3.1-cp310-cp310-macosx_13_0_x86_64.whl
Algorithm Hash digest
SHA256 c505db9a3cf8e4e1db0bc3a2f6509697687ed6bf4239ca63d740a7c6a5985680
MD5 fa2d1058f603c77892058a15fd1180e5
BLAKE2b-256 07b53a775f27bcaab4fac2c35b859c6752441b9dbc1f58301f79b9704b67bc9a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page