Commit ee3e9aa3 authored by Gregory Ashton's avatar Gregory Ashton

Resolve "Generate additional tidal parameters"

parent dad1db7e
......@@ -278,17 +278,17 @@ def convert_to_lal_binary_neutron_star_parameters(parameters):
convert_to_lal_binary_black_hole_parameters(converted_parameters)
if not any([key in converted_parameters for key in
['lambda_1', 'lambda_2', 'lambda_tilde', 'delta_lambda']]):
['lambda_1', 'lambda_2', 'lambda_tilde', 'delta_lambda_tilde']]):
converted_parameters['lambda_1'] = 0
converted_parameters['lambda_2'] = 0
added_keys = added_keys + ['lambda_1', 'lambda_2']
return converted_parameters, added_keys
if 'delta_lambda' in converted_parameters.keys():
if 'delta_lambda_tilde' in converted_parameters.keys():
converted_parameters['lambda_1'], converted_parameters['lambda_2'] =\
lambda_tilde_delta_lambda_to_lambda_1_lambda_2(
lambda_tilde_delta_lambda_tilde_to_lambda_1_lambda_2(
converted_parameters['lambda_tilde'],
parameters['delta_lambda'], converted_parameters['mass_1'],
parameters['delta_lambda_tilde'], converted_parameters['mass_1'],
converted_parameters['mass_2'])
elif 'lambda_tilde' in converted_parameters.keys():
converted_parameters['lambda_1'], converted_parameters['lambda_2'] =\
......@@ -535,7 +535,7 @@ def lambda_1_lambda_2_to_lambda_tilde(lambda_1, lambda_2, mass_1, mass_2):
return lambda_tilde
def lambda_1_lambda_2_to_delta_lambda(lambda_1, lambda_2, mass_1, mass_2):
def lambda_1_lambda_2_to_delta_lambda_tilde(lambda_1, lambda_2, mass_1, mass_2):
"""
Convert from individual tidal parameters to second domainant tidal term.
......@@ -554,22 +554,22 @@ def lambda_1_lambda_2_to_delta_lambda(lambda_1, lambda_2, mass_1, mass_2):
Return
------
delta_lambda: float
delta_lambda_tilde: float
Second dominant tidal term.
"""
eta = component_masses_to_symmetric_mass_ratio(mass_1, mass_2)
lambda_plus = lambda_1 + lambda_2
lambda_minus = lambda_1 - lambda_2
delta_lambda = 1 / 2 * (
delta_lambda_tilde = 1 / 2 * (
(1 - 4 * eta) ** 0.5 * (1 - 13272 / 1319 * eta + 8944 / 1319 * eta**2) *
lambda_plus + (1 - 15910 / 1319 * eta + 32850 / 1319 * eta**2 +
3380 / 1319 * eta**3) * lambda_minus)
return delta_lambda
return delta_lambda_tilde
def lambda_tilde_delta_lambda_to_lambda_1_lambda_2(
lambda_tilde, delta_lambda, mass_1, mass_2):
def lambda_tilde_delta_lambda_tilde_to_lambda_1_lambda_2(
lambda_tilde, delta_lambda_tilde, mass_1, mass_2):
"""
Convert from dominant tidal terms to individual tidal parameters.
......@@ -579,7 +579,7 @@ def lambda_tilde_delta_lambda_to_lambda_1_lambda_2(
----------
lambda_tilde: float
Dominant tidal term.
delta_lambda: float
delta_lambda_tilde: float
Secondary tidal term.
mass_1: float
Mass of more massive neutron star.
......@@ -602,12 +602,12 @@ def lambda_tilde_delta_lambda_to_lambda_1_lambda_2(
3380 / 1319 * eta**3)
lambda_1 =\
(13 * lambda_tilde / 8 * (coefficient_3 - coefficient_4) -
2 * delta_lambda * (coefficient_1 - coefficient_2))\
2 * delta_lambda_tilde * (coefficient_1 - coefficient_2))\
/ ((coefficient_1 + coefficient_2) * (coefficient_3 - coefficient_4) -
(coefficient_1 - coefficient_2) * (coefficient_3 + coefficient_4))
lambda_2 =\
(13 * lambda_tilde / 8 * (coefficient_3 + coefficient_4) -
2 * delta_lambda * (coefficient_1 + coefficient_2)) \
2 * delta_lambda_tilde * (coefficient_1 + coefficient_2)) \
/ ((coefficient_1 - coefficient_2) * (coefficient_3 + coefficient_4) -
(coefficient_1 + coefficient_2) * (coefficient_3 - coefficient_4))
return lambda_1, lambda_2
......@@ -884,7 +884,7 @@ def generate_tidal_parameters(sample):
"""
Generate all tidal parameters
lambda_tilde, delta_lambda
lambda_tilde, delta_lambda_tilde
Parameters
----------
......@@ -902,8 +902,8 @@ def generate_tidal_parameters(sample):
lambda_1_lambda_2_to_lambda_tilde(
output_sample['lambda_1'], output_sample['lambda_2'],
output_sample['mass_1'], output_sample['mass_2'])
output_sample['delta_lambda'] = \
lambda_1_lambda_2_to_delta_lambda(
output_sample['delta_lambda_tilde'] = \
lambda_1_lambda_2_to_delta_lambda_tilde(
output_sample['lambda_1'], output_sample['lambda_2'],
output_sample['mass_1'], output_sample['mass_2'])
......
......@@ -403,7 +403,7 @@ class BNSPriorDict(PriorDict):
self[key], (DeltaFunction, Constraint))}
tidal_parameters = \
{'lambda_1', 'lambda_2', 'lambda_tilde', 'delta_lambda'}
{'lambda_1', 'lambda_2', 'lambda_tilde', 'delta_lambda_tilde'}
if key in tidal_parameters:
if len(tidal_parameters.intersection(sampling_parameters)) > 2:
......@@ -446,7 +446,7 @@ Prior._default_latex_labels = {
'lambda_1': '$\\Lambda_1$',
'lambda_2': '$\\Lambda_2$',
'lambda_tilde': '$\\tilde{\\Lambda}$',
'delta_lambda': '$\\delta\\Lambda$'}
'delta_lambda_tilde': '$\\delta\\tilde{\\Lambda}$'}
class CalibrationPriorDict(PriorDict):
......
......@@ -21,4 +21,4 @@ phase = Uniform(name='phase', minimum=0, maximum=2 * np.pi, boundary='periodic')
lambda_1 = Uniform(name='lambda_1', minimum=0, maximum=3000, boundary=None)
lambda_2 = Uniform(name='lambda_2', minimum=0, maximum=3000, boundary=None)
# lambda_tilde = Uniform(name='lambda_tilde', minimum=0, maximum=5000, boundary=None)
# delta_lambda = Uniform(name='delta_lambda', minimum=-5000, maximum=5000, boundary=None)
# delta_lambda_tilde = Uniform(name='delta_lambda_tilde', minimum=-5000, maximum=5000, boundary=None)
......@@ -27,4 +27,4 @@ phase = Uniform(name='phase', minimum=0, maximum=2 * np.pi, boundary='periodic')
lambda_1 = Uniform(name='lambda_1', minimum=0, maximum=3000, boundary=None)
lambda_2 = Uniform(name='lambda_2', minimum=0, maximum=3000, boundary=None)
# lambda_tilde = Uniform(name='lambda_tilde', minimum=0, maximum=5000, boundary=None)
# delta_lambda = Uniform(name='delta_lambda', minimum=-5000, maximum=5000, boundary=None)
# delta_lambda_tilde = Uniform(name='delta_lambda_tilde', minimum=-5000, maximum=5000, boundary=None)
......@@ -30,7 +30,7 @@ class TestBasicConversions(unittest.TestCase):
- 11 * self.symmetric_mass_ratio**2)
* (self.lambda_1 - self.lambda_2)
)
self.delta_lambda = 1 / 2 * (
self.delta_lambda_tilde = 1 / 2 * (
(1 - 4 * self.symmetric_mass_ratio)**0.5
* (1 - 13272 / 1319 * self.symmetric_mass_ratio
+ 8944 / 1319 * self.symmetric_mass_ratio**2)
......@@ -93,10 +93,10 @@ class TestBasicConversions(unittest.TestCase):
self.assertTrue(all([abs(self.lambda_1 - lambda_1) < 1e-5,
abs(self.lambda_2 - lambda_2) < 1e-5]))
def test_lambda_tilde_delta_lambda_to_lambda_1_lambda_2(self):
def test_lambda_tilde_delta_lambda_tilde_to_lambda_1_lambda_2(self):
lambda_1, lambda_2 =\
conversion.lambda_tilde_delta_lambda_to_lambda_1_lambda_2(
self.lambda_tilde, self.delta_lambda, self.mass_1, self.mass_2)
conversion.lambda_tilde_delta_lambda_tilde_to_lambda_1_lambda_2(
self.lambda_tilde, self.delta_lambda_tilde, self.mass_1, self.mass_2)
self.assertTrue(all([abs(self.lambda_1 - lambda_1) < 1e-5,
abs(self.lambda_2 - lambda_2) < 1e-5]))
......@@ -106,11 +106,11 @@ class TestBasicConversions(unittest.TestCase):
self.lambda_1, self.lambda_2, self.mass_1, self.mass_2)
self.assertTrue((self.lambda_tilde - lambda_tilde) < 1e-5)
def test_lambda_1_lambda_2_to_delta_lambda(self):
delta_lambda = \
conversion.lambda_1_lambda_2_to_delta_lambda(
def test_lambda_1_lambda_2_to_delta_lambda_tilde(self):
delta_lambda_tilde = \
conversion.lambda_1_lambda_2_to_delta_lambda_tilde(
self.lambda_1, self.lambda_2, self.mass_1, self.mass_2)
self.assertTrue((self.delta_lambda - delta_lambda) < 1e-5)
self.assertTrue((self.delta_lambda_tilde - delta_lambda_tilde) < 1e-5)
class TestConvertToLALParams(unittest.TestCase):
......@@ -134,8 +134,8 @@ class TestConvertToLALParams(unittest.TestCase):
self.tidal_parameters = self.component_tidal_parameters.copy()
self.tidal_parameters['lambda_tilde'] = \
conversion.lambda_1_lambda_2_to_lambda_tilde(**self.all_component_pars)
self.tidal_parameters['delta_lambda'] = \
conversion.lambda_1_lambda_2_to_delta_lambda(**self.all_component_pars)
self.tidal_parameters['delta_lambda_tilde'] = \
conversion.lambda_1_lambda_2_to_delta_lambda_tilde(**self.all_component_pars)
def tearDown(self):
del self.search_keys
......@@ -241,8 +241,8 @@ class TestConvertToLALParams(unittest.TestCase):
key: self.parameters[key] for key in ['lambda_1', 'lambda_2']}
self.assertDictEqual(component_dict, self.component_tidal_parameters)
def test_lambda_tilde_delta_lambda(self):
self._conversion_to_component_tidal(['lambda_tilde', 'delta_lambda'])
def test_lambda_tilde_delta_lambda_tilde(self):
self._conversion_to_component_tidal(['lambda_tilde', 'delta_lambda_tilde'])
def test_lambda_tilde(self):
self._conversion_to_component_tidal(['lambda_tilde'])
......
......@@ -180,7 +180,7 @@ class TestBNSPriorDict(unittest.TestCase):
def test_redundant_priors_not_in_dict_before(self):
for prior in ['chirp_mass', 'total_mass', 'mass_ratio',
'symmetric_mass_ratio', 'cos_theta_jn', 'comoving_distance',
'redshift', 'lambda_tilde', 'delta_lambda']:
'redshift', 'lambda_tilde', 'delta_lambda_tilde']:
self.assertTrue(self.bns_prior_dict.test_redundancy(prior))
def test_redundant_priors_already_in_dict(self):
......@@ -211,7 +211,7 @@ class TestBNSPriorDict(unittest.TestCase):
def test_correct_not_redundant_priors_tidal(self):
del self.bns_prior_dict['lambda_1']
for prior in['lambda_1', 'lambda_tilde', 'delta_lambda']:
for prior in['lambda_1', 'lambda_tilde', 'delta_lambda_tilde']:
self.assertFalse(self.bns_prior_dict.test_redundancy(prior))
def test_add_unrelated_prior(self):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment