Bug in spin transformation functions between LALInference and LALSimulation
There is a bug in the spin transformation functions between the LALInference and LALSimulation conventions described here: https://lscsoft.docs.ligo.org/lalsuite/lalsimulation/group__lalsimulation__inference.html.
If I input q=1, chi1_vec = [-0.50, 0.00, 0.00], chi2_vec = [0.50, 0.00, 0.00] and pass it through the transformation and back, I get: chi1_vec = [-0.00, 0.50, 0.00], chi2_vec = [0.00, -0.50, 0.00].
I think this is happening because for this configuration the direction of J and L are the same as the two spins cancel each other. For this case, phiJL becomes undefined as it the azimuthal angle of J w.r.t L, and it looks like the code just sets phiJL to 0.
My script to reproduce this is here: https://git.ligo.org/waveforms/reviews/RemnantFits/blob/master/test_LALInf_spin_anlges/test_angle_convention.py
While this is a very special case that should not occur in PE samples, these configurations might be used in injections. More worryingly, initial tests by @nathan-johnson-mcdaniel suggest that the functions are also unstable for small perturbations about this special point. This is documented here: https://git.ligo.org/waveforms/reviews/RemnantFits/issues/15
@riccardo-sturani, you seem to have written this code. Have you seen this before and/or do you know of a possible fix?
@harald.pfeiffer, any thoughts?