jesterTOV.inference.flows.bilby_extract.extract_gw_posterior_from_bilby

jesterTOV.inference.flows.bilby_extract.extract_gw_posterior_from_bilby#

extract_gw_posterior_from_bilby(bilby_result_file, output_file=None)[source]#

Extract GW posterior samples from a bilby result HDF5 file.

Reads mass_1_source, mass_2_source, lambda_1, and lambda_2 from a bilby result file and saves them as a .npz file suitable for use with FlowTrainingConfig.

All four parameters must be present in the bilby result file. Bilby writes them directly for BNS analyses, so no parameter conversion is performed here.

Parameters:
  • bilby_result_file (str) – Path to bilby result .hdf5 file.

  • output_file (str | None) – Output .npz path. Defaults to the same directory as the input with a _gw_jester_posterior.npz suffix appended to the stem.

Return type:

str

Returns:

str – Path to the saved .npz file.

Raises:
  • KeyError – If a required parameter is absent from the bilby result file.

  • ValueError – If the HDF5 file does not contain a posterior group.