From 1f4338d15559dd20e6cb30ba699fc9fb454ef68d Mon Sep 17 00:00:00 2001 From: Gregory Ashton Date: Thu, 1 Apr 2021 05:29:06 -0700 Subject: [PATCH] Add a zero likelihood option --- bilby_pipe/input.py | 11 +++++++++-- bilby_pipe/parser.py | 7 +++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/bilby_pipe/input.py b/bilby_pipe/input.py index 9541349..27e842e 100644 --- a/bilby_pipe/input.py +++ b/bilby_pipe/input.py @@ -1046,7 +1046,7 @@ class Input(object): self, "likelihood_lookup_table" ) - if self.likelihood_type == "GravitationalWaveTransient": + if self.likelihood_type in ["GravitationalWaveTransient", "zero"]: Likelihood = bilby.gw.likelihood.GravitationalWaveTransient likelihood_kwargs.update(jitter_time=self.jitter_time) @@ -1085,7 +1085,14 @@ class Input(object): f"Initialise likelihood {Likelihood} with kwargs: \n{likelihood_kwargs}" ) - return Likelihood(**likelihood_kwargs) + likelihood = Likelihood(**likelihood_kwargs) + + # If requested, use a zero likelihood: for testing purposes + if self.likelihood_type == "zero": + logger.info("Using a ZeroLikelihood") + likelihood = bilby.core.likelihood.ZeroLikelihood(likelihood) + + return likelihood @property def extra_likelihood_kwargs(self): diff --git a/bilby_pipe/parser.py b/bilby_pipe/parser.py index a672baf..d9bdf71 100644 --- a/bilby_pipe/parser.py +++ b/bilby_pipe/parser.py @@ -613,9 +613,12 @@ def create_parser(top_level=True): default="GravitationalWaveTransient", help=( "The likelihood. Can be one of [GravitationalWaveTransient, " - "ROQGravitationalWaveTransient] or python path to a bilby " + "ROQGravitationalWaveTransient, zero] or python path to a bilby " "likelihood class available in the users installation. " - "Need to specify --roq-folder if ROQ likelihood used" + "The --roq-folder is required if the ROQ likelihood used." + "The --roq-folder is required if the ROQ likelihood used." + "If `zero` is given, a testing ZeroLikelihood is used which always" + "return zero." ), ) likelihood_parser.add( -- GitLab