From 71be186d61beeac337f59f0e0824b23fb3066e5a Mon Sep 17 00:00:00 2001 From: Colm Talbot <colm.talbot@ligo.org> Date: Fri, 8 May 2020 11:22:03 -0400 Subject: [PATCH] Rename new parameters --- bilby/gw/likelihood.py | 10 +++++----- bilby/gw/utils.py | 11 ++++++----- test/gw_likelihood_test.py | 10 +++++----- test/gw_utils_test.py | 14 +++++++------- 4 files changed, 23 insertions(+), 22 deletions(-) diff --git a/bilby/gw/likelihood.py b/bilby/gw/likelihood.py index 3c44d5f46..6818be97d 100644 --- a/bilby/gw/likelihood.py +++ b/bilby/gw/likelihood.py @@ -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 diff --git a/bilby/gw/utils.py b/bilby/gw/utils.py index 48573f428..a2fcb2109 100644 --- a/bilby/gw/utils.py +++ b/bilby/gw/utils.py @@ -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) diff --git a/test/gw_likelihood_test.py b/test/gw_likelihood_test.py index 962829bbd..658cd98f6 100644 --- a/test/gw_likelihood_test.py +++ b/test/gw_likelihood_test.py @@ -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"]) ) diff --git a/test/gw_utils_test.py b/test/gw_utils_test.py index f41e7ca93..d2ca327f9 100644 --- a/test/gw_utils_test.py +++ b/test/gw_utils_test.py @@ -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) -- GitLab