Cannot reconstruct marginalized parameters with 0 spin
@salvatore-vitale ran into the following error when trying to do a zero-spin run using an aligned-spin waveform (set with chi_1/chi_2=0 in the prior)
07:36 bilby INFO : Reconstructing marginalised parameters.
0%| | 0/664 [00:00<?, ?it/s]Traceback (most recent call last):
File "run_injections_no_roq.py", line 83, in <module>
main(int(sys.argv[1]), sys.argv[2])
File "run_injections_no_roq.py", line 67, in main
conversion_function=bilby.gw.conversion.generate_all_bbh_parameters)
File "/home/sylvia.biscoveanu/.conda/envs/python3_conda/lib/python3.6/site-packages/bilby/core/sampler/__init__.py", line 215, in run_sampler
npool=npool)
File "/home/sylvia.biscoveanu/.conda/envs/python3_conda/lib/python3.6/site-packages/bilby/core/result.py", line 1441, in samples_to_posterior
data_frame = conversion_function(data_frame, likelihood, priors, npool=npool)
File "/home/sylvia.biscoveanu/.conda/envs/python3_conda/lib/python3.6/site-packages/bilby/gw/conversion.py", line 858, in generate_all_bbh_parameters
likelihood=likelihood, priors=priors, npool=npool)
File "/home/sylvia.biscoveanu/.conda/envs/python3_conda/lib/python3.6/site-packages/bilby/gw/conversion.py", line 795, in _generate_all_cbc_parameters
samples=output_sample, likelihood=likelihood, npool=npool)
File "/home/sylvia.biscoveanu/.conda/envs/python3_conda/lib/python3.6/site-packages/bilby/gw/conversion.py", line 1229, in generate_posterior_samples_from_marginalized_likelihood
new_samples = np.array([fill_sample(xx) for xx in tqdm(fill_args, file=sys.stdout)])
File "/home/sylvia.biscoveanu/.conda/envs/python3_conda/lib/python3.6/site-packages/bilby/gw/conversion.py", line 1229, in <listcomp>
new_samples = np.array([fill_sample(xx) for xx in tqdm(fill_args, file=sys.stdout)])
File "/home/sylvia.biscoveanu/.conda/envs/python3_conda/lib/python3.6/site-packages/bilby/gw/conversion.py", line 1263, in fill_sample
new_sample = likelihood.generate_posterior_sample_from_marginalized_likelihood()
File "/home/sylvia.biscoveanu/.conda/envs/python3_conda/lib/python3.6/site-packages/bilby/gw/likelihood.py", line 458, in generate_posterior_sample_from_marginalized_likelihood
self.parameters))
File "/home/sylvia.biscoveanu/.conda/envs/python3_conda/lib/python3.6/site-packages/bilby/gw/waveform_generator.py", line 129, in frequency_domain_strain
transformed_model_data_points=self.time_array)
File "/home/sylvia.biscoveanu/.conda/envs/python3_conda/lib/python3.6/site-packages/bilby/gw/waveform_generator.py", line 164, in _calculate_strain
self.parameters = parameters
File "/home/sylvia.biscoveanu/.conda/envs/python3_conda/lib/python3.6/site-packages/bilby/gw/waveform_generator.py", line 227, in parameters
new_parameters, _ = self.parameter_conversion(new_parameters)
File "/home/sylvia.biscoveanu/.conda/envs/python3_conda/lib/python3.6/site-packages/bilby/gw/conversion.py", line 251, in convert_to_lal_binary_black_hole_parameters
converted_parameters[key] / converted_parameters[f"a_{idx}"]
ZeroDivisionError: float division by zero
I have tracked this down, and it seems to be due to the fact that this line https://git.ligo.org/lscsoft/bilby/-/blob/master/bilby/gw/conversion.py#L785 appears before the reconstruction of the marginalized parameters, which adds the component spin parameters to the original_keys
getting passed here https://git.ligo.org/lscsoft/bilby/-/blob/master/bilby/gw/conversion.py#L149 so that the spin generation enters this clause https://git.ligo.org/lscsoft/bilby/-/blob/master/bilby/gw/conversion.py#L251 instead of the one above. I am working on a fix.