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-cleanercleans lines from Short Fourier Transform (SFT) files
Installation
Install from PyPI:
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 filefit(frequency, spectrum)- Fit baseline to spectrumload_and_fit(detector_asd_src)- Load and fit in one stepload_and_fit_multiple(detector_asd_srcs)- Process multiple detectors
Line Detection
detect_lines(frequency, spectrum, baseline)- Detect spectral linesdetect_lines_multiple(detector_data)- Detect lines for multiple detectorsfind_and_plot(frequency, spectrum, baseline)- Detect and visualize
Coherent Analysis
analyze_coherent_lines(detector_asd_srcs)- Full coherent analysisanalyze_coherent_lines_from_data(detector_data)- Analysis from pre-loaded dataplot_results(coherent_groups, detector_data)- Visualize resultsprint_summary(coherent_groups, detector_data)- Print analysis summary
Cleaning
clean_lines_from_PSD(freq, detector_psds, detector_clean)- Core cleaning functionget_cleaning_mask(freq, detector_psds)- Get boolean cleaning masksapply_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.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| gw_line_cleaner-0.2.1.tar.gz | 43.0 kB | With provenance | Details for gw_line_cleaner-0.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| gw_line_cleaner-0.2.1-py3-none-any.whl | Python 3 | none | any | Details for gw_line_cleaner-0.2.1-py3-none-any.whl |
Total release size: 83.8 kB
Release files / gw_line_cleaner-0.2.1.tar.gz
| Download URL | gw_line_cleaner-0.2.1.tar.gz |
|---|---|
| Size | 43.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
83487d12fb20c2606a96f85a1443a0e35811702b1667f107c92865957a7a4e9d
|
|
BLAKE2b-256 checksum How to use checksums |
98a398de494d74f9928c504bf7f3c398f01d64103a140b59d985a15ea7456b7a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 7, 2026.
Transparency logRelease files / gw_line_cleaner-0.2.1-py3-none-any.whl
| Download URL | gw_line_cleaner-0.2.1-py3-none-any.whl |
|---|---|
| Size | 40.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
87edc01fa61f576c292fa0140eeef1bff1582279d903df02f37cc93bc5e3f6a0
|
|
BLAKE2b-256 checksum How to use checksums |
50428fc45b8c72bd89644a8d94de86808856479c2a4da3b944e8153c48256cac
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 7, 2026.
Transparency logSecurity for gw-line-cleaner 0.2.1
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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for gw_line_cleaner-0.2.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 7, 2026.
Transparency logA 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.