ml4gw 0.6.0__py3-none-any.whl → 0.6.1__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.

Potentially problematic release.


This version of ml4gw might be problematic. Click here for more details.

@@ -590,18 +590,19 @@ class IMRPhenomD(TaylorF2):
590
590
  return fRD, fDM
591
591
 
592
592
  def fmaxCalc(self, fRD, fDM, gamma2, gamma3):
593
- res = torch.zeros_like(gamma2)
594
- res = torch.abs(fRD + (-fDM * gamma3) / gamma2) * (gamma2 > 1).to(
595
- torch.int
596
- ) + torch.abs(
597
- fRD
598
- + (fDM * (-1 + torch.sqrt(1 - gamma2 * gamma2)) * gamma3) / gamma2
599
- ) * (
600
- gamma2 <= 1
601
- ).to(
602
- torch.int
603
- )
604
- return res
593
+ mask = gamma2 <= 1
594
+ # calculate result for gamma2 <= 1 case
595
+ sqrt_term = torch.sqrt(1 - gamma2.pow(2))
596
+ result_case1 = fRD + (fDM * (-1 + sqrt_term) * gamma3) / gamma2
597
+
598
+ # calculate result for gamma2 > 1 case
599
+ # i.e. don't add sqrt term
600
+ result_case2 = fRD + (-fDM * gamma3) / gamma2
601
+
602
+ # combine results using mask
603
+ result = torch.where(mask, result_case1, result_case2)
604
+
605
+ return torch.abs(result)
605
606
 
606
607
  def _linear_interp_finspin(self, finspin):
607
608
  # chi is a batch of final spins i.e. torch.Size([n])
@@ -4,6 +4,7 @@ from jaxtyping import Float
4
4
  from ml4gw.constants import MPC_SEC, MTSUN_SI, PI
5
5
  from ml4gw.constants import EulerGamma as GAMMA
6
6
  from ml4gw.types import BatchTensor, FrequencySeries1d
7
+ from ml4gw.waveforms.conversion import chirp_mass_and_mass_ratio_to_components
7
8
 
8
9
 
9
10
  class TaylorF2(torch.nn.Module):
@@ -60,8 +61,11 @@ class TaylorF2(torch.nn.Module):
60
61
  or phic.shape[0] != inclination.shape[0]
61
62
  ):
62
63
  raise RuntimeError("Tensors should have same batch size")
63
- mass2 = chirp_mass * (1.0 + mass_ratio) ** 0.2 / mass_ratio**0.6
64
- mass1 = mass_ratio * mass2
64
+
65
+ mass1, mass2 = chirp_mass_and_mass_ratio_to_components(
66
+ chirp_mass, mass_ratio
67
+ )
68
+
65
69
  cfac = torch.cos(inclination)
66
70
  pfac = 0.5 * (1.0 + cfac * cfac)
67
71
 
@@ -32,6 +32,23 @@ def XLALSimInspiralL_2PN(eta: BatchTensor):
32
32
  return 1.5 + eta / 6.0
33
33
 
34
34
 
35
+ def chirp_mass_and_mass_ratio_to_components(
36
+ chirp_mass: BatchTensor, mass_ratio: BatchTensor
37
+ ):
38
+ """
39
+ Compute component masses from chirp mass and mass ratio.
40
+ Args:
41
+ chirp_mass: Tensor of chirp mass values
42
+ mass_ratio:
43
+ Tensor of mass ratio values, `m2 / m1`,
44
+ where m1 >= m2, so that mass_ratio <= 1
45
+ """
46
+ total_mass = chirp_mass * (1 + mass_ratio) ** 1.2 / mass_ratio**0.6
47
+ mass_1 = total_mass / (1 + mass_ratio)
48
+ mass_2 = mass_1 * mass_ratio
49
+ return mass_1, mass_2
50
+
51
+
35
52
  def bilby_spins_to_lalsim(
36
53
  theta_jn: BatchTensor,
37
54
  phi_jl: BatchTensor,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ml4gw
3
- Version: 0.6.0
3
+ Version: 0.6.1
4
4
  Summary: Tools for training torch models on gravitational wave data
5
5
  Author: Alec Gunny
6
6
  Author-email: alec.gunny@ligo.org
@@ -40,12 +40,12 @@ ml4gw/waveforms/adhoc/__init__.py,sha256=XVwP4t8TMUj87WY3yMGRTkXsv7_lVr1w8p8iKBW
40
40
  ml4gw/waveforms/adhoc/ringdown.py,sha256=m8IBQTxKBBGFqBtWGEO4KG3DEYR8TTnNyGVdVLaMKa8,3316
41
41
  ml4gw/waveforms/adhoc/sine_gaussian.py,sha256=-MtrI7ydwBTk4K0O4tdkC8-w5OifQszdnWN9__I4XzY,3569
42
42
  ml4gw/waveforms/cbc/__init__.py,sha256=hGbPsFNAIveYJnff8qKY8RWeBPFtZoYcnGHxraPWtWI,99
43
- ml4gw/waveforms/cbc/phenom_d.py,sha256=vA60SjOvWSIcsU83-KEw2hnU3ATo4eW8A2mMmuMXo7Y,46941
43
+ ml4gw/waveforms/cbc/phenom_d.py,sha256=3JhN77Xl5foqjmdDJSw4GrTYcaOr1RxXdL1XjUAb8IY,47053
44
44
  ml4gw/waveforms/cbc/phenom_d_data.py,sha256=WA1FBxUp9fo1IQaV_OLJ_5g5gI166mY1FtG9n25he9U,53447
45
45
  ml4gw/waveforms/cbc/phenom_p.py,sha256=Y8L2r3UPkJeQqJNwknWBmcG_nO2Z_aXJ_DfWc_lzJhg,26720
46
- ml4gw/waveforms/cbc/taylorf2.py,sha256=ySYLGTT_c3k4NzPDsQ9v822kzvU6TwYpELJEWlCDGQE,10428
47
- ml4gw/waveforms/conversion.py,sha256=F5fsNeqf6KHY66opDIj8fN9bwUcwrt9f7PCaxLAi9Jk,6367
46
+ ml4gw/waveforms/cbc/taylorf2.py,sha256=_s-faE8yWMULMxGd4VvzPI54R3G-O2TF2G4-T2m2rDM,10510
47
+ ml4gw/waveforms/conversion.py,sha256=zPkaGkMVqsdrF0fS3ZscyP-2jX8YK40d4smUoJb4gj4,6903
48
48
  ml4gw/waveforms/generator.py,sha256=dO6RQ96EC87p2q0tEkxA62XkkJc1xARFO1SKcGvyDhM,1272
49
- ml4gw-0.6.0.dist-info/METADATA,sha256=6bwcfu6ojmrxgtMnFVViy9FanSmMXjhnN33yAzViFzo,5785
50
- ml4gw-0.6.0.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
51
- ml4gw-0.6.0.dist-info/RECORD,,
49
+ ml4gw-0.6.1.dist-info/METADATA,sha256=APoH6HIVkaBFuDLHQQ58NVmu9VJ5zBuo26cLwjHBrE4,5785
50
+ ml4gw-0.6.1.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
51
+ ml4gw-0.6.1.dist-info/RECORD,,
File without changes