Closed stephengreen closed 4 weeks ago
Yes, this PR fixes running injections with fixed parameters.
I tested the PR on the tutorial example and the following code worked to generate an injection with fixed posterior parameters except for chirp mass and mass ratio:
# Load the network
pm = PosteriorModel(model_path, device="cpu")
sampler = GWSampler(model=pm)
# Generate an injection consistent with the data the model was trained on.
injection = Injection.from_posterior_model_metadata(pm.metadata)
injection.asd = ASDDataset(asd_path, ifos=["H1", "L1"])
theta = injection.prior.sample()
inj = injection.injection(theta)
# Generate 10,000 samples from the normalizing flow.
sampler.context = inj
sampler.run_sampler(10000)
result = sampler.to_result()
# Run importance-sampling on the result.
num_processes = 8
result.importance_sample(num_processes=num_processes)
# Make a corner plot and save the result.
result.print_summary()
However, running dingo_pipe
on a model with Delta priors does not work (the weights are nan?). I will do some more investigation to track down the bug.
Try it now. I'm excluding the fixed parameters when evaluating the prior.
I tested the new commit on dingo_pipe of the tutorial example with chirp mass and mass ratio:
Example plot:
This should be sufficient for the tutorial. You can merge the branch.
This adds the parameters that have delta-function priors when sampling. It is needed so that the sky rotation transform and importance sampling works when holding some parameters fixed.
Corner plotting is also updated with a new flag for whether to include these fixed parameters. Default is to not include them.
This still needs to be tested.