jaxtfwaves 0.2.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.
@@ -0,0 +1,758 @@
1
+ #! /usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+ """Extended SOBHBParams with automatic parameter computation.
4
+
5
+ This module provides utilities to convert between several mass and spin
6
+ parameterizations and a JAX-compatible dataclass for SOBHB parameters.
7
+ """
8
+
9
+ # Note: keep naming consistent with the scientific literature; many names are
10
+ # intentionally camelCase-like to match upstream conventions.
11
+
12
+ import flax
13
+ import jax
14
+ import jax.numpy as jnp
15
+
16
+
17
+ # Conversion between mass ratio and symmetric mass ratio
18
+ def qofeta(eta):
19
+ """Return mass ratio q from symmetric mass ratio eta."""
20
+ return (1.0 + jnp.sqrt(1.0 - 4.0 * eta) - 2.0 * eta) / (2.0 * eta)
21
+
22
+
23
+ def etaofq(q):
24
+ """Return symmetric mass ratio eta from mass ratio q."""
25
+ return q / (1.0 + q) ** 2
26
+
27
+
28
+ # Mass difference delta = (m1-m2) / (m1+m2)
29
+ def deltaofq(q):
30
+ """Return mass difference delta from mass ratio q."""
31
+ return (q - 1.0) / (q + 1.0)
32
+
33
+
34
+ # Conversion between mass parameters
35
+ def Mchirpofm1m2(m1, m2):
36
+ """Return chirp mass from component masses m1, m2."""
37
+ return (m1 * m2) ** (3.0 / 5) / (m1 + m2) ** (1.0 / 5)
38
+
39
+
40
+ def etaofm1m2(m1, m2):
41
+ """Return symmetric mass ratio eta from component masses."""
42
+ return (m1 * m2) / (m1 + m2) ** 2.0
43
+
44
+
45
+ def m1ofMchirpeta(Mchirp, eta):
46
+ """Return m1 from chirp mass and eta."""
47
+ M = Mchirp * jnp.power(eta, -3.0 / 5)
48
+ delta = jnp.sqrt(1 - 4 * eta)
49
+ return M * (1 + delta) / 2.0
50
+
51
+
52
+ def m2ofMchirpeta(Mchirp, eta):
53
+ """Return m2 from chirp mass and eta."""
54
+ M = Mchirp * jnp.power(eta, -3.0 / 5)
55
+ delta = jnp.sqrt(1 - 4 * eta)
56
+ return M * (1 - delta) / 2.0
57
+
58
+
59
+ def Mofm1m2(m1, m2):
60
+ """Return total mass M = m1 + m2."""
61
+ return m1 + m2
62
+
63
+
64
+ def qofm1m2(m1, m2):
65
+ """Return mass ratio q = m1/m2."""
66
+ return m1 / m2
67
+
68
+
69
+ def m1ofMq(M, q):
70
+ """Return m1 from total mass M and mass ratio q."""
71
+ return M * q / (1 + q)
72
+
73
+
74
+ def m2ofMq(M, q):
75
+ """Return m2 from total mass M and mass ratio q."""
76
+ return M * 1 / (1 + q)
77
+
78
+
79
+ def MofMchirpeta(Mchirp, eta):
80
+ """Return total mass M from chirp mass and eta."""
81
+ return Mchirp * jnp.power(eta, -3.0 / 5)
82
+
83
+
84
+ def MchirpofMq(M, q):
85
+ """Return chirp mass from (M, q)."""
86
+ eta = etaofq(q)
87
+ return M * jnp.power(eta, 3.0 / 5)
88
+
89
+
90
+ # Conversion between spin parameters
91
+ def chisofchi1chi2(chi1, chi2):
92
+ """Return chis (effective aligned spin) from chi1 and chi2."""
93
+ return (chi1 + chi2) / 2.0
94
+
95
+
96
+ def chiaofchi1chi2(chi1, chi2):
97
+ """Return chia (anti-symmetric spin) from chi1 and chi2."""
98
+ return (chi1 - chi2) / 2.0
99
+
100
+
101
+ def chi1ofchischia(chis, chia):
102
+ """Return chi1 from chis and chia."""
103
+ return chis + chia
104
+
105
+
106
+ def chi2ofchischia(chis, chia):
107
+ """Return chi2 from chis and chia."""
108
+ return chis - chia
109
+
110
+
111
+ def chipofchi1chi2(chi1, chi2, q):
112
+ """Return precessing spin parameter chip from chi1, chi2 and q."""
113
+ return q / (1.0 + q) * chi1 + 1 / (1.0 + q) * chi2
114
+
115
+
116
+ def chimofchi1chi2(chi1, chi2, q):
117
+ """Return chim (anti-symmetric precessing combination) from chi1, chi2, q."""
118
+ return q / (1.0 + q) * chi1 - 1 / (1.0 + q) * chi2
119
+
120
+
121
+ def chi1ofchipchim(chip, chim, q):
122
+ """Reconstruct chi1 from chip, chim and q."""
123
+ return (1.0 + q) / (2 * q) * (chip + chim)
124
+
125
+
126
+ def chi2ofchipchim(chip, chim, q):
127
+ """Reconstruct chi2 from chip, chim and q."""
128
+ return (1.0 + q) / (2) * (chip - chim)
129
+
130
+
131
+ def chipofchischia(chis, chia, q):
132
+ """Return chip from chis and chia and q."""
133
+ return chis + (q - 1) / (1.0 + q) * chia
134
+
135
+
136
+ def chimofchischia(chis, chia, q):
137
+ """Return chim from chis and chia and q."""
138
+ return chia + (q - 1) / (1.0 + q) * chis
139
+
140
+
141
+ def chisofchipchim(chip, chim, q):
142
+ """Return chis from chip and chim for given q."""
143
+ return (1 + q) ** 2 / (4.0 * q) * (chip - (q - 1) / (1.0 + q) * chim)
144
+
145
+
146
+ def chiaofchipchim(chip, chim, q):
147
+ """Return chia from chip and chim for given q."""
148
+ return (1 + q) ** 2 / (4.0 * q) * (chim - (q - 1) / (1.0 + q) * chip)
149
+
150
+
151
+ def chiPNofchi1chi2(chi1, chi2, q):
152
+ """Return normalized chiPN from chi1, chi2 and q (PN-based formula)."""
153
+ eta = etaofq(q)
154
+ chiPN = 1.0 / 113 * eta * ((113 * q + 75.0) * chi1 + (113 / q + 75.0) * chi2)
155
+ return chiPN / (1.0 - 76.0 * eta / 113.0)
156
+
157
+
158
+ def chiPNofchipchim(chip, chim, q):
159
+ """Return normalized chiPN from chip and chim (alternative)."""
160
+ eta = etaofq(q)
161
+ chiPN = 1.0 / 113 * (94 * chip + (q - 1.0) / (q + 1.0) * 19 * chim)
162
+ return chiPN / (1.0 - 76.0 * eta / 113.0)
163
+
164
+
165
+ def chiPNofchischia(chis, chia, q):
166
+ """Return normalized chiPN from chis, chia and q."""
167
+ eta = etaofq(q)
168
+ chiPN = 1.0 / 113 * eta * ((113 * q + 113 / q + 150.0) * chis + (113 * q - 113 / q) * chia)
169
+ return chiPN / (1.0 - 76.0 * eta / 113.0)
170
+
171
+
172
+ def chipofchiPNchim(chipn, chim, q):
173
+ """Return chip from normalized chiPN and chim for given q."""
174
+ eta = etaofq(q)
175
+ chiPN = chipn * (1.0 - 76.0 * eta / 113.0)
176
+ return 1.0 / 94 * (113 * chiPN - (q - 1.0) / (q + 1.0) * 19 * chim)
177
+
178
+
179
+ # ======================================================
180
+ # Mass parameter conversions (JIT-compiled)
181
+ # ======================================================
182
+
183
+
184
+ @jax.jit
185
+ def m1_m2_to_Mchirp_eta(m1: float, m2: float):
186
+ """Convert component masses to chirp mass and symmetric mass ratio.
187
+
188
+ Args:
189
+ m1: Primary mass (m1 >= m2)
190
+ m2: Secondary mass
191
+
192
+ Returns:
193
+ Mchirp, eta
194
+ """
195
+ Mtot = m1 + m2
196
+ eta = (m1 * m2) / (Mtot**2)
197
+ Mchirp = Mtot * eta ** (3.0 / 5.0)
198
+ return Mchirp, eta
199
+
200
+
201
+ @jax.jit
202
+ def Mchirp_eta_to_m1_m2(Mchirp: float, eta: float):
203
+ """Convert chirp mass and symmetric mass ratio to component masses.
204
+
205
+ Args:
206
+ Mchirp: Chirp mass
207
+ eta: Symmetric mass ratio
208
+
209
+ Returns:
210
+ m1, m2 (with m1 >= m2)
211
+ """
212
+ Mtot = Mchirp / (eta ** (3.0 / 5.0))
213
+ # Solve quadratic equation for mass ratio
214
+ # m1 = Mtot * (1 + sqrt(1 - 4*eta)) / 2
215
+ # m2 = Mtot * (1 - sqrt(1 - 4*eta)) / 2
216
+ sqrt_term = jnp.sqrt(1.0 - 4.0 * eta)
217
+ m1 = Mtot * (1.0 + sqrt_term) / 2.0
218
+ m2 = Mtot * (1.0 - sqrt_term) / 2.0
219
+ return m1, m2
220
+
221
+
222
+ @jax.jit
223
+ def m1_m2_to_Mtot_q(m1: float, m2: float):
224
+ """Convert component masses to total mass and mass ratio.
225
+
226
+ Args:
227
+ m1: Primary mass (m1 >= m2)
228
+ m2: Secondary mass
229
+
230
+ Returns:
231
+ Mtot, q (where q = m1/m2 >= 1)
232
+ """
233
+ Mtot = m1 + m2
234
+ q = m1 / m2
235
+ return Mtot, q
236
+
237
+
238
+ @jax.jit
239
+ def Mtot_q_to_m1_m2(Mtot: float, q: float):
240
+ """Convert total mass and mass ratio to component masses.
241
+
242
+ Args:
243
+ Mtot: Total mass
244
+ q: Mass ratio (q = m1/m2 >= 1)
245
+
246
+ Returns:
247
+ m1, m2 (with m1 >= m2)
248
+ """
249
+ m2 = Mtot / (1.0 + q)
250
+ m1 = q * m2
251
+ return m1, m2
252
+
253
+
254
+ @jax.jit
255
+ def Mchirp_q_to_m1_m2(Mchirp: float, q: float):
256
+ """Convert chirp mass and mass ratio to component masses.
257
+
258
+ Args:
259
+ Mchirp: Chirp mass
260
+ q: Mass ratio (q = m1/m2 >= 1)
261
+
262
+ Returns:
263
+ m1, m2 (with m1 >= m2)
264
+ """
265
+ eta = q / ((1.0 + q) ** 2)
266
+ return Mchirp_eta_to_m1_m2(Mchirp, eta)
267
+
268
+
269
+ # ======================================================
270
+ # Spin parameter conversions (JIT-compiled)
271
+ # ======================================================
272
+
273
+
274
+ @jax.jit
275
+ def chip_chim_to_chi1_chi2(chip: float, chim: float, m1: float, m2: float):
276
+ """Convert effective spin parameters to component spins.
277
+
278
+ Note: This assumes aligned spins. For precessing spins, additional
279
+ information about spin orientations would be needed.
280
+
281
+ Args:
282
+ chip: Precessing spin parameter
283
+ chim: Anti-symmetric spin combination
284
+ m1: Primary mass
285
+ m2: Secondary mass
286
+
287
+ Returns:
288
+ chi1, chi2
289
+ """
290
+ q = m1 / m2
291
+
292
+ # Invert:
293
+ # chip = (q*chi1 + chi2)/(1+q)
294
+ # chim = (q*chi1 - chi2)/(1+q)
295
+ chi1 = (1.0 + q) / (2.0 * q) * (chip + chim)
296
+ chi2 = (1.0 + q) / 2.0 * (chip - chim)
297
+
298
+ return chi1, chi2
299
+
300
+
301
+ @jax.jit
302
+ def chi1_chi2_to_chis_chia(chi1: float, chi2: float):
303
+ """Convert component spins to effective and anti-symmetric spin parameters.
304
+
305
+ Args:
306
+ chi1: Dimensionless spin of primary
307
+ chi2: Dimensionless spin of secondary
308
+ m1: Primary mass
309
+ m2: Secondary mass
310
+
311
+ Returns:
312
+ chis: Symmetric spin parameter
313
+ chia: Anti-symmetric spin parameter
314
+ """
315
+ chis = (chi1 + chi2) / 2.0
316
+ chia = (chi1 - chi2) / 2.0
317
+ return chis, chia
318
+
319
+
320
+ @jax.jit
321
+ def chi1_chi2_to_chip_chim(chi1: float, chi2: float, q: float):
322
+ """Convert component spins to effective and anti-symmetric spin parameters.
323
+
324
+ Args:
325
+ chi1: Dimensionless spin of primary
326
+ chi2: Dimensionless spin of secondary
327
+ m1: Primary mass
328
+ m2: Secondary mass
329
+
330
+ Returns:
331
+ chis: Symmetric spin parameter
332
+ chia: Anti-symmetric spin parameter
333
+ """
334
+ chip = (q * chi1 + chi2) / (1.0 + q)
335
+ chim = (q * chi1 - chi2) / (1.0 + q)
336
+ return chip, chim
337
+
338
+
339
+ @jax.jit
340
+ def chieff_chia_to_chi1_chi2(chieff: float, chia: float, m1: float, m2: float):
341
+ """Convert effective spin parameters to component spins.
342
+
343
+ Args:
344
+ chieff: Effective aligned spin
345
+ chia: Anti-symmetric spin parameter
346
+ m1: Primary mass
347
+ m2: Secondary mass
348
+
349
+ Returns:
350
+ chi1, chi2
351
+ """
352
+ Mtot = m1 + m2
353
+ chi1 = chieff + (m2 / Mtot) * 2.0 * chia
354
+ chi2 = chieff - (m1 / Mtot) * 2.0 * chia
355
+ return chi1, chi2
356
+
357
+
358
+ # ======================================================
359
+ # Angular parameters conversion
360
+ # ======================================================
361
+
362
+
363
+ @jax.jit
364
+ def phi_left_right_to_phi0_psi(phi_left: float, phi_right: float):
365
+ """Compute phi0 and psi from phi_left and phi_right."""
366
+ phi = 0.5 * (phi_left + phi_right)
367
+ psi = 0.25 * (phi_right - phi_left)
368
+ return phi, psi
369
+
370
+
371
+ @jax.jit
372
+ def phi0_psi_to_phi_left_right(phi: float, psi: float):
373
+ """Compute pih_left and phi_right from phi0 and psi."""
374
+ phi_left = phi - 2.0 * psi
375
+ phi_right = phi + 2 * psi
376
+ return phi_left, phi_right
377
+
378
+
379
+ # ======================================================
380
+ # Extended SOBHBParams dataclass
381
+ # ======================================================
382
+
383
+
384
+ @flax.struct.dataclass
385
+ class SOBHBParams:
386
+ """JAX-compatible dataclass that contains source parameters.
387
+
388
+ This stores all parameters internally, with automatic computation
389
+ of derived quantities. The primary stored parameters are:
390
+ - m1, m2 (component masses)
391
+ - chi1, chi2 (component spins)
392
+
393
+ But the class also computes and stores:
394
+ - Mchirp, eta, Mtot, q (derived mass parameters)
395
+ - chip, chim, chis, chia, chipn (derived spin parameters)
396
+
397
+ Use the factory methods to construct from different parameterizations.
398
+ """
399
+
400
+ # Primary mass parameters
401
+ m1: float
402
+ m2: float
403
+
404
+ # Derived mass parameters
405
+ Mchirp: float
406
+ eta: float
407
+ Mtot: float
408
+ q: float
409
+
410
+ # Primary spin parameters
411
+ chi1: float
412
+ chi2: float
413
+
414
+ # Derived spin parameters
415
+ chip: float
416
+ chim: float
417
+ chis: float
418
+ chia: float
419
+ chipn: float
420
+
421
+ # Other physical parameters
422
+ dist: float
423
+ fstart: float
424
+ phi0: float
425
+ iota: float
426
+ psi: float
427
+ ra: float
428
+ dec: float
429
+ t_obs: float
430
+ cadence: float
431
+
432
+ # Constructions that help lift degeneracies
433
+ phi_left: float
434
+ phi_right: float
435
+ # A_left: float
436
+ # A_right: float
437
+
438
+ # ======================================================
439
+ # Factory methods for different parameterizations
440
+ # ======================================================
441
+
442
+ @staticmethod
443
+ def from_m1_m2(
444
+ m1: float,
445
+ m2: float,
446
+ chi1: float,
447
+ chi2: float,
448
+ dist: float,
449
+ fstart: float,
450
+ phi0: float,
451
+ iota: float,
452
+ psi: float,
453
+ ra: float,
454
+ dec: float,
455
+ t_obs: float,
456
+ cadence: float,
457
+ ):
458
+ """Construct from component masses m1, m2.
459
+
460
+ This is the primary constructor that computes all derived quantities.
461
+ """
462
+ # Ensure m1 >= m2
463
+ m1_use, m2_use = jnp.where(m1 >= m2, jnp.asarray([m1, m2]), jnp.asarray([m2, m1]))
464
+ chi1_use, chi2_use = jnp.where(
465
+ m1 >= m2, jnp.asarray([chi1, chi2]), jnp.asarray([chi2, chi1])
466
+ )
467
+
468
+ # Compute derived mass parameters
469
+ Mchirp, eta = m1_m2_to_Mchirp_eta(m1_use, m2_use)
470
+ Mtot, q = m1_m2_to_Mtot_q(m1_use, m2_use)
471
+
472
+ # Compute derived spin parameters
473
+ chis, chia = chi1_chi2_to_chis_chia(chi1_use, chi2_use)
474
+ chip, chim = chi1_chi2_to_chip_chim(chi1_use, chi2_use, q)
475
+ chipn = chiPNofchi1chi2(chi1_use, chi2_use, q)
476
+
477
+ # Derived angular (distance to be added) parameters
478
+ phi_left, phi_right = phi0_psi_to_phi_left_right(phi0, psi)
479
+
480
+ return SOBHBParams(
481
+ m1=m1_use,
482
+ m2=m2_use,
483
+ Mchirp=Mchirp,
484
+ eta=eta,
485
+ Mtot=Mtot,
486
+ q=q,
487
+ chi1=chi1_use,
488
+ chi2=chi2_use,
489
+ chis=chis,
490
+ chia=chia,
491
+ chip=chip,
492
+ chim=chim,
493
+ chipn=chipn,
494
+ dist=dist,
495
+ fstart=fstart,
496
+ phi0=phi0,
497
+ iota=iota,
498
+ psi=psi,
499
+ ra=ra,
500
+ dec=dec,
501
+ phi_right=phi_right,
502
+ phi_left=phi_left,
503
+ t_obs=t_obs,
504
+ cadence=cadence,
505
+ )
506
+
507
+ @staticmethod
508
+ def from_Mchirp_eta(
509
+ Mchirp: float,
510
+ eta: float,
511
+ chi1: float,
512
+ chi2: float,
513
+ dist: float,
514
+ fstart: float,
515
+ phi0: float,
516
+ iota: float,
517
+ psi: float,
518
+ ra: float,
519
+ dec: float,
520
+ t_obs: float,
521
+ cadence: float,
522
+ ):
523
+ """Construct from chirp mass and symmetric mass ratio."""
524
+ # Convert to component masses
525
+ m1, m2 = Mchirp_eta_to_m1_m2(Mchirp, eta)
526
+
527
+ # Use primary constructor
528
+ return SOBHBParams.from_m1_m2(
529
+ m1,
530
+ m2,
531
+ chi1,
532
+ chi2,
533
+ dist,
534
+ fstart,
535
+ phi0,
536
+ iota,
537
+ psi,
538
+ ra,
539
+ dec,
540
+ t_obs,
541
+ cadence,
542
+ )
543
+
544
+ @staticmethod
545
+ def from_Mtot_q(
546
+ Mtot: float,
547
+ q: float,
548
+ chi1: float,
549
+ chi2: float,
550
+ dist: float,
551
+ fstart: float,
552
+ phi0: float,
553
+ iota: float,
554
+ psi: float,
555
+ ra: float,
556
+ dec: float,
557
+ t_obs: float,
558
+ cadence: float,
559
+ ):
560
+ """Construct from total mass and mass ratio."""
561
+ # Convert to component masses
562
+ m1, m2 = Mtot_q_to_m1_m2(Mtot, q)
563
+
564
+ # Use primary constructor
565
+ return SOBHBParams.from_m1_m2(
566
+ m1,
567
+ m2,
568
+ chi1,
569
+ chi2,
570
+ dist,
571
+ fstart,
572
+ phi0,
573
+ iota,
574
+ psi,
575
+ ra,
576
+ dec,
577
+ t_obs,
578
+ cadence,
579
+ )
580
+
581
+ @staticmethod
582
+ def from_Mchirp_q(
583
+ Mchirp: float,
584
+ q: float,
585
+ chi1: float,
586
+ chi2: float,
587
+ dist: float,
588
+ fstart: float,
589
+ phi0: float,
590
+ iota: float,
591
+ psi: float,
592
+ ra: float,
593
+ dec: float,
594
+ t_obs: float,
595
+ cadence: float,
596
+ ):
597
+ """Construct from chirp mass and mass ratio."""
598
+ # Convert to component masses
599
+ m1, m2 = Mchirp_q_to_m1_m2(Mchirp, q)
600
+
601
+ # Use primary constructor
602
+ return SOBHBParams.from_m1_m2(
603
+ m1,
604
+ m2,
605
+ chi1,
606
+ chi2,
607
+ dist,
608
+ fstart,
609
+ phi0,
610
+ iota,
611
+ psi,
612
+ ra,
613
+ dec,
614
+ t_obs,
615
+ cadence,
616
+ )
617
+
618
+ @staticmethod
619
+ def from_Mchirp_eta_with_chiPN_chim(
620
+ Mchirp: float,
621
+ eta: float,
622
+ chipn: float,
623
+ chim: float,
624
+ dist: float,
625
+ fstart: float,
626
+ phi0: float,
627
+ iota: float,
628
+ psi: float,
629
+ ra: float,
630
+ dec: float,
631
+ t_obs: float,
632
+ cadence: float,
633
+ ):
634
+ """Construct from chirp mass, eta, and effective spin parameters."""
635
+ # Convert to component masses
636
+ m1, m2 = Mchirp_eta_to_m1_m2(Mchirp, eta)
637
+ q = m1 / m2
638
+
639
+ # Convert spin parameters
640
+ chip = chipofchiPNchim(chipn, chim, q)
641
+ chi1 = chi1ofchipchim(chip, chim, q)
642
+ chi2 = chi2ofchipchim(chip, chim, q)
643
+
644
+ # Use primary constructor
645
+ return SOBHBParams.from_m1_m2(
646
+ m1,
647
+ m2,
648
+ chi1,
649
+ chi2,
650
+ dist,
651
+ fstart,
652
+ phi0,
653
+ iota,
654
+ psi,
655
+ ra,
656
+ dec,
657
+ t_obs,
658
+ cadence,
659
+ )
660
+
661
+ @staticmethod
662
+ def from_Mchirp_eta_with_chiPN_chim_left_right_quantities(
663
+ Mchirp: float,
664
+ eta: float,
665
+ chipn: float,
666
+ chim: float,
667
+ dist: float,
668
+ fstart: float,
669
+ phi_left: float,
670
+ iota: float,
671
+ phi_right: float,
672
+ ra: float,
673
+ dec: float,
674
+ t_obs: float,
675
+ cadence: float,
676
+ ):
677
+ """Construct from chirp mass, eta, chi_PN, chi_m, phi_left, phi_right."""
678
+ phi, psi = phi_left_right_to_phi0_psi(phi_left, phi_right)
679
+ return SOBHBParams.from_Mchirp_eta_with_chiPN_chim(
680
+ Mchirp,
681
+ eta,
682
+ chipn,
683
+ chim,
684
+ dist,
685
+ fstart,
686
+ phi,
687
+ iota,
688
+ psi,
689
+ ra,
690
+ dec,
691
+ t_obs,
692
+ cadence,
693
+ )
694
+
695
+
696
+ # ======================================================
697
+ # Usage examples
698
+ # ======================================================
699
+
700
+ if __name__ == "__main__":
701
+ print("=== Example 1: Construct from m1, m2 ===")
702
+ params1 = SOBHBParams.from_m1_m2(
703
+ m1=1e6,
704
+ m2=8e5,
705
+ chi1=0.5,
706
+ chi2=-0.3,
707
+ dist=1000.0,
708
+ fstart=1e-3,
709
+ phi0=0.0,
710
+ iota=0.5,
711
+ psi=0.3,
712
+ ra=1.2,
713
+ dec=0.8,
714
+ t_obs=31536000.0,
715
+ cadence=5.0,
716
+ )
717
+ print(f"m1={params1.m1}, m2={params1.m2}")
718
+ print(f"Mchirp={params1.Mchirp}, eta={params1.eta}")
719
+ print(f"Mtot={params1.Mtot}, q={params1.q}")
720
+ print(f"chi1={params1.chi1}, chi2={params1.chi2}")
721
+ print(f"chieff={params1.chis}, chia={params1.chia}")
722
+
723
+ print("\n=== Example 2: Construct from Mchirp, eta ===")
724
+ params2 = SOBHBParams.from_Mchirp_eta(
725
+ Mchirp=params1.Mchirp,
726
+ eta=params1.eta,
727
+ chi1=0.5,
728
+ chi2=-0.3,
729
+ dist=1000.0,
730
+ fstart=1e-3,
731
+ phi0=0.0,
732
+ iota=0.5,
733
+ psi=0.3,
734
+ ra=1.2,
735
+ dec=0.8,
736
+ t_obs=31536000.0,
737
+ cadence=5.0,
738
+ )
739
+ print(f"Recovered: m1={params2.m1}, m2={params2.m2}")
740
+
741
+ print("\n=== Example 3: Construct from Mtot, q ===")
742
+ params3 = SOBHBParams.from_Mtot_q(
743
+ Mtot=1.8e6,
744
+ q=1.25,
745
+ chi1=0.5,
746
+ chi2=-0.3,
747
+ dist=1000.0,
748
+ fstart=1e-3,
749
+ phi0=0.0,
750
+ iota=0.5,
751
+ psi=0.3,
752
+ ra=1.2,
753
+ dec=0.8,
754
+ t_obs=31536000.0,
755
+ cadence=5.0,
756
+ )
757
+ print(f"m1={params3.m1}, m2={params3.m2}")
758
+ print(f"Mtot={params3.Mtot}, q={params3.q}")