Skip to content
Snippets Groups Projects
Commit 71be186d authored by Colm Talbot's avatar Colm Talbot
Browse files

Rename new parameters

parent 9c9701d0
No related branches found
No related tags found
No related merge requests found
......@@ -26,7 +26,7 @@ from .prior import BBHPriorDict, CBCPriorDict, Cosmological
from .source import lal_binary_black_hole
from .utils import (
noise_weighted_inner_product, build_roq_weights, blockwise_dot_product,
kappa_eta_to_ra_dec)
zenith_azimuth_to_ra_dec)
from .waveform_generator import WaveformGenerator
from collections import namedtuple
......@@ -85,7 +85,7 @@ class GravitationalWaveTransient(Likelihood):
Definition of the reference frame for the sky location.
- "sky": sample in RA/dec, this is the default
- e.g., "H1L1", ["H1", "L1"], InterferometerList(["H1", "L1"]):
sample in azimuth and zenith, `eta` and `kappa` defined in the
sample in azimuth and zenith, `azimuth` and `zenith` defined in the
frame where the z-axis is aligned the the vector connecting H1
and L1.
time_reference: str, optional
......@@ -760,8 +760,8 @@ class GravitationalWaveTransient(Likelihood):
def get_sky_frame_parameters(self):
time = self.parameters['{}_time'.format(self.time_reference)]
if not self.reference_frame == "sky":
ra, dec = kappa_eta_to_ra_dec(
self.parameters['kappa'], self.parameters['eta'],
ra, dec = zenith_azimuth_to_ra_dec(
self.parameters['zenith'], self.parameters['azimuth'],
time, self.reference_frame)
else:
ra = self.parameters["ra"]
......@@ -937,7 +937,7 @@ class ROQGravitationalWaveTransient(GravitationalWaveTransient):
Definition of the reference frame for the sky location.
- "sky": sample in RA/dec, this is the default
- e.g., "H1L1", ["H1", "L1"], InterferometerList(["H1", "L1"]):
sample in azimuth and zenith, `eta` and `kappa` defined in the
sample in azimuth and zenith, `azimuth` and `zenith` defined in the
frame where the z-axis is aligned the the vector connecting H1
and L1.
time_reference: str, optional
......
......@@ -329,7 +329,7 @@ def euler_rotation(delta_x):
return total_rotation
def kappa_eta_to_theta_phi(kappa, eta, ifos):
def zenith_azimuth_to_theta_phi(zenith, azimuth, ifos):
"""
Convert from the 'detector frame' to the Earth frame.
......@@ -348,8 +348,9 @@ def kappa_eta_to_theta_phi(kappa, eta, ifos):
"""
delta_x = ifos[0].geometry.vertex - ifos[1].geometry.vertex
omega_prime = np.array([
np.sin(kappa) * np.cos(eta), np.sin(kappa) * np.sin(eta),
np.cos(kappa)])
np.sin(zenith) * np.cos(azimuth),
np.sin(zenith) * np.sin(azimuth),
np.cos(zenith)])
rotation_matrix = euler_rotation(delta_x)
omega = np.dot(rotation_matrix, omega_prime)
theta = np.arccos(omega[2])
......@@ -357,7 +358,7 @@ def kappa_eta_to_theta_phi(kappa, eta, ifos):
return theta, phi
def kappa_eta_to_ra_dec(kappa, eta, geocent_time, ifos):
def zenith_azimuth_to_ra_dec(zenith, azimuth, geocent_time, ifos):
"""
Convert from the 'detector frame' to the Earth frame.
......@@ -376,7 +377,7 @@ def kappa_eta_to_ra_dec(kappa, eta, geocent_time, ifos):
ra, dec: float
The zenith and azimuthal angles in the sky frame.
"""
theta, phi = kappa_eta_to_theta_phi(kappa, eta, ifos)
theta, phi = zenith_azimuth_to_theta_phi(zenith, azimuth, ifos)
gmst = lal.GreenwichMeanSiderealTime(geocent_time)
ra, dec = theta_phi_to_ra_dec(theta, phi, gmst)
ra = ra % (2 * np.pi)
......
......@@ -234,11 +234,11 @@ class TestGWTransient(unittest.TestCase):
)
parameters = self.parameters.copy()
del parameters["ra"], parameters["dec"]
parameters["kappa"] = 1.0
parameters["eta"] = 1.0
parameters["ra"], parameters["dec"] = bilby.gw.utils.kappa_eta_to_ra_dec(
kappa=parameters["kappa"],
eta=parameters["eta"],
parameters["zenith"] = 1.0
parameters["azimuth"] = 1.0
parameters["ra"], parameters["dec"] = bilby.gw.utils.zenith_azimuth_to_ra_dec(
zenith=parameters["zenith"],
azimuth=parameters["azimuth"],
geocent_time=parameters["geocent_time"],
ifos=bilby.gw.detector.InterferometerList(["H1", "L1"])
)
......
......@@ -265,8 +265,8 @@ class TestSkyFrameConversion(unittest.TestCase):
self.priors = bilby.core.prior.PriorDict()
self.priors["ra"] = bilby.core.prior.Uniform(0, 2 * np.pi)
self.priors["dec"] = bilby.core.prior.Cosine()
self.priors["eta"] = bilby.core.prior.Uniform(0, 2 * np.pi)
self.priors["kappa"] = bilby.core.prior.Sine()
self.priors["azimuth"] = bilby.core.prior.Uniform(0, 2 * np.pi)
self.priors["zenith"] = bilby.core.prior.Sine()
self.priors["time"] = bilby.core.prior.Uniform(-0.1, 0.1)
self.ifos = bilby.gw.detector.InterferometerList(["H1", "L1"])
self.samples = self.priors.sample(10000)
......@@ -277,14 +277,14 @@ class TestSkyFrameConversion(unittest.TestCase):
del self.samples
def test_conversion_gives_correct_prior(self) -> None:
kappas = self.samples["kappa"]
etas = self.samples["eta"]
zeniths = self.samples["zenith"]
azimuths = self.samples["azimuth"]
times = self.samples["time"]
args = zip(*[
(kappa, eta, time, self.ifos)
for kappa, eta, time in zip(kappas, etas, times)
(zenith, azimuth, time, self.ifos)
for zenith, azimuth, time in zip(zeniths, azimuths, times)
])
ras, decs = zip(*map(bilby.gw.utils.kappa_eta_to_ra_dec, *args))
ras, decs = zip(*map(bilby.gw.utils.zenith_azimuth_to_ra_dec, *args))
self.assertGreaterEqual(ks_2samp(self.samples["ra"], ras).pvalue, 0.01)
self.assertGreaterEqual(ks_2samp(self.samples["dec"], decs).pvalue, 0.01)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment