Skip to main content

GW Line Cleaner

Remove line artifacts from gravitational wave data.

A Python package for detecting and removing spectral line artifacts from gravitational wave detector data. Supports analysis across arbitrary numbers of detectors (LIGO H1/L1, Virgo, KAGRA, etc.).

Features

  • Baseline fitting: Robust polynomial baseline estimation for ASD/PSD spectra
  • Line detection: Automatic detection of spectral lines using peak finding algorithms
  • Coherent analysis: Identify lines appearing across multiple detectors (potential astrophysical signals)
  • Line cleaning: Remove instrument-specific artifacts while preserving coherent signals
  • Command-line utility: gw-line-cleaner cleans lines from Short Fourier Transform (SFT) files

Installation

Install from PyPI (when available):

pip install gw-line-cleaner

Or install from source:

git clone https://github.com/gwda/gw-line-cleaner.git
cd gw-line-cleaner
pip install -e .

Python Interface

Basic Usage

import gw_line_cleaner as gwlc

# Load and fit baseline for a single detector
frequency, spectrum, result = gwlc.load_and_fit("path/to/spectrum.txt")

# View fitting results
result.info(detector_name="H1")
result.plot(frequency, spectrum, detector_name="H1")

# Detect spectral lines
lines = gwlc.detect_lines(frequency, spectrum, result.baseline, detector_name="H1")
print(f"Detected {len(lines)} lines")

Multi-Detector Coherent Analysis

import gw_line_cleaner as gwlc

# Define detector data files
detector_files = {
    "H1": "path/to/h1_spectrum.txt",
    "L1": "path/to/l1_spectrum.txt",
    "V1": "path/to/v1_spectrum.txt",  # Optional: add more detectors
}

# Analyze coherent lines across detectors
coherent_groups, detector_data = gwlc.analyze_coherent_lines(
    detector_files,
    min_detectors=2  # Lines must appear in at least 2 detectors
)

# Print summary
gwlc.print_summary(coherent_groups, detector_data)

# Plot results
gwlc.plot_results(coherent_groups, detector_data, save_path="coherent_analysis.png")

Line Cleaning

import gw_line_cleaner as gwlc
import numpy as np

# Prepare PSD data for multiple detectors
freq = np.linspace(10, 2000, 100000)
detector_psds = {
    "H1": h1_psd_array,
    "L1": l1_psd_array,
}

# Get cleaned PSDs (incoherent lines removed, coherent lines preserved)
cleaned_psds, masks = gwlc.apply_cleaning(freq, detector_psds, min_detectors=2)

# Or get just the cleaning masks
masks = gwlc.get_cleaning_mask(freq, detector_psds, min_detectors=2)

API Reference

Baseline Fitting

  • load(file_path) - Load spectrum data from file
  • fit(frequency, spectrum) - Fit baseline to spectrum
  • load_and_fit(detector_asd_src) - Load and fit in one step
  • load_and_fit_multiple(detector_asd_srcs) - Process multiple detectors

Line Detection

  • detect_lines(frequency, spectrum, baseline) - Detect spectral lines
  • detect_lines_multiple(detector_data) - Detect lines for multiple detectors
  • find_and_plot(frequency, spectrum, baseline) - Detect and visualize

Coherent Analysis

  • analyze_coherent_lines(detector_asd_srcs) - Full coherent analysis
  • analyze_coherent_lines_from_data(detector_data) - Analysis from pre-loaded data
  • plot_results(coherent_groups, detector_data) - Visualize results
  • print_summary(coherent_groups, detector_data) - Print analysis summary

Cleaning

  • clean_lines_from_PSD(freq, detector_psds, detector_clean) - Core cleaning function
  • get_cleaning_mask(freq, detector_psds) - Get boolean cleaning masks
  • apply_cleaning(freq, detector_psds) - Apply cleaning and return cleaned PSDs

Command Line Utility

The gw-line-cleaner utility cleans lines from Short Fourier Transform (SFT, SFT) files, the standard data product utilised by continuous gravitational data analysis routines from the LALSuite library.

Usage

