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

make BBHPriorSet update test_redundancy

parent 9db4c495
No related branches found
No related tags found
1 merge request!59Updating priors
......@@ -17,54 +17,50 @@ class BBHPriorSet(PriorSet):
if dictionary is None and filename is None:
filename = os.path.join(os.path.dirname(__file__), 'prior_files', 'binary_black_holes.prior')
logging.info('No prior given, using default BBH priors in {}.'.format(filename))
PriorSet.__init__(dictionary=dictionary, filename=filename)
self.test_redundancy = test_cbc_redundancy
PriorSet.__init__(self, dictionary=dictionary, filename=filename)
def test_redundancy(self, key):
"""
Test whether adding the key would add be redundant.
def test_cbc_redundancy(key, prior):
"""
Test whether adding the key would add be redundant.
Parameters
----------
key: str
The string to test.
Parameters
----------
key: str
The string to test.
prior: dict
Current prior dictionary.
Return
------
redundant: bool
Whether the key is redundant
"""
redundant = False
mass_parameters = {'mass_1', 'mass_2', 'chirp_mass', 'total_mass', 'mass_ratio', 'symmetric_mass_ratio'}
spin_magnitude_parameters = {'a_1', 'a_2'}
spin_tilt_1_parameters = {'tilt_1', 'cos_tilt_1'}
spin_tilt_2_parameters = {'tilt_2', 'cos_tilt_2'}
spin_azimuth_parameters = {'phi_1', 'phi_2', 'phi_12', 'phi_jl'}
inclination_parameters = {'iota', 'cos_iota'}
distance_parameters = {'luminosity_distance', 'comoving_distance', 'redshift'}
Return
------
redundant: bool
Whether the key is redundant
"""
redundant = False
mass_parameters = {'mass_1', 'mass_2', 'chirp_mass', 'total_mass', 'mass_ratio', 'symmetric_mass_ratio'}
spin_magnitude_parameters = {'a_1', 'a_2'}
spin_tilt_1_parameters = {'tilt_1', 'cos_tilt_1'}
spin_tilt_2_parameters = {'tilt_2', 'cos_tilt_2'}
spin_azimuth_parameters = {'phi_1', 'phi_2', 'phi_12', 'phi_jl'}
inclination_parameters = {'iota', 'cos_iota'}
distance_parameters = {'luminosity_distance', 'comoving_distance', 'redshift'}
for parameter_set in [mass_parameters, spin_magnitude_parameters, spin_azimuth_parameters]:
if key in parameter_set:
if len(parameter_set.intersection(prior.keys())) > 2:
redundant = True
logging.warning('{} in prior. This may lead to unexpected behaviour.'.format(
parameter_set.intersection(prior.keys())))
break
elif len(parameter_set.intersection(prior.keys())) == 2:
redundant = True
break
for parameter_set in [inclination_parameters, distance_parameters, spin_tilt_1_parameters, spin_tilt_2_parameters]:
if key in parameter_set:
if len(parameter_set.intersection(prior.keys())) > 1:
redundant = True
logging.warning('{} in prior. This may lead to unexpected behaviour.'.format(
parameter_set.intersection(prior.keys())))
break
elif len(parameter_set.intersection(prior.keys())) == 1:
for parameter_set in [mass_parameters, spin_magnitude_parameters, spin_azimuth_parameters]:
if key in parameter_set:
if len(parameter_set.intersection(self.__dict__)) > 2:
redundant = True
logging.warning('{} in prior. This may lead to unexpected behaviour.'.format(
parameter_set.intersection(self.__dict__)))
break
elif len(parameter_set.intersection(self.__dict__)) == 2:
redundant = True
break
for parameter_set in [inclination_parameters, distance_parameters, spin_tilt_1_parameters, spin_tilt_2_parameters]:
if key in parameter_set:
if len(parameter_set.intersection(self.__dict__)) > 1:
redundant = True
logging.warning('{} in prior. This may lead to unexpected behaviour.'.format(
parameter_set.intersection(self.__dict__)))
break
elif len(parameter_set.intersection(self.__dict__)) == 1:
redundant = True
break
return redundant
return redundant
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