tdanalysis 1.0.0__py3-none-any.whl
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.
- tdanalysis/__init__.py +0 -0
- tdanalysis/_compat.py +173 -0
- tdanalysis/covariance/covariance_calc.py +811 -0
- tdanalysis/covariance/psd.py +987 -0
- tdanalysis/data/acorrs/A1_aplus_acorr_4s_4096.npy +0 -0
- tdanalysis/data/acorrs/A1_aplus_acorr_8s_4096.npy +0 -0
- tdanalysis/data/acorrs/CE20_1p0MW_Aplus_acorr_4s_4096.npy +0 -0
- tdanalysis/data/acorrs/CE20_1p0MW_Aplus_acorr_8s_4096.npy +0 -0
- tdanalysis/data/acorrs/CE20_1p0MW_aLIGO_acorr_4s_4096.npy +0 -0
- tdanalysis/data/acorrs/CE20_1p0MW_aLIGO_acorr_8s_4096.npy +0 -0
- tdanalysis/data/acorrs/CE20_1p5MW_Aplus_acorr_4s_4096.npy +0 -0
- tdanalysis/data/acorrs/CE20_1p5MW_Aplus_acorr_8s_4096.npy +0 -0
- tdanalysis/data/acorrs/CE20_1p5MW_aLIGO_acorr_4s_4096.npy +0 -0
- tdanalysis/data/acorrs/CE20_1p5MW_aLIGO_acorr_8s_4096.npy +0 -0
- tdanalysis/data/acorrs/CE20_gwforge_default_acorr_4s_4096.npy +0 -0
- tdanalysis/data/acorrs/CE20_gwforge_default_acorr_8s_4096.npy +0 -0
- tdanalysis/data/acorrs/CE40_1p0MW_Aplus_acorr_4s_4096.npy +0 -0
- tdanalysis/data/acorrs/CE40_1p0MW_Aplus_acorr_8s_4096.npy +0 -0
- tdanalysis/data/acorrs/CE40_1p0MW_aLIGO_acorr_4s_4096.npy +0 -0
- tdanalysis/data/acorrs/CE40_1p0MW_aLIGO_acorr_8s_4096.npy +0 -0
- tdanalysis/data/acorrs/CE40_1p5MW_Aplus_acorr_4s_4096.npy +0 -0
- tdanalysis/data/acorrs/CE40_1p5MW_Aplus_acorr_8s_4096.npy +0 -0
- tdanalysis/data/acorrs/CE40_1p5MW_aLIGO_acorr_4s_4096.npy +0 -0
- tdanalysis/data/acorrs/CE40_1p5MW_aLIGO_acorr_8s_4096.npy +0 -0
- tdanalysis/data/acorrs/CE40_gwforge_default_acorr_4s_4096.npy +0 -0
- tdanalysis/data/acorrs/CE40_gwforge_default_acorr_8s_4096.npy +0 -0
- tdanalysis/data/acorrs/ET1ET2ET3_ET_D_acorr_4s_4096.npy +0 -0
- tdanalysis/data/acorrs/ET1ET2ET3_ET_D_acorr_8s_4096.npy +0 -0
- tdanalysis/data/acorrs/ET1ET2ET3_cryo_10km_acorr_4s_4096.npy +0 -0
- tdanalysis/data/acorrs/ET1ET2ET3_cryo_10km_acorr_8s_4096.npy +0 -0
- tdanalysis/data/acorrs/ET1ET2ET3_cryo_15km_acorr_4s_4096.npy +0 -0
- tdanalysis/data/acorrs/ET1ET2ET3_cryo_15km_acorr_8s_4096.npy +0 -0
- tdanalysis/data/acorrs/PROVENANCE.md +1143 -0
- tdanalysis/data/acorrs/half_A1_aplus_acorr_4s_4096.npy +0 -0
- tdanalysis/data/acorrs/half_A1_aplus_acorr_8s_4096.npy +0 -0
- tdanalysis/data/acorrs/half_CE20_1p0MW_Aplus_acorr_4s_4096.npy +0 -0
- tdanalysis/data/acorrs/half_CE20_1p0MW_Aplus_acorr_8s_4096.npy +0 -0
- tdanalysis/data/acorrs/half_CE20_1p0MW_aLIGO_acorr_4s_4096.npy +0 -0
- tdanalysis/data/acorrs/half_CE20_1p0MW_aLIGO_acorr_8s_4096.npy +0 -0
- tdanalysis/data/acorrs/half_CE20_1p5MW_Aplus_acorr_4s_4096.npy +0 -0
- tdanalysis/data/acorrs/half_CE20_1p5MW_Aplus_acorr_8s_4096.npy +0 -0
- tdanalysis/data/acorrs/half_CE20_1p5MW_aLIGO_acorr_4s_4096.npy +0 -0
- tdanalysis/data/acorrs/half_CE20_1p5MW_aLIGO_acorr_8s_4096.npy +0 -0
- tdanalysis/data/acorrs/half_CE20_gwforge_default_acorr_4s_4096.npy +0 -0
- tdanalysis/data/acorrs/half_CE20_gwforge_default_acorr_8s_4096.npy +0 -0
- tdanalysis/data/acorrs/half_CE40_1p0MW_Aplus_acorr_4s_4096.npy +0 -0
- tdanalysis/data/acorrs/half_CE40_1p0MW_Aplus_acorr_8s_4096.npy +0 -0
- tdanalysis/data/acorrs/half_CE40_1p0MW_aLIGO_acorr_4s_4096.npy +0 -0
- tdanalysis/data/acorrs/half_CE40_1p0MW_aLIGO_acorr_8s_4096.npy +0 -0
- tdanalysis/data/acorrs/half_CE40_1p5MW_Aplus_acorr_4s_4096.npy +0 -0
- tdanalysis/data/acorrs/half_CE40_1p5MW_Aplus_acorr_8s_4096.npy +0 -0
- tdanalysis/data/acorrs/half_CE40_1p5MW_aLIGO_acorr_4s_4096.npy +0 -0
- tdanalysis/data/acorrs/half_CE40_1p5MW_aLIGO_acorr_8s_4096.npy +0 -0
- tdanalysis/data/acorrs/half_CE40_gwforge_default_acorr_4s_4096.npy +0 -0
- tdanalysis/data/acorrs/half_CE40_gwforge_default_acorr_8s_4096.npy +0 -0
- tdanalysis/data/acorrs/half_ET1ET2ET3_ET_D_acorr_4s_4096.npy +0 -0
- tdanalysis/data/acorrs/half_ET1ET2ET3_ET_D_acorr_8s_4096.npy +0 -0
- tdanalysis/data/acorrs/half_ET1ET2ET3_cryo_10km_acorr_4s_4096.npy +0 -0
- tdanalysis/data/acorrs/half_ET1ET2ET3_cryo_10km_acorr_8s_4096.npy +0 -0
- tdanalysis/data/acorrs/half_ET1ET2ET3_cryo_15km_acorr_4s_4096.npy +0 -0
- tdanalysis/data/acorrs/half_ET1ET2ET3_cryo_15km_acorr_8s_4096.npy +0 -0
- tdanalysis/data/detectors/A1.interferometer +13 -0
- tdanalysis/data/detectors/CE20.ifo +11 -0
- tdanalysis/data/detectors/CE40.ifo +11 -0
- tdanalysis/data/detectors/ET.ifo +12 -0
- tdanalysis/data/detectors/PROVENANCE.md +230 -0
- tdanalysis/data/noise_curves/CE20-asd.txt +1000 -0
- tdanalysis/data/noise_curves/CE20km_1p0MW_Aplus_coat_strain.txt +1000 -0
- tdanalysis/data/noise_curves/CE20km_1p0MW_aLIGO_coat_strain.txt +1000 -0
- tdanalysis/data/noise_curves/CE20km_1p5MW_Aplus_coat_strain.txt +1000 -0
- tdanalysis/data/noise_curves/CE20km_1p5MW_aLIGO_coat_strain.txt +1000 -0
- tdanalysis/data/noise_curves/CE40-asd.txt +1000 -0
- tdanalysis/data/noise_curves/CE40km_1p0MW_Aplus_coat_strain.txt +1000 -0
- tdanalysis/data/noise_curves/CE40km_1p0MW_aLIGO_coat_strain.txt +1000 -0
- tdanalysis/data/noise_curves/CE40km_1p5MW_Aplus_coat_strain.txt +1000 -0
- tdanalysis/data/noise_curves/CE40km_1p5MW_aLIGO_coat_strain.txt +1000 -0
- tdanalysis/data/noise_curves/ET-psd.txt +3000 -0
- tdanalysis/data/noise_curves/ET_cryo_10km_psd.txt +3000 -0
- tdanalysis/data/noise_curves/ET_cryo_15km_psd.txt +3000 -0
- tdanalysis/data/noise_curves/PROVENANCE.md +130 -0
- tdanalysis/data/noise_curves/aplus.txt +3000 -0
- tdanalysis/detectors/__init__.py +89 -0
- tdanalysis/detectors/xg.py +1040 -0
- tdanalysis/dtypes.py +75 -0
- tdanalysis/exe/config.py +129 -0
- tdanalysis/exe/runner.py +755 -0
- tdanalysis/exe/tdpipe.py +72 -0
- tdanalysis/fitting_factor.py +908 -0
- tdanalysis/forms/cd.py +81 -0
- tdanalysis/forms/gs.py +200 -0
- tdanalysis/forms/gs_batched.py +66 -0
- tdanalysis/forms/invld.py +105 -0
- tdanalysis/forms/llt.py +122 -0
- tdanalysis/forms/pcg.py +362 -0
- tdanalysis/gpu/gpu_matrix_multiplier.py +215 -0
- tdanalysis/gpu/kernels.py +14 -0
- tdanalysis/inference/nr_injection.py +178 -0
- tdanalysis/likelihoods/comparison/discriminators.py +218 -0
- tdanalysis/likelihoods/multi/consistency_test.py +232 -0
- tdanalysis/likelihoods/multi/pe.py +442 -0
- tdanalysis/likelihoods/reduced_batch.py +203 -0
- tdanalysis/likelihoods/single/consistency_test.py +443 -0
- tdanalysis/likelihoods/single/pe.py +2424 -0
- tdanalysis/priors/bbh.py +215 -0
- tdanalysis/priors/bilby.py +67 -0
- tdanalysis/utils/bilby.py +480 -0
- tdanalysis/utils/conditioning.py +128 -0
- tdanalysis/utils/io.py +117 -0
- tdanalysis/utils/plotting.py +434 -0
- tdanalysis/utils/serialize.py +62 -0
- tdanalysis/waveforms/__init__.py +9 -0
- tdanalysis/waveforms/nraasur.py +575 -0
- tdanalysis-1.0.0.dist-info/METADATA +174 -0
- tdanalysis-1.0.0.dist-info/RECORD +118 -0
- tdanalysis-1.0.0.dist-info/WHEEL +4 -0
- tdanalysis-1.0.0.dist-info/entry_points.txt +2 -0
- tdanalysis-1.0.0.dist-info/licenses/LICENSE +203 -0
- tdanalysis-1.0.0.dist-info/licenses/NOTICE.md +133 -0
tdanalysis/__init__.py
ADDED
|
File without changes
|
tdanalysis/_compat.py
ADDED
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
"""Model base class, vendored so an installed copy needs no git dependency.
|
|
2
|
+
|
|
3
|
+
``mcsamplers`` (https://gitlab.com/vaishakp/parameter-estimation) is not on
|
|
4
|
+
PyPI, and PyPI refuses any distribution whose metadata carries a PEP 508 direct
|
|
5
|
+
URL reference -- extras included. So a released ``tdanalysis`` cannot declare
|
|
6
|
+
it, and declaring nothing produced the failure this file exists to remove: the
|
|
7
|
+
package imported fine and then died on ``ModuleNotFoundError: 'mcsamplers'`` at
|
|
8
|
+
the first likelihood.
|
|
9
|
+
|
|
10
|
+
The whole surface actually used was one class, imported identically at every
|
|
11
|
+
site::
|
|
12
|
+
|
|
13
|
+
from mcsamplers.model import Model
|
|
14
|
+
|
|
15
|
+
so it is reproduced here rather than depended on. Same author, same terms as
|
|
16
|
+
the rest of the package (see NOTICE.md). ``mcsamplers``' samplers are NOT
|
|
17
|
+
vendored -- only the model contract they call. Install ``mcsamplers`` itself if
|
|
18
|
+
you want to sample with it; this class stays interface-compatible with it, and
|
|
19
|
+
an installed ``mcsamplers`` is preferred at import time when present.
|
|
20
|
+
|
|
21
|
+
The contract, unchanged: a model owns ``xdata``/``ydata``, an initial guess, and
|
|
22
|
+
a dict of ``{name: (min, max)}`` uniform priors. Samplers work in REDUCED
|
|
23
|
+
coordinates -- the unit cube ``[0, 1]^ndim`` -- and the ``*_reduced`` methods
|
|
24
|
+
push a reduced point forward into physical parameters before delegating.
|
|
25
|
+
Subclasses implement ``evaluate_logliklihood`` (spelling preserved).
|
|
26
|
+
"""
|
|
27
|
+
from __future__ import annotations
|
|
28
|
+
|
|
29
|
+
from abc import ABC
|
|
30
|
+
from collections import namedtuple
|
|
31
|
+
|
|
32
|
+
import numpy as np
|
|
33
|
+
|
|
34
|
+
try: # a real mcsamplers install wins
|
|
35
|
+
from mcsamplers.model import Model # noqa: F401
|
|
36
|
+
_VENDORED = False
|
|
37
|
+
except ImportError:
|
|
38
|
+
_VENDORED = True
|
|
39
|
+
|
|
40
|
+
__all__ = ["Model", "Uniform", "pushforward_parameter",
|
|
41
|
+
"pushforward_all_parameters", "vendored"]
|
|
42
|
+
|
|
43
|
+
#: Uniform prior over ``[min, max]`` for one named parameter.
|
|
44
|
+
Uniform = namedtuple("Uniform", ["name", "min", "max"])
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def vendored() -> bool:
|
|
48
|
+
"""True when this module's own ``Model`` is in use, not ``mcsamplers``'."""
|
|
49
|
+
return _VENDORED
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def pushforward_parameter(X, x_prior):
|
|
53
|
+
"""Map ``X`` in ``[0, 1]`` onto ``[x_prior.min, x_prior.max]``."""
|
|
54
|
+
return x_prior.min + X * (x_prior.max - x_prior.min)
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def pushforward_all_parameters(reduced, parameter_priors):
|
|
58
|
+
"""Unit cube -> physical parameters, columnwise.
|
|
59
|
+
|
|
60
|
+
Accepts either a single point or a ``(n, ndim)`` batch; the scalar case is
|
|
61
|
+
promoted and squeezed back, matching the upstream behaviour that several
|
|
62
|
+
callers rely on.
|
|
63
|
+
"""
|
|
64
|
+
try:
|
|
65
|
+
parameters = np.zeros(reduced.shape)
|
|
66
|
+
except AttributeError:
|
|
67
|
+
parameters = np.array([0])
|
|
68
|
+
reduced = np.array([reduced])
|
|
69
|
+
|
|
70
|
+
for idx, (p, prior) in enumerate(zip(reduced.T, parameter_priors)):
|
|
71
|
+
parameters[..., idx] = pushforward_parameter(p, prior)
|
|
72
|
+
|
|
73
|
+
return parameters
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
if _VENDORED:
|
|
77
|
+
|
|
78
|
+
class Model(ABC): # noqa: F811
|
|
79
|
+
"""Parameter-estimation model over uniform priors.
|
|
80
|
+
|
|
81
|
+
Interface-compatible with ``mcsamplers.model.Model``, including the
|
|
82
|
+
``liklihood`` spelling, which is load-bearing: the samplers call these
|
|
83
|
+
names.
|
|
84
|
+
"""
|
|
85
|
+
|
|
86
|
+
def __init__(self, xdata, ydata, initial_guess,
|
|
87
|
+
parameter_priors_dict, truths=None):
|
|
88
|
+
self.xdata = xdata
|
|
89
|
+
self.ydata = ydata
|
|
90
|
+
self.initial_guess = initial_guess
|
|
91
|
+
self.parameter_priors_dict = parameter_priors_dict
|
|
92
|
+
self.truths = truths
|
|
93
|
+
self.initialize_parameter_priors()
|
|
94
|
+
|
|
95
|
+
self.metadata = {
|
|
96
|
+
"xdata": xdata,
|
|
97
|
+
"ydata": ydata,
|
|
98
|
+
"initial_guess": initial_guess,
|
|
99
|
+
"parameter_priors_dict": parameter_priors_dict,
|
|
100
|
+
"truths": truths,
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
# ---- pickling -------------------------------------------------
|
|
104
|
+
# ``parameter_priors`` is a list of namedtuples built at construction;
|
|
105
|
+
# it is dropped and rebuilt rather than pickled, so a subclass that
|
|
106
|
+
# extends __getstate__ keeps working.
|
|
107
|
+
|
|
108
|
+
def __getstate__(self):
|
|
109
|
+
state_rep = self.__dict__.copy()
|
|
110
|
+
state_rep.pop("parameter_priors", None)
|
|
111
|
+
return state_rep
|
|
112
|
+
|
|
113
|
+
def __setstate__(self, other_state):
|
|
114
|
+
self.__dict__.update(other_state)
|
|
115
|
+
self.initialize_parameter_priors()
|
|
116
|
+
|
|
117
|
+
def initialize_parameter_priors(self):
|
|
118
|
+
self.parameter_priors = [
|
|
119
|
+
Uniform(name, rng[0], rng[1])
|
|
120
|
+
for name, rng in self.parameter_priors_dict.items()
|
|
121
|
+
]
|
|
122
|
+
|
|
123
|
+
# ---- likelihood ------------------------------------------------
|
|
124
|
+
|
|
125
|
+
def evaluate_logliklihood(self, parameters):
|
|
126
|
+
raise NotImplementedError
|
|
127
|
+
|
|
128
|
+
def evaluate(self, parameters):
|
|
129
|
+
raise NotImplementedError
|
|
130
|
+
|
|
131
|
+
def evaluate_liklihood(self, parameters):
|
|
132
|
+
return np.exp(self.evaluate_logliklihood(parameters))
|
|
133
|
+
|
|
134
|
+
def evaluate_logliklihood_reduced(self, reduced_parameters):
|
|
135
|
+
return self.evaluate_logliklihood(
|
|
136
|
+
pushforward_all_parameters(reduced_parameters,
|
|
137
|
+
self.parameter_priors))
|
|
138
|
+
|
|
139
|
+
def evaluate_liklihood_reduced(self, reduced_parameters):
|
|
140
|
+
return np.exp(self.evaluate_logliklihood_reduced(reduced_parameters))
|
|
141
|
+
|
|
142
|
+
# ---- priors ----------------------------------------------------
|
|
143
|
+
|
|
144
|
+
def ln_prior_probability(self, parameters):
|
|
145
|
+
ln_prob = 0
|
|
146
|
+
for param, prior in zip(parameters, self.parameter_priors):
|
|
147
|
+
if prior.min < param < prior.max:
|
|
148
|
+
ln_prob += 0
|
|
149
|
+
else:
|
|
150
|
+
ln_prob += -np.inf
|
|
151
|
+
break
|
|
152
|
+
return ln_prob
|
|
153
|
+
|
|
154
|
+
def prior_probability(self, parameters):
|
|
155
|
+
return np.exp(self.ln_prior_probability(parameters))
|
|
156
|
+
|
|
157
|
+
def ln_prior_probability_reduced(self, reduced_parameters):
|
|
158
|
+
return self.ln_prior_probability(
|
|
159
|
+
pushforward_all_parameters(reduced_parameters,
|
|
160
|
+
self.parameter_priors))
|
|
161
|
+
|
|
162
|
+
def prior_probability_reduced(self, reduced_parameters):
|
|
163
|
+
return self.prior_probability(
|
|
164
|
+
pushforward_all_parameters(reduced_parameters,
|
|
165
|
+
self.parameter_priors))
|
|
166
|
+
|
|
167
|
+
# ---- posterior samples -----------------------------------------
|
|
168
|
+
|
|
169
|
+
def pushforward_samples(self, samples):
|
|
170
|
+
return np.array([
|
|
171
|
+
pushforward_all_parameters(samples[idx], self.parameter_priors)
|
|
172
|
+
for idx in range(samples.shape[0])
|
|
173
|
+
])
|