gw-line-cleaner [-h] [-l {DEBUG,INFO,WARNING,ERROR,CRITICAL}] [-t TEMP_DIR]
                -i INPUT_SFTS -o OUTPUT_SFT_DIR
                [-I INJECT_PARAMS] [-D]
                [-B FSTAT_BEFORE_PARAMS] [-A FSTAT_AFTER_PARAMS]
                [-O OUTPUT_STATS] [-S] [-P OUTPUT_SPECTRA_PLOTS]
                [-e EARTH_EPHEMERIS] [-s SUN_EPHEMERIS]

Options

  • -h, --help: Show this help message and exit.
  • -l, --log-level {DEBUG,INFO,WARNING,ERROR,CRITICAL}: Set the logging level (default: INFO).
  • -t, --temp-dir TEMP_DIR: Temporary directory to write intermediate files.
  • -i, --input-SFTs INPUT_SFTS: Input SFTs. Either a directory containing SFT files, or a text file containing SFT filenames.
  • -o, --output-SFT-dir OUTPUT_SFT_DIR: Directory in which to write output SFTs.
  • -I, --inject-params INJECT_PARAMS: If given, configuration file with parameters of a continuous wave signal to be injected into the input SFTs before cleaning. If argument contains a colon, the string before the colon is the filename, and the string after the colon is the section to read the parameters from.
  • -D, --inject-as-depth: If true, injection amplitudes are interpreted as (inverse) sensitivity depths, i.e. (h0, aPlus, aCross) => (h0, aPlus, aCross) * sqrt(Sh).
  • -B, --Fstat-before-params FSTAT_BEFORE_PARAMS: If given, configuration file with parameters of a continuous wave signal at which to compute the F-statistic before cleaning. If argument contains a colon, the string before the colon is the filename, and the string after the colon is the section to read the parameters from.
  • -A, --Fstat-after-params FSTAT_AFTER_PARAMS: If given, configuration file with parameters of a continuous wave signal at which to compute the F-statistic after cleaning. If argument contains a colon, the string before the colon is the filename, and the string after the colon is the section to read the parameters from.
  • -O, --output-stats OUTPUT_STATS: Path to HDF5 file where various statistics will be written.
  • -S, --output-spectra: Include amplitude spectral densities before/after cleaning in output statistics.
  • -P, --output-spectra-plots OUTPUT_SPECTRA_PLOTS: Path to image file where plots of amplitude spectral densities before/after cleaning will be written.
  • -e, --earth-ephemeris EARTH_EPHEMERIS: Earth ephemeris file to use.
  • -s, --sun-ephemeris SUN_EPHEMERIS: Sun ephemeris file to use.

License

MIT License

Metadata

Release files for gw-line-cleaner 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gw-line-cleaner 0.2.0
File Size Uploaded Provenance Actions
gw_line_cleaner-0.2.0.tar.gz 41.8 kB Without provenance Details for gw_line_cleaner-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for gw-line-cleaner 0.2.0
File Interpreter ABI Platform Actions
gw_line_cleaner-0.2.0-py3-none-any.whl Python 3 none any Details for gw_line_cleaner-0.2.0-py3-none-any.whl

Total release size: 82.6 kB

Release files / gw_line_cleaner-0.2.0.tar.gz

Download URL gw_line_cleaner-0.2.0.tar.gz
Size 41.8 kB
Tags Source
SHA-256 checksum
How to use checksums
7e3e36483fe4177b860281b2c2b5951cabcd7b6a61e8276dc2c10d372067a466
BLAKE2b-256 checksum
How to use checksums
f605a29d21ad2aa840bd9917d181f759958ee2362b59d14bc14968eaa1877b76
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.15

Release files / gw_line_cleaner-0.2.0-py3-none-any.whl

Download URL gw_line_cleaner-0.2.0-py3-none-any.whl
Size 40.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7f2be63b7332db9e0b147626b6049439fd4ea8d0090e97f18c97974123fe970a
BLAKE2b-256 checksum
How to use checksums
7ce7eca556d9e7bcc5be52ebbc1f841e479dd0ef4025af4abcfbb0704d4056bc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.15

Security for gw-line-cleaner 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page