Speeding up deriving the posteriors
I have found that the reason why it takes a long time to 'extract the information from %s' is because there is a bottle neck in the pesummary.gw.file.one_format.generate_all_posterior_samples
function. If I run this function with a lalinference results file and time how long it takes to derive each posterior I find the following:
mchirp_from_mchirp_source_z: 1.9073486328125e-06
q_from_eta: 1.9073486328125e-06
q_from_m1_m2: 1.1920928955078125e-06
invert_q: 0.00567317008972168
mchirp_from_mtotal_q: 6.67572021484375e-06
m1_from_mchirp_q: 0.024062156677246094
m2_from_mchirp_qz: 0.030719995498657227
mtotal_from_m1_m2: 0.02073502540588379
mtotal_from_m1_m2: 1.2636184692382812e-05
eta_from_m1_m2: 0.022076129913330078
spin_angles: 1.1920928955078125e-05
component_spins: 0.2714090347290039
chi_p and chi_eff: 0.07051324844360352
dL_from_z: 5.9604644775390625e-06
z_from_dL: 223.57816982269287
comoving_distance_from_z: 0.9140491485595703
m1_source_from_m1_z: 0.05551481246948242
m2_source_from_m2_z; 0.048599958419799805
mtotal_source_from_mtotal_z: 0.054395198822021484
It seems like the main bottle neck is the function pesummary.gw.file.conversions.z_from_dL
. The Astropy docs suggest that instead of calculating z for every distance sample, you should instead generate an array of values at many closely-spaced redshifts that cover the relevant redshift range, and then use interpolation to find the redshift at each value you’re interested in.
Edited by Charlie Hoy