Skip to content

Commit

Permalink
Update parameters from theta to tilt in accordence to Lalsuite
Browse files Browse the repository at this point in the history
  • Loading branch information
kazewong committed Sep 20, 2024
1 parent 799ffc9 commit a94586e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
8 changes: 4 additions & 4 deletions example/GW150914_IMRPhenomPV2.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,11 @@
sample_transforms = [
# ComponentMassesToChirpMassMassRatioTransform,
BoundToUnbound(name_mapping = (["M_c"], ["M_c_unbounded"]), original_lower_bound=M_c_min, original_upper_bound=M_c_max),
BoundToUnbound(name_mapping = (["eta"], ["eta_unbounded"]), original_lower_bound=q_min, original_upper_bound=q_max),
BoundToUnbound(name_mapping = (["q"], ["q_unbounded"]), original_lower_bound=q_min, original_upper_bound=q_max),
BoundToUnbound(name_mapping = (["theta_jn"], ["theta_jn_unbounded"]) , original_lower_bound=0.0, original_upper_bound=jnp.pi),
BoundToUnbound(name_mapping = (["phi_jl"], ["phi_jl_unbounded"]) , original_lower_bound=0.0, original_upper_bound=2 * jnp.pi),
BoundToUnbound(name_mapping = (["theta_1"], ["theta_1_unbounded"]) , original_lower_bound=0.0, original_upper_bound=jnp.pi),
BoundToUnbound(name_mapping = (["theta_2"], ["theta_2_unbounded"]) , original_lower_bound=0.0, original_upper_bound=jnp.pi),
BoundToUnbound(name_mapping = (["tilt_1"], ["tilt_1_unbounded"]) , original_lower_bound=0.0, original_upper_bound=jnp.pi),
BoundToUnbound(name_mapping = (["tilt_2"], ["tilt_2_unbounded"]) , original_lower_bound=0.0, original_upper_bound=jnp.pi),
BoundToUnbound(name_mapping = (["phi_12"], ["phi_12_unbounded"]) , original_lower_bound=0.0, original_upper_bound=2 * jnp.pi),
BoundToUnbound(name_mapping = (["a_1"], ["a_1_unbounded"]) , original_lower_bound=0.0, original_upper_bound=1.0),
BoundToUnbound(name_mapping = (["a_2"], ["a_2_unbounded"]) , original_lower_bound=0.0, original_upper_bound=1.0),
Expand All @@ -126,8 +126,8 @@
]

likelihood_transforms = [
MassRatioToSymmetricMassRatioTransform,
SpinToCartesianSpinTransform(freq_ref=20.),
MassRatioToSymmetricMassRatioTransform,
]


Expand Down
6 changes: 3 additions & 3 deletions src/jimgw/single_event/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def __init__(
freq_ref: Float,
):
name_mapping = (
["theta_jn", "phi_jl", "theta_1", "theta_2", "phi_12", "a_1", "a_2"],
["theta_jn", "phi_jl", "tilt_1", "tilt_2", "phi_12", "a_1", "a_2"],
["iota", "s1_x", "s1_y", "s1_z", "s2_x", "s2_y", "s2_z"],
)
super().__init__(name_mapping)
Expand All @@ -48,8 +48,8 @@ def named_transform(x):
iota, s1x, s1y, s1z, s2x, s2y, s2z = spin_to_cartesian_spin(
x["theta_jn"],
x["phi_jl"],
x["theta_1"],
x["theta_2"],
x["tilt_1"],
x["tilt_2"],
x["phi_12"],
x["a_1"],
x["a_2"],
Expand Down
21 changes: 11 additions & 10 deletions src/jimgw/single_event/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ def eta_to_q(eta: Float) -> Float:
temp = 1 / eta / 2 - 1
return temp - (temp**2 - 1) ** 0.5


def euler_rotation(delta_x: Float[Array, " 3"]):
"""
Calculate the rotation matrix mapping the vector (0, 0, 1) to delta_x
Expand Down Expand Up @@ -395,8 +396,8 @@ def theta_phi_to_ra_dec(theta: Float, phi: Float, gmst: Float) -> tuple[Float, F
def spin_to_cartesian_spin(
thetaJN: Float,
phiJL: Float,
theta1: Float,
theta2: Float,
tilt1: Float,
tilt2: Float,
phi12: Float,
chi1: Float,
chi2: Float,
Expand All @@ -417,9 +418,9 @@ def spin_to_cartesian_spin(
Zenith angle between the total angular momentum and the line of sight
phiJL: Float
Difference between total and orbital angular momentum azimuthal angles
theta1: Float
tilt1: Float
Zenith angle between the spin and orbital angular momenta for the primary object
theta2: Float
tilt2: Float
Zenith angle between the spin and orbital angular momenta for the secondary object
phi12: Float
Difference between the azimuthal angles of the individual spin vector projections
Expand Down Expand Up @@ -483,16 +484,16 @@ def rotate_z(angle, vec):

s1hat = jnp.array(
[
jnp.sin(theta1) * jnp.cos(phiRef),
jnp.sin(theta1) * jnp.sin(phiRef),
jnp.cos(theta1),
jnp.sin(tilt1) * jnp.cos(phiRef),
jnp.sin(tilt1) * jnp.sin(phiRef),
jnp.cos(tilt1),
]
)
s2hat = jnp.array(
[
jnp.sin(theta2) * jnp.cos(phi12 + phiRef),
jnp.sin(theta2) * jnp.sin(phi12 + phiRef),
jnp.cos(theta2),
jnp.sin(tilt2) * jnp.cos(phi12 + phiRef),
jnp.sin(tilt2) * jnp.sin(phi12 + phiRef),
jnp.cos(tilt2),
]
)

Expand Down

0 comments on commit a94586e

Please sign in to comment.