ml4gw 0.7.5__tar.gz → 0.7.6__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.
Potentially problematic release.
This version of ml4gw might be problematic. Click here for more details.
- {ml4gw-0.7.5 → ml4gw-0.7.6}/PKG-INFO +1 -1
- ml4gw-0.7.6/docs/.gitignore +2 -0
- {ml4gw-0.7.5 → ml4gw-0.7.6}/docs/conf.py +14 -1
- ml4gw-0.7.6/docs/examples/augmentations.rst +20 -0
- ml4gw-0.7.6/docs/examples/distributions.rst +50 -0
- ml4gw-0.7.6/docs/examples/gw.rst +65 -0
- ml4gw-0.7.6/docs/examples/transforms.qtransform.rst +40 -0
- ml4gw-0.7.6/docs/examples/transforms.spectral.rst +32 -0
- ml4gw-0.7.6/docs/examples/transforms.whitening.rst +29 -0
- ml4gw-0.7.6/docs/images/distribution_samples.png +0 -0
- ml4gw-0.7.6/docs/images/qscan_spectrogram.png +0 -0
- {ml4gw-0.7.5 → ml4gw-0.7.6}/docs/index.rst +15 -3
- {ml4gw-0.7.5 → ml4gw-0.7.6}/docs/installation.rst +3 -3
- {ml4gw-0.7.5 → ml4gw-0.7.6}/docs/requirements.txt +1 -0
- ml4gw-0.7.6/docs/tutorials/ml4gw_tutorial.ipynb +1744 -0
- ml4gw-0.7.6/docs/usage.rst +17 -0
- {ml4gw-0.7.5 → ml4gw-0.7.6}/ml4gw/augmentations.py +4 -4
- {ml4gw-0.7.5 → ml4gw-0.7.6}/ml4gw/dataloading/chunked_dataset.py +3 -3
- {ml4gw-0.7.5 → ml4gw-0.7.6}/ml4gw/dataloading/hdf5_dataset.py +7 -10
- {ml4gw-0.7.5 → ml4gw-0.7.6}/ml4gw/dataloading/in_memory_dataset.py +21 -21
- {ml4gw-0.7.5 → ml4gw-0.7.6}/ml4gw/distributions.py +19 -17
- {ml4gw-0.7.5 → ml4gw-0.7.6}/ml4gw/gw.py +60 -53
- {ml4gw-0.7.5 → ml4gw-0.7.6}/ml4gw/nn/autoencoder/base.py +9 -9
- {ml4gw-0.7.5 → ml4gw-0.7.6}/ml4gw/nn/autoencoder/convolutional.py +4 -4
- {ml4gw-0.7.5 → ml4gw-0.7.6}/ml4gw/nn/resnet/resnet_1d.py +13 -13
- {ml4gw-0.7.5 → ml4gw-0.7.6}/ml4gw/nn/resnet/resnet_2d.py +12 -12
- {ml4gw-0.7.5 → ml4gw-0.7.6}/ml4gw/nn/streaming/online_average.py +1 -1
- {ml4gw-0.7.5 → ml4gw-0.7.6}/ml4gw/nn/streaming/snapshotter.py +14 -14
- {ml4gw-0.7.5 → ml4gw-0.7.6}/ml4gw/spectral.py +48 -48
- {ml4gw-0.7.5 → ml4gw-0.7.6}/ml4gw/transforms/iirfilter.py +3 -3
- {ml4gw-0.7.5 → ml4gw-0.7.6}/ml4gw/transforms/pearson.py +7 -8
- {ml4gw-0.7.5 → ml4gw-0.7.6}/ml4gw/transforms/qtransform.py +19 -19
- {ml4gw-0.7.5 → ml4gw-0.7.6}/ml4gw/transforms/scaler.py +4 -4
- {ml4gw-0.7.5 → ml4gw-0.7.6}/ml4gw/transforms/spectral.py +10 -10
- {ml4gw-0.7.5 → ml4gw-0.7.6}/ml4gw/transforms/spectrogram.py +12 -11
- {ml4gw-0.7.5 → ml4gw-0.7.6}/ml4gw/transforms/spline_interpolation.py +8 -15
- {ml4gw-0.7.5 → ml4gw-0.7.6}/ml4gw/transforms/transform.py +1 -1
- {ml4gw-0.7.5 → ml4gw-0.7.6}/ml4gw/transforms/whitening.py +36 -36
- {ml4gw-0.7.5 → ml4gw-0.7.6}/ml4gw/utils/slicing.py +40 -40
- {ml4gw-0.7.5 → ml4gw-0.7.6}/ml4gw/waveforms/cbc/phenom_d.py +22 -66
- {ml4gw-0.7.5 → ml4gw-0.7.6}/ml4gw/waveforms/cbc/phenom_p.py +9 -5
- {ml4gw-0.7.5 → ml4gw-0.7.6}/ml4gw/waveforms/cbc/taylorf2.py +8 -7
- {ml4gw-0.7.5 → ml4gw-0.7.6}/ml4gw/waveforms/conversion.py +2 -1
- {ml4gw-0.7.5 → ml4gw-0.7.6}/ml4gw/waveforms/generator.py +33 -32
- {ml4gw-0.7.5 → ml4gw-0.7.6}/pyproject.toml +6 -1
- {ml4gw-0.7.5 → ml4gw-0.7.6}/tests/nn/resnet/test_resnet_1d.py +32 -3
- {ml4gw-0.7.5 → ml4gw-0.7.6}/tests/nn/resnet/test_resnet_2d.py +25 -3
- {ml4gw-0.7.5 → ml4gw-0.7.6}/tests/test_distributions.py +43 -3
- {ml4gw-0.7.5 → ml4gw-0.7.6}/tests/test_gw.py +5 -0
- {ml4gw-0.7.5 → ml4gw-0.7.6}/tests/test_spectral.py +7 -1
- {ml4gw-0.7.5 → ml4gw-0.7.6}/tests/transforms/test_spectral_transform.py +10 -0
- {ml4gw-0.7.5 → ml4gw-0.7.6}/tests/transforms/test_spline_interpolation.py +26 -8
- {ml4gw-0.7.5 → ml4gw-0.7.6}/tests/transforms/test_waveforms.py +4 -0
- {ml4gw-0.7.5 → ml4gw-0.7.6}/tests/transforms/test_whitening.py +3 -0
- {ml4gw-0.7.5 → ml4gw-0.7.6}/tests/utils/test_slicing.py +26 -0
- {ml4gw-0.7.5 → ml4gw-0.7.6}/tests/waveforms/cbc/test_cbc_waveforms.py +54 -0
- {ml4gw-0.7.5 → ml4gw-0.7.6}/tests/waveforms/test_conversion.py +17 -0
- {ml4gw-0.7.5 → ml4gw-0.7.6}/tests/waveforms/test_generator.py +4 -0
- {ml4gw-0.7.5 → ml4gw-0.7.6}/uv.lock +671 -2
- ml4gw-0.7.5/docs/ml4gw.dataloading.rst +0 -37
- ml4gw-0.7.5/docs/ml4gw.nn.autoencoder.rst +0 -45
- ml4gw-0.7.5/docs/ml4gw.nn.resnet.rst +0 -29
- ml4gw-0.7.5/docs/ml4gw.nn.rst +0 -31
- ml4gw-0.7.5/docs/ml4gw.nn.streaming.rst +0 -29
- ml4gw-0.7.5/docs/ml4gw.rst +0 -64
- ml4gw-0.7.5/docs/ml4gw.transforms.rst +0 -77
- ml4gw-0.7.5/docs/ml4gw.waveforms.rst +0 -53
- ml4gw-0.7.5/docs/modules.rst +0 -7
- ml4gw-0.7.5/examples/README.md +0 -12
- ml4gw-0.7.5/examples/ml4gw_tutorial.ipynb +0 -1757
- ml4gw-0.7.5/examples/pyproject.toml +0 -22
- ml4gw-0.7.5/examples/uv.lock +0 -2960
- {ml4gw-0.7.5 → ml4gw-0.7.6}/.coverage +0 -0
- {ml4gw-0.7.5 → ml4gw-0.7.6}/.gitattributes +0 -0
- {ml4gw-0.7.5 → ml4gw-0.7.6}/.github/workflows/coverage.yaml +0 -0
- {ml4gw-0.7.5 → ml4gw-0.7.6}/.github/workflows/docs.yaml +0 -0
- {ml4gw-0.7.5 → ml4gw-0.7.6}/.github/workflows/pre-commit.yaml +0 -0
- {ml4gw-0.7.5 → ml4gw-0.7.6}/.github/workflows/publish.yaml +0 -0
- {ml4gw-0.7.5 → ml4gw-0.7.6}/.github/workflows/unit-tests.yaml +0 -0
- {ml4gw-0.7.5 → ml4gw-0.7.6}/.gitignore +0 -0
- {ml4gw-0.7.5 → ml4gw-0.7.6}/.pre-commit-config.yaml +0 -0
- {ml4gw-0.7.5 → ml4gw-0.7.6}/.readthedocs.yaml +0 -0
- {ml4gw-0.7.5 → ml4gw-0.7.6}/CITATION.cff +0 -0
- {ml4gw-0.7.5 → ml4gw-0.7.6}/LICENSE +0 -0
- {ml4gw-0.7.5 → ml4gw-0.7.6}/README.md +0 -0
- {ml4gw-0.7.5 → ml4gw-0.7.6}/docs/Makefile +0 -0
- {ml4gw-0.7.5 → ml4gw-0.7.6}/docs/make.bat +0 -0
- {ml4gw-0.7.5 → ml4gw-0.7.6}/ml4gw/__init__.py +0 -0
- {ml4gw-0.7.5 → ml4gw-0.7.6}/ml4gw/constants.py +0 -0
- {ml4gw-0.7.5 → ml4gw-0.7.6}/ml4gw/dataloading/__init__.py +0 -0
- {ml4gw-0.7.5 → ml4gw-0.7.6}/ml4gw/nn/__init__.py +0 -0
- {ml4gw-0.7.5 → ml4gw-0.7.6}/ml4gw/nn/autoencoder/__init__.py +0 -0
- {ml4gw-0.7.5 → ml4gw-0.7.6}/ml4gw/nn/autoencoder/skip_connection.py +0 -0
- {ml4gw-0.7.5 → ml4gw-0.7.6}/ml4gw/nn/autoencoder/utils.py +0 -0
- {ml4gw-0.7.5 → ml4gw-0.7.6}/ml4gw/nn/norm.py +0 -0
- {ml4gw-0.7.5 → ml4gw-0.7.6}/ml4gw/nn/resnet/__init__.py +0 -0
- {ml4gw-0.7.5 → ml4gw-0.7.6}/ml4gw/nn/streaming/__init__.py +0 -0
- {ml4gw-0.7.5 → ml4gw-0.7.6}/ml4gw/transforms/__init__.py +0 -0
- {ml4gw-0.7.5 → ml4gw-0.7.6}/ml4gw/transforms/snr_rescaler.py +0 -0
- {ml4gw-0.7.5 → ml4gw-0.7.6}/ml4gw/transforms/waveforms.py +0 -0
- {ml4gw-0.7.5 → ml4gw-0.7.6}/ml4gw/types.py +0 -0
- {ml4gw-0.7.5 → ml4gw-0.7.6}/ml4gw/utils/interferometer.py +0 -0
- {ml4gw-0.7.5 → ml4gw-0.7.6}/ml4gw/waveforms/__init__.py +0 -0
- {ml4gw-0.7.5 → ml4gw-0.7.6}/ml4gw/waveforms/adhoc/__init__.py +0 -0
- {ml4gw-0.7.5 → ml4gw-0.7.6}/ml4gw/waveforms/adhoc/ringdown.py +0 -0
- {ml4gw-0.7.5 → ml4gw-0.7.6}/ml4gw/waveforms/adhoc/sine_gaussian.py +0 -0
- {ml4gw-0.7.5 → ml4gw-0.7.6}/ml4gw/waveforms/cbc/__init__.py +0 -0
- {ml4gw-0.7.5 → ml4gw-0.7.6}/ml4gw/waveforms/cbc/coefficients.py +0 -0
- {ml4gw-0.7.5 → ml4gw-0.7.6}/ml4gw/waveforms/cbc/phenom_d_data.py +0 -0
- {ml4gw-0.7.5 → ml4gw-0.7.6}/ml4gw/waveforms/cbc/utils.py +0 -0
- {ml4gw-0.7.5 → ml4gw-0.7.6}/tests/conftest.py +0 -0
- {ml4gw-0.7.5 → ml4gw-0.7.6}/tests/dataloading/test_chunked_dataset.py +0 -0
- {ml4gw-0.7.5 → ml4gw-0.7.6}/tests/dataloading/test_hdf5_dataset.py +0 -0
- {ml4gw-0.7.5 → ml4gw-0.7.6}/tests/dataloading/test_in_memory_dataset.py +0 -0
- {ml4gw-0.7.5 → ml4gw-0.7.6}/tests/nn/streaming/test_online_average.py +0 -0
- {ml4gw-0.7.5 → ml4gw-0.7.6}/tests/nn/streaming/test_snapshotter.py +0 -0
- {ml4gw-0.7.5 → ml4gw-0.7.6}/tests/nn/test_norm.py +0 -0
- {ml4gw-0.7.5 → ml4gw-0.7.6}/tests/test_augmentations.py +0 -0
- {ml4gw-0.7.5 → ml4gw-0.7.6}/tests/transforms/test_iirfilter.py +0 -0
- {ml4gw-0.7.5 → ml4gw-0.7.6}/tests/transforms/test_pearson.py +0 -0
- {ml4gw-0.7.5 → ml4gw-0.7.6}/tests/transforms/test_qtransform.py +0 -0
- {ml4gw-0.7.5 → ml4gw-0.7.6}/tests/transforms/test_scaler.py +0 -0
- {ml4gw-0.7.5 → ml4gw-0.7.6}/tests/transforms/test_snr_rescaler.py +0 -0
- {ml4gw-0.7.5 → ml4gw-0.7.6}/tests/transforms/test_spectrogram.py +0 -0
- {ml4gw-0.7.5 → ml4gw-0.7.6}/tests/waveforms/adhoc/test_sine_gaussian.py +0 -0
- {ml4gw-0.7.5 → ml4gw-0.7.6}/tests/waveforms/cbc/test_utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ml4gw
|
|
3
|
-
Version: 0.7.
|
|
3
|
+
Version: 0.7.6
|
|
4
4
|
Summary: Tools for training torch models on gravitational wave data
|
|
5
5
|
Author-email: Ethan Marx <emarx@mit.edu>, Will Benoit <benoi090@umn.edu>, Deep Chatterjee <deep1018@mit.edu>, Alec Gunny <alec.gunny@ligo.org>
|
|
6
6
|
License-File: LICENSE
|
|
@@ -19,7 +19,7 @@ sys.path.insert(0, os.path.abspath("../"))
|
|
|
19
19
|
# -- Project information -----------------------------------------------------
|
|
20
20
|
|
|
21
21
|
project = "ml4gw"
|
|
22
|
-
copyright = "
|
|
22
|
+
copyright = "2025, Alec Gunny, Ethan Marx, William Benoit, Deep Chatterjee"
|
|
23
23
|
author = "Alec Gunny, Ethan Marx, William Benoit, Deep Chatterjee"
|
|
24
24
|
|
|
25
25
|
|
|
@@ -30,11 +30,24 @@ author = "Alec Gunny, Ethan Marx, William Benoit, Deep Chatterjee"
|
|
|
30
30
|
# ones.
|
|
31
31
|
extensions = [
|
|
32
32
|
"sphinx.ext.autodoc",
|
|
33
|
+
"sphinx.ext.mathjax",
|
|
34
|
+
"sphinx.ext.autosummary",
|
|
33
35
|
"sphinx.ext.napoleon",
|
|
34
36
|
"sphinx_autodoc_typehints",
|
|
35
37
|
"sphinx.ext.githubpages",
|
|
38
|
+
"myst_nb",
|
|
36
39
|
]
|
|
40
|
+
autosummary_generate = True
|
|
37
41
|
|
|
42
|
+
autodoc_default_options = {
|
|
43
|
+
"members": True,
|
|
44
|
+
"undoc-members": True,
|
|
45
|
+
"show-inheritance": True,
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
autodoc_typehints = "description"
|
|
49
|
+
autodoc_inherit_docstrings = False
|
|
50
|
+
nb_execution_mode = "off"
|
|
38
51
|
|
|
39
52
|
# Add any paths that contain templates here, relative to this directory.
|
|
40
53
|
templates_path = ["_templates"]
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Augmentations
|
|
2
|
+
=============
|
|
3
|
+
|
|
4
|
+
Apply random time-series reversal and inversion augmentations to batches of data.
|
|
5
|
+
|
|
6
|
+
.. code-block:: python
|
|
7
|
+
|
|
8
|
+
from ml4gw.augmentations import SignalInverter, SignalReverser
|
|
9
|
+
import torch
|
|
10
|
+
|
|
11
|
+
# Initialize augmentors with probability of applying the transformation
|
|
12
|
+
inverter = SignalInverter(prob=0.25)
|
|
13
|
+
reverser = SignalReverser(prob=0.5)
|
|
14
|
+
|
|
15
|
+
# Example data with shape (batch_size, channels, length)
|
|
16
|
+
X = torch.randn(10, 2, 1000)
|
|
17
|
+
|
|
18
|
+
# Apply augmentations
|
|
19
|
+
X = inverter(X)
|
|
20
|
+
X = reverser(X)
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
Distributions
|
|
2
|
+
================
|
|
3
|
+
|
|
4
|
+
Sample from probability distributions not yet included in `torch.distributions`.
|
|
5
|
+
|
|
6
|
+
.. code-block:: python
|
|
7
|
+
|
|
8
|
+
from ml4gw.distributions import PowerLaw, Cosine, UniformComovingVolume
|
|
9
|
+
import matplotlib.pyplot as plt
|
|
10
|
+
|
|
11
|
+
# Initialize distributions
|
|
12
|
+
power_law = PowerLaw(
|
|
13
|
+
minimum=4,
|
|
14
|
+
maximum=100,
|
|
15
|
+
index=-3,
|
|
16
|
+
)
|
|
17
|
+
cosine = Cosine()
|
|
18
|
+
ucv = UniformComovingVolume(
|
|
19
|
+
minimum=0,
|
|
20
|
+
maximum=2,
|
|
21
|
+
distance_type="redshift",
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
# Sample from distributions
|
|
25
|
+
samples_power_law = power_law.sample((10000,))
|
|
26
|
+
samples_cosine = cosine.sample((10000,))
|
|
27
|
+
samples_ucv = ucv.sample((10000,))
|
|
28
|
+
|
|
29
|
+
# Plot samples
|
|
30
|
+
plt.figure(figsize=(12, 4))
|
|
31
|
+
|
|
32
|
+
plt.subplot(1, 3, 1)
|
|
33
|
+
plt.hist(samples_power_law, bins=50)
|
|
34
|
+
plt.title("PowerLaw")
|
|
35
|
+
|
|
36
|
+
plt.subplot(1, 3, 2)
|
|
37
|
+
plt.hist(samples_cosine, bins=50)
|
|
38
|
+
plt.title("Cosine")
|
|
39
|
+
|
|
40
|
+
plt.subplot(1, 3, 3)
|
|
41
|
+
plt.hist(samples_ucv, bins=50)
|
|
42
|
+
plt.title("UniformComovingVolume")
|
|
43
|
+
|
|
44
|
+
plt.tight_layout()
|
|
45
|
+
plt.show()
|
|
46
|
+
|
|
47
|
+
.. image:: ../images/distribution_samples.png
|
|
48
|
+
:alt: Histograms of samples from the distributions
|
|
49
|
+
:width: 600px
|
|
50
|
+
:align: center
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
Gravitational-wave projection and SNR calculation
|
|
2
|
+
=================================================
|
|
3
|
+
|
|
4
|
+
.. code-block:: python
|
|
5
|
+
|
|
6
|
+
"""
|
|
7
|
+
Project a batch of waveform polarizations onto the Hanford,
|
|
8
|
+
Livingston, and Virgo interferometers to compute the observed
|
|
9
|
+
gravitational wave strain.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
from ml4gw.gw import get_ifo_geometry, compute_observed_strain
|
|
13
|
+
from ml4gw.distributions import Cosine
|
|
14
|
+
from torch.distributions import Uniform
|
|
15
|
+
|
|
16
|
+
dec = Cosine()
|
|
17
|
+
psi = Uniform(0, torch.pi)
|
|
18
|
+
phi = Uniform(-torch.pi, torch.pi)
|
|
19
|
+
|
|
20
|
+
# Get the interferometer geometry
|
|
21
|
+
ifos = ["H1", "L1", "V1"]
|
|
22
|
+
tensors, vertices = get_ifo_geometry(*ifos)
|
|
23
|
+
|
|
24
|
+
# The following assumes that the plus and cross polarizations
|
|
25
|
+
# of the gravitational wave have already been computed by
|
|
26
|
+
# some method; e.g., using the `TimeDomainCBCWaveformGenerator`
|
|
27
|
+
# from the `ml4gw.waveforms` module. `sample_rate` is the sample
|
|
28
|
+
# rate at which the polarizations were generated.
|
|
29
|
+
waveforms = compute_observed_strain(
|
|
30
|
+
dec=dec.sample((num_waveforms,)),
|
|
31
|
+
psi=psi.sample((num_waveforms,)),
|
|
32
|
+
phi=phi.sample((num_waveforms,)),
|
|
33
|
+
detector_tensors=tensors,
|
|
34
|
+
detector_vertices=vertices,
|
|
35
|
+
sample_rate=sample_rate,
|
|
36
|
+
cross=hc,
|
|
37
|
+
plus=hp,
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
.. code-block:: python
|
|
41
|
+
|
|
42
|
+
"""
|
|
43
|
+
Compute the signal-to-noise ratio (SNR) of a batch of waveforms
|
|
44
|
+
relative to a given noise power spectral density (PSD).
|
|
45
|
+
"""
|
|
46
|
+
|
|
47
|
+
from ml4gw.gw import compute_network_snr
|
|
48
|
+
|
|
49
|
+
# Assume `waveforms` is a batch of waveforms with shape
|
|
50
|
+
# (num_waveforms, num_detectors, num_samples) and
|
|
51
|
+
# `psd` is a batch of power spectral densities. See the
|
|
52
|
+
# docstring for details on the allowed PSD shapes.
|
|
53
|
+
|
|
54
|
+
# Highpass determines the minimum frequency for the SNR calculation.
|
|
55
|
+
highpass = 20
|
|
56
|
+
|
|
57
|
+
# Sample rate of the waveforms
|
|
58
|
+
sample_rate = 2048
|
|
59
|
+
|
|
60
|
+
snr = compute_network_snr(
|
|
61
|
+
responses=waveforms,
|
|
62
|
+
psd=psd,
|
|
63
|
+
sample_rate=sample_rate,
|
|
64
|
+
highpass=highpass,
|
|
65
|
+
)
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
Q-transform
|
|
2
|
+
================
|
|
3
|
+
|
|
4
|
+
.. code-block:: python
|
|
5
|
+
|
|
6
|
+
"""
|
|
7
|
+
Compute the Q-transform of a batch of time-series data.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from ml4gw.transforms import QScan
|
|
11
|
+
import matplotlib.pyplot as plt
|
|
12
|
+
import torch
|
|
13
|
+
|
|
14
|
+
sample_rate = 2048
|
|
15
|
+
duration = 10
|
|
16
|
+
# Output shape of the spectrogram
|
|
17
|
+
spectrogram_shape = [256, 256]
|
|
18
|
+
|
|
19
|
+
qscan = QScan(
|
|
20
|
+
sample_rate=sample_rate,
|
|
21
|
+
duration=duration,
|
|
22
|
+
spectrogram_shape=spectrogram_shape,
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
# Example data with shape (batch_size, channels, length)
|
|
26
|
+
X = torch.randn(10, 2, duration * sample_rate)
|
|
27
|
+
|
|
28
|
+
# Apply the Q-transform to compute the Q-transform of X
|
|
29
|
+
spectrograms = qscan(X)
|
|
30
|
+
|
|
31
|
+
# Plot the first spectrogram
|
|
32
|
+
plt.imshow(spectrograms[0, 0], aspect='auto', origin='lower')
|
|
33
|
+
plt.colorbar()
|
|
34
|
+
plt.title('Q-transform Spectrogram')
|
|
35
|
+
plt.show()
|
|
36
|
+
|
|
37
|
+
.. image:: ../images/qscan_spectrogram.png
|
|
38
|
+
:width: 600px
|
|
39
|
+
:align: center
|
|
40
|
+
:alt: Spectrogram of the Q-transform
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
Spectral Density
|
|
2
|
+
================
|
|
3
|
+
|
|
4
|
+
.. code-block:: python
|
|
5
|
+
|
|
6
|
+
"""
|
|
7
|
+
Compute the power spectral density and cross-spectral density of
|
|
8
|
+
batches of time-series data.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
from ml4gw.transforms import SpectralDensity
|
|
12
|
+
import torch
|
|
13
|
+
|
|
14
|
+
sample_rate = 2048
|
|
15
|
+
fftlength = 2
|
|
16
|
+
duration = 10
|
|
17
|
+
|
|
18
|
+
# Initialize the spectral transform with a sample rate and fftlength
|
|
19
|
+
spectral_density = SpectralDensity(
|
|
20
|
+
sample_rate=sample_rate,
|
|
21
|
+
fftlength=fftlength,
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
# Example data with shape (batch_size, channels, length)
|
|
25
|
+
X = torch.randn(10, 2, duration * sample_rate)
|
|
26
|
+
|
|
27
|
+
# Apply the spectral transform to compute the power spectral density of X
|
|
28
|
+
psd = spectral_density(X)
|
|
29
|
+
|
|
30
|
+
# This module can also compute the cross-spectral density between two signals
|
|
31
|
+
Y = torch.randn(10, 2, duration * sample_rate)
|
|
32
|
+
csd = spectral_density(X, Y)
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
Whitening
|
|
2
|
+
=========
|
|
3
|
+
|
|
4
|
+
.. code-block:: python
|
|
5
|
+
|
|
6
|
+
"""
|
|
7
|
+
Whiten a batch of time-series data
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from ml4gw.transforms import Whiten
|
|
11
|
+
import torch
|
|
12
|
+
|
|
13
|
+
fduration = 2
|
|
14
|
+
sample_rate = 2048
|
|
15
|
+
highpass = 20
|
|
16
|
+
duration = 10
|
|
17
|
+
|
|
18
|
+
whitener = Whiten(
|
|
19
|
+
fduration=fduration,
|
|
20
|
+
sample_rate=sample_rate,
|
|
21
|
+
highpass=highpass,
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
X = torch.randn(10, 2, duration * sample_rate)
|
|
25
|
+
|
|
26
|
+
# Apply the whitening transform. Assume `psd` is the
|
|
27
|
+
# power spectral density computed using, e.g., the
|
|
28
|
+
# `SpectralDensity` transform.
|
|
29
|
+
X_whitened = whitener(X, psd)
|
|
Binary file
|
|
Binary file
|
|
@@ -15,7 +15,7 @@ ml4gw
|
|
|
15
15
|
ml4gw is a library of `pytorch <https://pytorch.org/docs/stable/index.html>`_ utilities
|
|
16
16
|
for training neural networks in service of gravitational wave physics applications.
|
|
17
17
|
|
|
18
|
-
The code can be found on github at `<https://github.com/
|
|
18
|
+
The code can be found on github at `<https://github.com/ML4GW/ml4gw>`_
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
.. toctree::
|
|
@@ -23,14 +23,26 @@ The code can be found on github at `<https://github.com/ml4gw/ml4gw>`_
|
|
|
23
23
|
:caption: Contents:
|
|
24
24
|
|
|
25
25
|
installation
|
|
26
|
-
|
|
26
|
+
usage
|
|
27
|
+
tutorials/ml4gw_tutorial
|
|
28
|
+
|
|
29
|
+
API:
|
|
30
|
+
----
|
|
31
|
+
|
|
32
|
+
.. autosummary::
|
|
33
|
+
:toctree: api
|
|
34
|
+
:caption: API
|
|
35
|
+
:recursive:
|
|
36
|
+
|
|
37
|
+
ml4gw
|
|
38
|
+
ml4gw.utils
|
|
27
39
|
|
|
28
40
|
Projects
|
|
29
41
|
========
|
|
30
42
|
Currently, the following projects are using ml4gw to support their research:
|
|
31
43
|
|
|
32
44
|
* `Aframe <https://github.com/ml4gw/aframev2>`_ - Gravitational wave detection of binary black hole mergers
|
|
33
|
-
* `
|
|
45
|
+
* `AMPLFI <https://github.com/ml4gw/amplfi>`_ - Parameter estimation of gravitational wave signals
|
|
34
46
|
|
|
35
47
|
|
|
36
48
|
Development
|
|
@@ -12,8 +12,8 @@ ml4gw is installable with pip:
|
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
To build with a specific version of PyTorch/CUDA, please see the PyTorch installation `instructions <https://pytorch.org/get-started/previous-versions/>`_
|
|
15
|
-
to see how to specify the desired torch version and :code:`--extra-index-url` flag. For example, to install with PyTorch
|
|
15
|
+
to see how to specify the desired torch version and :code:`--extra-index-url` flag. For example, to install with PyTorch 2.5.0 and CUDA 12.1, use the following command:
|
|
16
16
|
|
|
17
17
|
.. code-block:: console
|
|
18
|
-
|
|
19
|
-
$ pip install ml4gw torch==
|
|
18
|
+
|
|
19
|
+
$ pip install ml4gw torch==2.5.0 --extra-index-url=https://download.pytorch.org/whl/cu121
|