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.0.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.0-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.0-cp313-cp313-manylinux_2_34_aarch64.whl (18.2 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ ARM64

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

Uploaded CPython 3.13macOS 15.0+ ARM64

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

Uploaded CPython 3.13macOS 13.0+ x86-64

gwframe-0.3.0-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.0-cp312-cp312-manylinux_2_34_aarch64.whl (18.2 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ ARM64

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

Uploaded CPython 3.12macOS 15.0+ ARM64

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

Uploaded CPython 3.12macOS 13.0+ x86-64

gwframe-0.3.0-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.0-cp311-cp311-manylinux_2_34_aarch64.whl (18.2 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.34+ ARM64

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

Uploaded CPython 3.11macOS 15.0+ ARM64

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

Uploaded CPython 3.11macOS 13.0+ x86-64

gwframe-0.3.0-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.0-cp310-cp310-manylinux_2_34_aarch64.whl (18.2 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.34+ ARM64

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

Uploaded CPython 3.10macOS 15.0+ ARM64

gwframe-0.3.0-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.0.tar.gz.

File metadata

  • Download URL: gwframe-0.3.0.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.0.tar.gz
Algorithm Hash digest
SHA256 200009766d2d7195a6475a08c4b77ff6ae84a3643eaf2b3a4f3945a2bfff924b
MD5 36701694a9f50b188791b1f60b338c9a
BLAKE2b-256 6a1a725bfa15bef171dc53106c3711ce5758fef2dbf5d14225b8d9ec1d5f3a3d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gwframe-0.3.0-cp313-cp313-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 14757116a9313a6b46e40a5939265feef92f9387f4bab23da5b6474a757af341
MD5 b8a587118cb461e487340b54b170fe7e
BLAKE2b-256 4c6b3dfba71a988d61762818cbf95ff78728793e6aeded838a5fc1859ec3ab5f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gwframe-0.3.0-cp313-cp313-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 3ebbfca53d395f2078b32b4c0a034b4db2a73e7da8067aa1a8c1486748135d6a
MD5 48fdb8e26914992108dbc9432ff256a0
BLAKE2b-256 6832b09be6a803f190c44b6cb903a9de1648e151ecc4a04cb1a234ac3a9f506f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gwframe-0.3.0-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 ad1e1b096a28b6a600cd9d30108469e1e37ec3fd2cb8dadd4aaa4694f36cb118
MD5 b46f425c4bf1ad00c85aa984523778cf
BLAKE2b-256 302de3afcbb4b89be21735b23068e82318e625afa7b478ed9079c2e6c871539d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gwframe-0.3.0-cp313-cp313-macosx_13_0_x86_64.whl
Algorithm Hash digest
SHA256 18c058efd560f2de02d96be42566dab154545d3523b950c696e8bc5455e2cbe2
MD5 b3f6bb5e29690a32e362de7e4201d69f
BLAKE2b-256 97437dfa718c50bfda9c987de52d6e9f31c2c5c1d6c9dc2b3693282c577b8511

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gwframe-0.3.0-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 06a4fbfdd2bc371503612cd0fdb0c7bcc7d0fe5c1aae1a5d35679a506e2181a2
MD5 dc6a0d7842206c471b4428c73143b7f6
BLAKE2b-256 3d3cbee58f81c413cbe41e34bc44e4564f697c6054cea8cb3be35c9facf2bdbb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gwframe-0.3.0-cp312-cp312-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 b510476098ca1aa40e48950443c58e56bf54b2f6300114fbbda5fe0cfea8c495
MD5 4a90195b933d40f9a4130f85faf15ea4
BLAKE2b-256 a372544833d327eeccbef3d53b038fa09cf6631b2d063b0e53ecc416d89350c6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gwframe-0.3.0-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 b89fc5a175d5825f2f20c03ea4cc800fa8e42a9d93acba98bb2da7b118ea48ad
MD5 c9ddf4a4bd0d873ec2ec3bf6fd5a0735
BLAKE2b-256 f0364cf77d245544bfed8d1c1b1004806ef9d917f23fc36724ef52aabb995684

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gwframe-0.3.0-cp312-cp312-macosx_13_0_x86_64.whl
Algorithm Hash digest
SHA256 61fd52809b9a745f85f53cc9298cb88fc25cde45133a0093f07b85d36fcb16bd
MD5 84f2ee6000c1936dd81915ece6c70e6b
BLAKE2b-256 452850ae52eb6453da9dd025defe9c978820ef432df06640f07880797eed60ed

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gwframe-0.3.0-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 af555f00799095ebb821ee512983179f8f934efe468f3eeed22dcc1d8684f851
MD5 b1e2a9617f3bc5c37b1b7e0fbe42bdb7
BLAKE2b-256 b053de3e0702a25da773cc696f8560c5b9d4eaadb1c98b089e4d908db29788a7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gwframe-0.3.0-cp311-cp311-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 bbd3f781162fbcb156b36861cd4ea5600a58f8f6a684ab8c13b1210a7c712889
MD5 b9641e4fe84cf607a4a790e4d575467e
BLAKE2b-256 b484092bb3c63025ae31bcc53e8f9d0e8e4d5c17f23e7ad3ffcf337975d9c4ba

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gwframe-0.3.0-cp311-cp311-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 e177d28379b633dec804c93bbd896ed4b52de922e80bee9efab99599e6af192c
MD5 522a1fd6b07d51045672607c026aa9b4
BLAKE2b-256 dcf2c43728dee96cdee802de5f4b3c47bdc038174c9fcbde1cd0b20701678968

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gwframe-0.3.0-cp311-cp311-macosx_13_0_x86_64.whl
Algorithm Hash digest
SHA256 422ffe78b3bd16b5fd05782ead7b0506e101db4085687e0aa853ebc32e17b072
MD5 766799a24d3b7c104da7d9c9a8075893
BLAKE2b-256 43fa3bd6b17cd7f24723b1863c8edc3afab5486bfc03bb55042bc26e8a39e4d5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gwframe-0.3.0-cp310-cp310-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 f9ef29fee62e1c764fb7b295e5c5a45eeab00ce814affb90a87875da38ce71a4
MD5 1a85da3b3500b68f695825553e868580
BLAKE2b-256 788af8d95bc1a1d10ef01acd0896276ebf11f78d49c40840f00c4c33830e8d46

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gwframe-0.3.0-cp310-cp310-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 e998893527186f33f99b1dbee6648abb37a04698508662b96bf5cdeb279a59dc
MD5 07de03a4fec96d8761cc81658f4907b2
BLAKE2b-256 6c8dd9f80f6c9b4584562b4f36f6c54c4fbc2e62a51b6c5d47188fb339ae0068

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gwframe-0.3.0-cp310-cp310-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 b3d802efa926b8153fb984f4ae629b8d9006fa3c5369a78ad83e28dcd299688c
MD5 0eac6e3495fca158b4fbde4888adaaeb
BLAKE2b-256 c5b8271b876515198ad0cb0e5c7c5402e7ac727aa3a8cd5fddc677f61a3090ae

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gwframe-0.3.0-cp310-cp310-macosx_13_0_x86_64.whl
Algorithm Hash digest
SHA256 d10d8bacb6acab9ff330111a64b2a7ad172ce56cffbdf5fdaea9c973114fb820
MD5 3e637dc96dbe94bdc3393b77dd74fd7e
BLAKE2b-256 5eedd73e3187dab97b3af40c66fea2561b9956f8419a879144278dcae6392b57

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