gw-line-cleaner 0.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- gw_line_cleaner-0.2.0/.gitignore +3 -0
- gw_line_cleaner-0.2.0/.pre-commit-config.yaml +46 -0
- gw_line_cleaner-0.2.0/LICENSE +18 -0
- gw_line_cleaner-0.2.0/LICENSES/CC0-1.0.txt +121 -0
- gw_line_cleaner-0.2.0/LICENSES/MIT.txt +18 -0
- gw_line_cleaner-0.2.0/PKG-INFO +221 -0
- gw_line_cleaner-0.2.0/README.md +191 -0
- gw_line_cleaner-0.2.0/REUSE.toml +19 -0
- gw_line_cleaner-0.2.0/pyproject.toml +121 -0
- gw_line_cleaner-0.2.0/requirements-dev.txt +7 -0
- gw_line_cleaner-0.2.0/setup.cfg +4 -0
- gw_line_cleaner-0.2.0/src/gw_line_cleaner/__init__.py +97 -0
- gw_line_cleaner-0.2.0/src/gw_line_cleaner/baseline_fit.py +824 -0
- gw_line_cleaner-0.2.0/src/gw_line_cleaner/cleaner.py +420 -0
- gw_line_cleaner-0.2.0/src/gw_line_cleaner/cli.py +745 -0
- gw_line_cleaner-0.2.0/src/gw_line_cleaner/coherent_analyzer.py +814 -0
- gw_line_cleaner-0.2.0/src/gw_line_cleaner/simple_line_detector.py +701 -0
- gw_line_cleaner-0.2.0/src/gw_line_cleaner.egg-info/PKG-INFO +221 -0
- gw_line_cleaner-0.2.0/src/gw_line_cleaner.egg-info/SOURCES.txt +24 -0
- gw_line_cleaner-0.2.0/src/gw_line_cleaner.egg-info/dependency_links.txt +1 -0
- gw_line_cleaner-0.2.0/src/gw_line_cleaner.egg-info/entry_points.txt +2 -0
- gw_line_cleaner-0.2.0/src/gw_line_cleaner.egg-info/requires.txt +8 -0
- gw_line_cleaner-0.2.0/src/gw_line_cleaner.egg-info/scm_file_list.json +20 -0
- gw_line_cleaner-0.2.0/src/gw_line_cleaner.egg-info/scm_version.json +8 -0
- gw_line_cleaner-0.2.0/src/gw_line_cleaner.egg-info/top_level.txt +1 -0
- gw_line_cleaner-0.2.0/test/test_cleaning.py +82 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
default_install_hook_types: [pre-commit, post-commit]
|
|
2
|
+
|
|
3
|
+
repos:
|
|
4
|
+
|
|
5
|
+
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
6
|
+
rev: v6.0.0
|
|
7
|
+
hooks:
|
|
8
|
+
- id: trailing-whitespace
|
|
9
|
+
- id: end-of-file-fixer
|
|
10
|
+
- id: check-added-large-files
|
|
11
|
+
- id: check-toml
|
|
12
|
+
- id: check-yaml
|
|
13
|
+
- id: file-contents-sorter
|
|
14
|
+
args: [--unique]
|
|
15
|
+
files: ^\.gitattributes$|^\.gitignore$|^requirements-dev\.txt$
|
|
16
|
+
|
|
17
|
+
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
18
|
+
rev: v0.16.1
|
|
19
|
+
hooks:
|
|
20
|
+
- id: ruff-check
|
|
21
|
+
|
|
22
|
+
- repo: https://github.com/jsh9/pydoclint
|
|
23
|
+
rev: 0.9.1
|
|
24
|
+
hooks:
|
|
25
|
+
- id: pydoclint
|
|
26
|
+
|
|
27
|
+
- repo: https://github.com/assorted-pre-commit-hooks/copyright
|
|
28
|
+
rev: v0.12
|
|
29
|
+
hooks:
|
|
30
|
+
- id: copyright
|
|
31
|
+
|
|
32
|
+
- repo: https://github.com/psf/black
|
|
33
|
+
rev: 26.5.1
|
|
34
|
+
hooks:
|
|
35
|
+
- id: black
|
|
36
|
+
args: [--target-version=py310]
|
|
37
|
+
|
|
38
|
+
- repo: https://github.com/pre-commit/mirrors-mypy
|
|
39
|
+
rev: v2.3.0
|
|
40
|
+
hooks:
|
|
41
|
+
- id: mypy
|
|
42
|
+
|
|
43
|
+
- repo: https://github.com/assorted-pre-commit-hooks/version-tag
|
|
44
|
+
rev: v0.1
|
|
45
|
+
hooks:
|
|
46
|
+
- id: version-tag
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025-2026 Ye Zhou, Karl Wette
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
|
6
|
+
associated documentation files (the "Software"), to deal in the Software without restriction, including
|
|
7
|
+
without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the
|
|
9
|
+
following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial
|
|
12
|
+
portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
|
15
|
+
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
|
|
16
|
+
EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
17
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
18
|
+
USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
Creative Commons Legal Code
|
|
2
|
+
|
|
3
|
+
CC0 1.0 Universal
|
|
4
|
+
|
|
5
|
+
CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
|
|
6
|
+
LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
|
|
7
|
+
ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
|
|
8
|
+
INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
|
|
9
|
+
REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
|
|
10
|
+
PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
|
|
11
|
+
THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
|
|
12
|
+
HEREUNDER.
|
|
13
|
+
|
|
14
|
+
Statement of Purpose
|
|
15
|
+
|
|
16
|
+
The laws of most jurisdictions throughout the world automatically confer
|
|
17
|
+
exclusive Copyright and Related Rights (defined below) upon the creator
|
|
18
|
+
and subsequent owner(s) (each and all, an "owner") of an original work of
|
|
19
|
+
authorship and/or a database (each, a "Work").
|
|
20
|
+
|
|
21
|
+
Certain owners wish to permanently relinquish those rights to a Work for
|
|
22
|
+
the purpose of contributing to a commons of creative, cultural and
|
|
23
|
+
scientific works ("Commons") that the public can reliably and without fear
|
|
24
|
+
of later claims of infringement build upon, modify, incorporate in other
|
|
25
|
+
works, reuse and redistribute as freely as possible in any form whatsoever
|
|
26
|
+
and for any purposes, including without limitation commercial purposes.
|
|
27
|
+
These owners may contribute to the Commons to promote the ideal of a free
|
|
28
|
+
culture and the further production of creative, cultural and scientific
|
|
29
|
+
works, or to gain reputation or greater distribution for their Work in
|
|
30
|
+
part through the use and efforts of others.
|
|
31
|
+
|
|
32
|
+
For these and/or other purposes and motivations, and without any
|
|
33
|
+
expectation of additional consideration or compensation, the person
|
|
34
|
+
associating CC0 with a Work (the "Affirmer"), to the extent that he or she
|
|
35
|
+
is an owner of Copyright and Related Rights in the Work, voluntarily
|
|
36
|
+
elects to apply CC0 to the Work and publicly distribute the Work under its
|
|
37
|
+
terms, with knowledge of his or her Copyright and Related Rights in the
|
|
38
|
+
Work and the meaning and intended legal effect of CC0 on those rights.
|
|
39
|
+
|
|
40
|
+
1. Copyright and Related Rights. A Work made available under CC0 may be
|
|
41
|
+
protected by copyright and related or neighboring rights ("Copyright and
|
|
42
|
+
Related Rights"). Copyright and Related Rights include, but are not
|
|
43
|
+
limited to, the following:
|
|
44
|
+
|
|
45
|
+
i. the right to reproduce, adapt, distribute, perform, display,
|
|
46
|
+
communicate, and translate a Work;
|
|
47
|
+
ii. moral rights retained by the original author(s) and/or performer(s);
|
|
48
|
+
iii. publicity and privacy rights pertaining to a person's image or
|
|
49
|
+
likeness depicted in a Work;
|
|
50
|
+
iv. rights protecting against unfair competition in regards to a Work,
|
|
51
|
+
subject to the limitations in paragraph 4(a), below;
|
|
52
|
+
v. rights protecting the extraction, dissemination, use and reuse of data
|
|
53
|
+
in a Work;
|
|
54
|
+
vi. database rights (such as those arising under Directive 96/9/EC of the
|
|
55
|
+
European Parliament and of the Council of 11 March 1996 on the legal
|
|
56
|
+
protection of databases, and under any national implementation
|
|
57
|
+
thereof, including any amended or successor version of such
|
|
58
|
+
directive); and
|
|
59
|
+
vii. other similar, equivalent or corresponding rights throughout the
|
|
60
|
+
world based on applicable law or treaty, and any national
|
|
61
|
+
implementations thereof.
|
|
62
|
+
|
|
63
|
+
2. Waiver. To the greatest extent permitted by, but not in contravention
|
|
64
|
+
of, applicable law, Affirmer hereby overtly, fully, permanently,
|
|
65
|
+
irrevocably and unconditionally waives, abandons, and surrenders all of
|
|
66
|
+
Affirmer's Copyright and Related Rights and associated claims and causes
|
|
67
|
+
of action, whether now known or unknown (including existing as well as
|
|
68
|
+
future claims and causes of action), in the Work (i) in all territories
|
|
69
|
+
worldwide, (ii) for the maximum duration provided by applicable law or
|
|
70
|
+
treaty (including future time extensions), (iii) in any current or future
|
|
71
|
+
medium and for any number of copies, and (iv) for any purpose whatsoever,
|
|
72
|
+
including without limitation commercial, advertising or promotional
|
|
73
|
+
purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
|
|
74
|
+
member of the public at large and to the detriment of Affirmer's heirs and
|
|
75
|
+
successors, fully intending that such Waiver shall not be subject to
|
|
76
|
+
revocation, rescission, cancellation, termination, or any other legal or
|
|
77
|
+
equitable action to disrupt the quiet enjoyment of the Work by the public
|
|
78
|
+
as contemplated by Affirmer's express Statement of Purpose.
|
|
79
|
+
|
|
80
|
+
3. Public License Fallback. Should any part of the Waiver for any reason
|
|
81
|
+
be judged legally invalid or ineffective under applicable law, then the
|
|
82
|
+
Waiver shall be preserved to the maximum extent permitted taking into
|
|
83
|
+
account Affirmer's express Statement of Purpose. In addition, to the
|
|
84
|
+
extent the Waiver is so judged Affirmer hereby grants to each affected
|
|
85
|
+
person a royalty-free, non transferable, non sublicensable, non exclusive,
|
|
86
|
+
irrevocable and unconditional license to exercise Affirmer's Copyright and
|
|
87
|
+
Related Rights in the Work (i) in all territories worldwide, (ii) for the
|
|
88
|
+
maximum duration provided by applicable law or treaty (including future
|
|
89
|
+
time extensions), (iii) in any current or future medium and for any number
|
|
90
|
+
of copies, and (iv) for any purpose whatsoever, including without
|
|
91
|
+
limitation commercial, advertising or promotional purposes (the
|
|
92
|
+
"License"). The License shall be deemed effective as of the date CC0 was
|
|
93
|
+
applied by Affirmer to the Work. Should any part of the License for any
|
|
94
|
+
reason be judged legally invalid or ineffective under applicable law, such
|
|
95
|
+
partial invalidity or ineffectiveness shall not invalidate the remainder
|
|
96
|
+
of the License, and in such case Affirmer hereby affirms that he or she
|
|
97
|
+
will not (i) exercise any of his or her remaining Copyright and Related
|
|
98
|
+
Rights in the Work or (ii) assert any associated claims and causes of
|
|
99
|
+
action with respect to the Work, in either case contrary to Affirmer's
|
|
100
|
+
express Statement of Purpose.
|
|
101
|
+
|
|
102
|
+
4. Limitations and Disclaimers.
|
|
103
|
+
|
|
104
|
+
a. No trademark or patent rights held by Affirmer are waived, abandoned,
|
|
105
|
+
surrendered, licensed or otherwise affected by this document.
|
|
106
|
+
b. Affirmer offers the Work as-is and makes no representations or
|
|
107
|
+
warranties of any kind concerning the Work, express, implied,
|
|
108
|
+
statutory or otherwise, including without limitation warranties of
|
|
109
|
+
title, merchantability, fitness for a particular purpose, non
|
|
110
|
+
infringement, or the absence of latent or other defects, accuracy, or
|
|
111
|
+
the present or absence of errors, whether or not discoverable, all to
|
|
112
|
+
the greatest extent permissible under applicable law.
|
|
113
|
+
c. Affirmer disclaims responsibility for clearing rights of other persons
|
|
114
|
+
that may apply to the Work or any use thereof, including without
|
|
115
|
+
limitation any person's Copyright and Related Rights in the Work.
|
|
116
|
+
Further, Affirmer disclaims responsibility for obtaining any necessary
|
|
117
|
+
consents, permissions or other rights required for any use of the
|
|
118
|
+
Work.
|
|
119
|
+
d. Affirmer understands and acknowledges that Creative Commons is not a
|
|
120
|
+
party to this document and has no duty or obligation with respect to
|
|
121
|
+
this CC0 or use of the Work.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025-2026 Ye Zhou, Karl Wette
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
|
6
|
+
associated documentation files (the "Software"), to deal in the Software without restriction, including
|
|
7
|
+
without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the
|
|
9
|
+
following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial
|
|
12
|
+
portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
|
15
|
+
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
|
|
16
|
+
EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
17
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
18
|
+
USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: gw-line-cleaner
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Remove line artifacts from gravitational wave data
|
|
5
|
+
Author-email: Ye Zhou <u7993710@anu.edu.au>, Karl Wette <karl.wette@anu.edu.au>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/gwda/gw-line-cleaner
|
|
8
|
+
Project-URL: Issues, https://github.com/gwda/gw-line-cleaner/issues
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
13
|
+
Classifier: Operating System :: OS Independent
|
|
14
|
+
Classifier: Intended Audience :: Science/Research
|
|
15
|
+
Classifier: Topic :: Scientific/Engineering :: Astronomy
|
|
16
|
+
Classifier: Topic :: Scientific/Engineering :: Physics
|
|
17
|
+
Requires-Python: >=3.10
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
License-File: LICENSES/MIT.txt
|
|
20
|
+
License-File: LICENSES/CC0-1.0.txt
|
|
21
|
+
Requires-Dist: astropy>=5.0
|
|
22
|
+
Requires-Dist: coloredlogs>=15.0
|
|
23
|
+
Requires-Dist: h5py>=3.16
|
|
24
|
+
Requires-Dist: lalsuite[lalpulsar]>=7.26
|
|
25
|
+
Requires-Dist: matplotlib>=3.4
|
|
26
|
+
Requires-Dist: numba>=0.55
|
|
27
|
+
Requires-Dist: numpy>=1.20
|
|
28
|
+
Requires-Dist: scipy>=1.7
|
|
29
|
+
Dynamic: license-file
|
|
30
|
+
|
|
31
|
+
# GW Line Cleaner
|
|
32
|
+
|
|
33
|
+
Remove line artifacts from gravitational wave data.
|
|
34
|
+
|
|
35
|
+
A Python package for detecting and removing spectral line artifacts from
|
|
36
|
+
gravitational wave detector data. Supports analysis across arbitrary numbers of
|
|
37
|
+
detectors (LIGO H1/L1, Virgo, KAGRA, etc.).
|
|
38
|
+
|
|
39
|
+
## Features
|
|
40
|
+
|
|
41
|
+
- **Baseline fitting**: Robust polynomial baseline estimation for ASD/PSD
|
|
42
|
+
spectra
|
|
43
|
+
- **Line detection**: Automatic detection of spectral lines using peak finding
|
|
44
|
+
algorithms
|
|
45
|
+
- **Coherent analysis**: Identify lines appearing across multiple detectors
|
|
46
|
+
(potential astrophysical signals)
|
|
47
|
+
- **Line cleaning**: Remove instrument-specific artifacts while preserving
|
|
48
|
+
coherent signals
|
|
49
|
+
- **Command-line utility**: `gw-line-cleaner` cleans lines from Short Fourier
|
|
50
|
+
Transform (SFT) files
|
|
51
|
+
|
|
52
|
+
## Installation
|
|
53
|
+
|
|
54
|
+
Install from PyPI (when available):
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
pip install gw-line-cleaner
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Or install from source:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
git clone https://github.com/gwda/gw-line-cleaner.git
|
|
64
|
+
cd gw-line-cleaner
|
|
65
|
+
pip install -e .
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Python Interface
|
|
69
|
+
|
|
70
|
+
### Basic Usage
|
|
71
|
+
|
|
72
|
+
```python
|
|
73
|
+
import gw_line_cleaner as gwlc
|
|
74
|
+
|
|
75
|
+
# Load and fit baseline for a single detector
|
|
76
|
+
frequency, spectrum, result = gwlc.load_and_fit("path/to/spectrum.txt")
|
|
77
|
+
|
|
78
|
+
# View fitting results
|
|
79
|
+
result.info(detector_name="H1")
|
|
80
|
+
result.plot(frequency, spectrum, detector_name="H1")
|
|
81
|
+
|
|
82
|
+
# Detect spectral lines
|
|
83
|
+
lines = gwlc.detect_lines(frequency, spectrum, result.baseline, detector_name="H1")
|
|
84
|
+
print(f"Detected {len(lines)} lines")
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Multi-Detector Coherent Analysis
|
|
88
|
+
|
|
89
|
+
```python
|
|
90
|
+
import gw_line_cleaner as gwlc
|
|
91
|
+
|
|
92
|
+
# Define detector data files
|
|
93
|
+
detector_files = {
|
|
94
|
+
"H1": "path/to/h1_spectrum.txt",
|
|
95
|
+
"L1": "path/to/l1_spectrum.txt",
|
|
96
|
+
"V1": "path/to/v1_spectrum.txt", # Optional: add more detectors
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
# Analyze coherent lines across detectors
|
|
100
|
+
coherent_groups, detector_data = gwlc.analyze_coherent_lines(
|
|
101
|
+
detector_files,
|
|
102
|
+
min_detectors=2 # Lines must appear in at least 2 detectors
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
# Print summary
|
|
106
|
+
gwlc.print_summary(coherent_groups, detector_data)
|
|
107
|
+
|
|
108
|
+
# Plot results
|
|
109
|
+
gwlc.plot_results(coherent_groups, detector_data, save_path="coherent_analysis.png")
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Line Cleaning
|
|
113
|
+
|
|
114
|
+
```python
|
|
115
|
+
import gw_line_cleaner as gwlc
|
|
116
|
+
import numpy as np
|
|
117
|
+
|
|
118
|
+
# Prepare PSD data for multiple detectors
|
|
119
|
+
freq = np.linspace(10, 2000, 100000)
|
|
120
|
+
detector_psds = {
|
|
121
|
+
"H1": h1_psd_array,
|
|
122
|
+
"L1": l1_psd_array,
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
# Get cleaned PSDs (incoherent lines removed, coherent lines preserved)
|
|
126
|
+
cleaned_psds, masks = gwlc.apply_cleaning(freq, detector_psds, min_detectors=2)
|
|
127
|
+
|
|
128
|
+
# Or get just the cleaning masks
|
|
129
|
+
masks = gwlc.get_cleaning_mask(freq, detector_psds, min_detectors=2)
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### API Reference
|
|
133
|
+
|
|
134
|
+
#### Baseline Fitting
|
|
135
|
+
|
|
136
|
+
- `load(file_path)` - Load spectrum data from file
|
|
137
|
+
- `fit(frequency, spectrum)` - Fit baseline to spectrum
|
|
138
|
+
- `load_and_fit(detector_asd_src)` - Load and fit in one step
|
|
139
|
+
- `load_and_fit_multiple(detector_asd_srcs)` - Process multiple detectors
|
|
140
|
+
|
|
141
|
+
#### Line Detection
|
|
142
|
+
|
|
143
|
+
- `detect_lines(frequency, spectrum, baseline)` - Detect spectral lines
|
|
144
|
+
- `detect_lines_multiple(detector_data)` - Detect lines for multiple detectors
|
|
145
|
+
- `find_and_plot(frequency, spectrum, baseline)` - Detect and visualize
|
|
146
|
+
|
|
147
|
+
#### Coherent Analysis
|
|
148
|
+
|
|
149
|
+
- `analyze_coherent_lines(detector_asd_srcs)` - Full coherent analysis
|
|
150
|
+
- `analyze_coherent_lines_from_data(detector_data)` - Analysis from pre-loaded data
|
|
151
|
+
- `plot_results(coherent_groups, detector_data)` - Visualize results
|
|
152
|
+
- `print_summary(coherent_groups, detector_data)` - Print analysis summary
|
|
153
|
+
|
|
154
|
+
#### Cleaning
|
|
155
|
+
|
|
156
|
+
- `clean_lines_from_PSD(freq, detector_psds, detector_clean)` - Core cleaning function
|
|
157
|
+
- `get_cleaning_mask(freq, detector_psds)` - Get boolean cleaning masks
|
|
158
|
+
- `apply_cleaning(freq, detector_psds)` - Apply cleaning and return cleaned PSDs
|
|
159
|
+
|
|
160
|
+
## Command Line Utility
|
|
161
|
+
|
|
162
|
+
The `gw-line-cleaner` utility cleans lines from Short Fourier Transform (SFT,
|
|
163
|
+
[SFT]) files, the standard data product utilised by continuous gravitational
|
|
164
|
+
data analysis routines from the [LALSuite] library.
|
|
165
|
+
|
|
166
|
+
### Usage
|
|
167
|
+
|
|
168
|
+
```
|
|
169
|
+
gw-line-cleaner [-h] [-l {DEBUG,INFO,WARNING,ERROR,CRITICAL}] [-t TEMP_DIR]
|
|
170
|
+
-i INPUT_SFTS -o OUTPUT_SFT_DIR
|
|
171
|
+
[-I INJECT_PARAMS] [-D]
|
|
172
|
+
[-B FSTAT_BEFORE_PARAMS] [-A FSTAT_AFTER_PARAMS]
|
|
173
|
+
[-O OUTPUT_STATS] [-S] [-P OUTPUT_SPECTRA_PLOTS]
|
|
174
|
+
[-e EARTH_EPHEMERIS] [-s SUN_EPHEMERIS]
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
### Options
|
|
178
|
+
|
|
179
|
+
- **-h, --help**: Show this help message and exit.
|
|
180
|
+
- **-l, --log-level {DEBUG,INFO,WARNING,ERROR,CRITICAL}**: Set the logging
|
|
181
|
+
level (default: INFO).
|
|
182
|
+
- **-t, --temp-dir TEMP_DIR**: Temporary directory to write intermediate
|
|
183
|
+
files.
|
|
184
|
+
- **-i, --input-SFTs INPUT_SFTS**: Input SFTs. Either a directory containing
|
|
185
|
+
SFT files, or a text file containing SFT filenames.
|
|
186
|
+
- **-o, --output-SFT-dir OUTPUT_SFT_DIR**: Directory in which to write output
|
|
187
|
+
SFTs.
|
|
188
|
+
- **-I, --inject-params INJECT_PARAMS**: If given, configuration file with
|
|
189
|
+
parameters of a continuous wave signal to be injected into the input SFTs
|
|
190
|
+
before cleaning. If argument contains a colon, the string before the colon is
|
|
191
|
+
the filename, and the string after the colon is the section to read the
|
|
192
|
+
parameters from.
|
|
193
|
+
- **-D, --inject-as-depth**: If true, injection amplitudes are interpreted as
|
|
194
|
+
(inverse) sensitivity depths, i.e. *(h0, aPlus, aCross) => (h0, aPlus,
|
|
195
|
+
aCross) * sqrt(Sh)*.
|
|
196
|
+
- **-B, --Fstat-before-params FSTAT_BEFORE_PARAMS**: If given, configuration
|
|
197
|
+
file with parameters of a continuous wave signal at which to compute the
|
|
198
|
+
F-statistic before cleaning. If argument contains a colon, the string before
|
|
199
|
+
the colon is the filename, and the string after the colon is the section to
|
|
200
|
+
read the parameters from.
|
|
201
|
+
- **-A, --Fstat-after-params FSTAT_AFTER_PARAMS**: If given, configuration
|
|
202
|
+
file with parameters of a continuous wave signal at which to compute the
|
|
203
|
+
F-statistic after cleaning. If argument contains a colon, the string before
|
|
204
|
+
the colon is the filename, and the string after the colon is the section to
|
|
205
|
+
read the parameters from.
|
|
206
|
+
- **-O, --output-stats OUTPUT_STATS**: Path to HDF5 file where various
|
|
207
|
+
statistics will be written.
|
|
208
|
+
- **-S, --output-spectra**: Include amplitude spectral densities before/after
|
|
209
|
+
cleaning in output statistics.
|
|
210
|
+
- **-P, --output-spectra-plots OUTPUT_SPECTRA_PLOTS**: Path to image file
|
|
211
|
+
where plots of amplitude spectral densities before/after cleaning will be
|
|
212
|
+
written.
|
|
213
|
+
- **-e, --earth-ephemeris EARTH_EPHEMERIS**: Earth ephemeris file to use.
|
|
214
|
+
- **-s, --sun-ephemeris SUN_EPHEMERIS**: Sun ephemeris file to use.
|
|
215
|
+
|
|
216
|
+
## License
|
|
217
|
+
|
|
218
|
+
MIT License
|
|
219
|
+
|
|
220
|
+
[SFT]: https://dcc.ligo.org/LIGO-T040164/public
|
|
221
|
+
[LALSuite]: https://doi.org/10.7935/GT1W-FZ16
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
# GW Line Cleaner
|
|
2
|
+
|
|
3
|
+
Remove line artifacts from gravitational wave data.
|
|
4
|
+
|
|
5
|
+
A Python package for detecting and removing spectral line artifacts from
|
|
6
|
+
gravitational wave detector data. Supports analysis across arbitrary numbers of
|
|
7
|
+
detectors (LIGO H1/L1, Virgo, KAGRA, etc.).
|
|
8
|
+
|
|
9
|
+
## Features
|
|
10
|
+
|
|
11
|
+
- **Baseline fitting**: Robust polynomial baseline estimation for ASD/PSD
|
|
12
|
+
spectra
|
|
13
|
+
- **Line detection**: Automatic detection of spectral lines using peak finding
|
|
14
|
+
algorithms
|
|
15
|
+
- **Coherent analysis**: Identify lines appearing across multiple detectors
|
|
16
|
+
(potential astrophysical signals)
|
|
17
|
+
- **Line cleaning**: Remove instrument-specific artifacts while preserving
|
|
18
|
+
coherent signals
|
|
19
|
+
- **Command-line utility**: `gw-line-cleaner` cleans lines from Short Fourier
|
|
20
|
+
Transform (SFT) files
|
|
21
|
+
|
|
22
|
+
## Installation
|
|
23
|
+
|
|
24
|
+
Install from PyPI (when available):
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
pip install gw-line-cleaner
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Or install from source:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
git clone https://github.com/gwda/gw-line-cleaner.git
|
|
34
|
+
cd gw-line-cleaner
|
|
35
|
+
pip install -e .
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Python Interface
|
|
39
|
+
|
|
40
|
+
### Basic Usage
|
|
41
|
+
|
|
42
|
+
```python
|
|
43
|
+
import gw_line_cleaner as gwlc
|
|
44
|
+
|
|
45
|
+
# Load and fit baseline for a single detector
|
|
46
|
+
frequency, spectrum, result = gwlc.load_and_fit("path/to/spectrum.txt")
|
|
47
|
+
|
|
48
|
+
# View fitting results
|
|
49
|
+
result.info(detector_name="H1")
|
|
50
|
+
result.plot(frequency, spectrum, detector_name="H1")
|
|
51
|
+
|
|
52
|
+
# Detect spectral lines
|
|
53
|
+
lines = gwlc.detect_lines(frequency, spectrum, result.baseline, detector_name="H1")
|
|
54
|
+
print(f"Detected {len(lines)} lines")
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Multi-Detector Coherent Analysis
|
|
58
|
+
|
|
59
|
+
```python
|
|
60
|
+
import gw_line_cleaner as gwlc
|
|
61
|
+
|
|
62
|
+
# Define detector data files
|
|
63
|
+
detector_files = {
|
|
64
|
+
"H1": "path/to/h1_spectrum.txt",
|
|
65
|
+
"L1": "path/to/l1_spectrum.txt",
|
|
66
|
+
"V1": "path/to/v1_spectrum.txt", # Optional: add more detectors
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
# Analyze coherent lines across detectors
|
|
70
|
+
coherent_groups, detector_data = gwlc.analyze_coherent_lines(
|
|
71
|
+
detector_files,
|
|
72
|
+
min_detectors=2 # Lines must appear in at least 2 detectors
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
# Print summary
|
|
76
|
+
gwlc.print_summary(coherent_groups, detector_data)
|
|
77
|
+
|
|
78
|
+
# Plot results
|
|
79
|
+
gwlc.plot_results(coherent_groups, detector_data, save_path="coherent_analysis.png")
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Line Cleaning
|
|
83
|
+
|
|
84
|
+
```python
|
|
85
|
+
import gw_line_cleaner as gwlc
|
|
86
|
+
import numpy as np
|
|
87
|
+
|
|
88
|
+
# Prepare PSD data for multiple detectors
|
|
89
|
+
freq = np.linspace(10, 2000, 100000)
|
|
90
|
+
detector_psds = {
|
|
91
|
+
"H1": h1_psd_array,
|
|
92
|
+
"L1": l1_psd_array,
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
# Get cleaned PSDs (incoherent lines removed, coherent lines preserved)
|
|
96
|
+
cleaned_psds, masks = gwlc.apply_cleaning(freq, detector_psds, min_detectors=2)
|
|
97
|
+
|
|
98
|
+
# Or get just the cleaning masks
|
|
99
|
+
masks = gwlc.get_cleaning_mask(freq, detector_psds, min_detectors=2)
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### API Reference
|
|
103
|
+
|
|
104
|
+
#### Baseline Fitting
|
|
105
|
+
|
|
106
|
+
- `load(file_path)` - Load spectrum data from file
|
|
107
|
+
- `fit(frequency, spectrum)` - Fit baseline to spectrum
|
|
108
|
+
- `load_and_fit(detector_asd_src)` - Load and fit in one step
|
|
109
|
+
- `load_and_fit_multiple(detector_asd_srcs)` - Process multiple detectors
|
|
110
|
+
|
|
111
|
+
#### Line Detection
|
|
112
|
+
|
|
113
|
+
- `detect_lines(frequency, spectrum, baseline)` - Detect spectral lines
|
|
114
|
+
- `detect_lines_multiple(detector_data)` - Detect lines for multiple detectors
|
|
115
|
+
- `find_and_plot(frequency, spectrum, baseline)` - Detect and visualize
|
|
116
|
+
|
|
117
|
+
#### Coherent Analysis
|
|
118
|
+
|
|
119
|
+
- `analyze_coherent_lines(detector_asd_srcs)` - Full coherent analysis
|
|
120
|
+
- `analyze_coherent_lines_from_data(detector_data)` - Analysis from pre-loaded data
|
|
121
|
+
- `plot_results(coherent_groups, detector_data)` - Visualize results
|
|
122
|
+
- `print_summary(coherent_groups, detector_data)` - Print analysis summary
|
|
123
|
+
|
|
124
|
+
#### Cleaning
|
|
125
|
+
|
|
126
|
+
- `clean_lines_from_PSD(freq, detector_psds, detector_clean)` - Core cleaning function
|
|
127
|
+
- `get_cleaning_mask(freq, detector_psds)` - Get boolean cleaning masks
|
|
128
|
+
- `apply_cleaning(freq, detector_psds)` - Apply cleaning and return cleaned PSDs
|
|
129
|
+
|
|
130
|
+
## Command Line Utility
|
|
131
|
+
|
|
132
|
+
The `gw-line-cleaner` utility cleans lines from Short Fourier Transform (SFT,
|
|
133
|
+
[SFT]) files, the standard data product utilised by continuous gravitational
|
|
134
|
+
data analysis routines from the [LALSuite] library.
|
|
135
|
+
|
|
136
|
+
### Usage
|
|
137
|
+
|
|
138
|
+
```
|
|
139
|
+
gw-line-cleaner [-h] [-l {DEBUG,INFO,WARNING,ERROR,CRITICAL}] [-t TEMP_DIR]
|
|
140
|
+
-i INPUT_SFTS -o OUTPUT_SFT_DIR
|
|
141
|
+
[-I INJECT_PARAMS] [-D]
|
|
142
|
+
[-B FSTAT_BEFORE_PARAMS] [-A FSTAT_AFTER_PARAMS]
|
|
143
|
+
[-O OUTPUT_STATS] [-S] [-P OUTPUT_SPECTRA_PLOTS]
|
|
144
|
+
[-e EARTH_EPHEMERIS] [-s SUN_EPHEMERIS]
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### Options
|
|
148
|
+
|
|
149
|
+
- **-h, --help**: Show this help message and exit.
|
|
150
|
+
- **-l, --log-level {DEBUG,INFO,WARNING,ERROR,CRITICAL}**: Set the logging
|
|
151
|
+
level (default: INFO).
|
|
152
|
+
- **-t, --temp-dir TEMP_DIR**: Temporary directory to write intermediate
|
|
153
|
+
files.
|
|
154
|
+
- **-i, --input-SFTs INPUT_SFTS**: Input SFTs. Either a directory containing
|
|
155
|
+
SFT files, or a text file containing SFT filenames.
|
|
156
|
+
- **-o, --output-SFT-dir OUTPUT_SFT_DIR**: Directory in which to write output
|
|
157
|
+
SFTs.
|
|
158
|
+
- **-I, --inject-params INJECT_PARAMS**: If given, configuration file with
|
|
159
|
+
parameters of a continuous wave signal to be injected into the input SFTs
|
|
160
|
+
before cleaning. If argument contains a colon, the string before the colon is
|
|
161
|
+
the filename, and the string after the colon is the section to read the
|
|
162
|
+
parameters from.
|
|
163
|
+
- **-D, --inject-as-depth**: If true, injection amplitudes are interpreted as
|
|
164
|
+
(inverse) sensitivity depths, i.e. *(h0, aPlus, aCross) => (h0, aPlus,
|
|
165
|
+
aCross) * sqrt(Sh)*.
|
|
166
|
+
- **-B, --Fstat-before-params FSTAT_BEFORE_PARAMS**: If given, configuration
|
|
167
|
+
file with parameters of a continuous wave signal at which to compute the
|
|
168
|
+
F-statistic before cleaning. If argument contains a colon, the string before
|
|
169
|
+
the colon is the filename, and the string after the colon is the section to
|
|
170
|
+
read the parameters from.
|
|
171
|
+
- **-A, --Fstat-after-params FSTAT_AFTER_PARAMS**: If given, configuration
|
|
172
|
+
file with parameters of a continuous wave signal at which to compute the
|
|
173
|
+
F-statistic after cleaning. If argument contains a colon, the string before
|
|
174
|
+
the colon is the filename, and the string after the colon is the section to
|
|
175
|
+
read the parameters from.
|
|
176
|
+
- **-O, --output-stats OUTPUT_STATS**: Path to HDF5 file where various
|
|
177
|
+
statistics will be written.
|
|
178
|
+
- **-S, --output-spectra**: Include amplitude spectral densities before/after
|
|
179
|
+
cleaning in output statistics.
|
|
180
|
+
- **-P, --output-spectra-plots OUTPUT_SPECTRA_PLOTS**: Path to image file
|
|
181
|
+
where plots of amplitude spectral densities before/after cleaning will be
|
|
182
|
+
written.
|
|
183
|
+
- **-e, --earth-ephemeris EARTH_EPHEMERIS**: Earth ephemeris file to use.
|
|
184
|
+
- **-s, --sun-ephemeris SUN_EPHEMERIS**: Sun ephemeris file to use.
|
|
185
|
+
|
|
186
|
+
## License
|
|
187
|
+
|
|
188
|
+
MIT License
|
|
189
|
+
|
|
190
|
+
[SFT]: https://dcc.ligo.org/LIGO-T040164/public
|
|
191
|
+
[LALSuite]: https://doi.org/10.7935/GT1W-FZ16
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
version = 1
|
|
2
|
+
|
|
3
|
+
[[annotations]]
|
|
4
|
+
path = [
|
|
5
|
+
".gitignore",
|
|
6
|
+
".pre-commit-config.yaml",
|
|
7
|
+
"README.md",
|
|
8
|
+
"pyproject.toml",
|
|
9
|
+
"requirements-dev.txt",
|
|
10
|
+
]
|
|
11
|
+
SPDX-FileCopyrightText = "NONE"
|
|
12
|
+
SPDX-License-Identifier = "CC0-1.0"
|
|
13
|
+
|
|
14
|
+
[[annotations]]
|
|
15
|
+
path = [
|
|
16
|
+
"src/**/*.py",
|
|
17
|
+
"test/**/*.py",
|
|
18
|
+
]
|
|
19
|
+
SPDX-License-Identifier = "MIT"
|