Skip to content

parameter_conversion as part of bilby_pipe_write_default_ini

  • If we define, a new function parameter_conversion=bilby.gw.conversion.convert_to_lal_siqm_parameters currently can not be passed through the bilby_pipe_write_default_ini.
def convert_to_lal_siqm_parameters(parameters):
    """
    Convert parameters we have into parameters we need.

    This is defined by the parameters of bilby.source.lal_binary_black_hole()


    Mass: mass_1, mass_2
    Spin: a_1, a_2, tilt_1, tilt_2, phi_12, phi_jl
    Extrinsic: luminosity_distance, theta_jn, phase, ra, dec, geocent_time, psi

    This involves popping a lot of things from parameters.
    The keys in added_keys should be popped after evaluating the waveform.

    Parameters
    ----------
    parameters: dict
        dictionary of parameter values to convert into the required parameters

    Return
    ------
    converted_parameters: dict
        dict of the required parameters
    added_keys: list
        keys which are added to parameters during function call
    """
    converted_parameters = parameters.copy()
    original_keys = list(converted_parameters.keys())
    converted_parameters, added_keys =\
        convert_to_lal_binary_black_hole_parameters(converted_parameters)

    if not any([key in converted_parameters for key in
                ['dQuadMon1', 'dQuadMon2', 'dQuadMonS', 'dQuadMonA']]):
        converted_parameters['dQuadMon1'] = 0
        converted_parameters['dQuadMon2'] = 0
        added_keys = added_keys + ['dQuadMon1', 'dQuadMon2']
        return converted_parameters, added_keys
        
        
    if 'dQuadMonS' in converted_parameters.keys():
        converted_parameters['dQuadMon1'], converted_parameters['dQuadMon2'] =\
            dquadmons_and_dquadmona_to_dquadmon1_and_dquadmon2(
                converted_parameters['dQuadMonS'],
                parameters['dQuadMonA'])
    elif 'dQuadMonA' in converted_parameters.keys():
        converted_parameters['dQuadMon1'], converted_parameters['dQuadMon2'] =\
            dquadmons_and_dquadmona_to_dquadmon1_and_dquadmon2(
                converted_parameters['dQuadMonS'],
                parameters['dQuadMonA'])

    return converted_parameters, added_keys

  • But the usual bilby examples can be done using the following changes through the sampler arguments:
bilby.run_sampler(
    likelihood=likelihood, priors=priors, sampler='dynesty', npoints=1000,
    parameter_conversion=bilby.gw.conversion.convert_to_lal_siqm_parameters,
    injection_parameters=injection_parameters, outdir=outdir, label=label)
Edited by NV Krishnendu