diff --git a/bin/inference/pycbc_inference_plot_posterior b/bin/inference/pycbc_inference_plot_posterior index c691665c49a..6154ebe1f05 100644 --- a/bin/inference/pycbc_inference_plot_posterior +++ b/bin/inference/pycbc_inference_plot_posterior @@ -48,7 +48,7 @@ from pycbc.results.scatter_histograms import create_multidim_plot use('agg') # add options to command line -parser = io.ResultsArgumentParser() +parser = io.ResultsArgumentParser(defaultparams='samples') pycbc.add_common_pycbc_options(parser) # program-specific parser.add_argument("--output-file", type=str, required=True, @@ -60,13 +60,18 @@ parser.add_argument("--prior-nsamples", type=int, default=10000, help="The number of samples to use for plotting the " "prior. Default is 10000.") parser.add_argument("--colors-multi-run", nargs="+", type=str, - help="For multiple runs, provide colours to be used for successively. Default setting is to use the successive colours specified in matplotlib color cycle.") + help="For multiple runs, provide colours to be used for " + "successively. Default setting is to use the " + "successive colours specified in matplotlib color " + "cycle.") parser.add_argument("--fill-hist", action="store_true", default=False, help="Fill the 1D marginalized histograms") parser.add_argument("--hist-color", - help="Provide color for histogram outline. Default is black") + help="Provide color for histogram outline. Default is " + "black") parser.add_argument("--hist-fill-color", default='gray', - help="Provide the fill_color for filled histograms. Default is gray") + help="Provide the fill_color for filled histograms. " + "Default is gray") # add options for what plots to create option_utils.add_plot_posterior_option_group(parser) # scatter configuration diff --git a/pycbc/inference/io/__init__.py b/pycbc/inference/io/__init__.py index 23df1697631..10ee21dbf94 100644 --- a/pycbc/inference/io/__init__.py +++ b/pycbc/inference/io/__init__.py @@ -446,11 +446,13 @@ class ResultsArgumentParser(argparse.ArgumentParser): to not be included. May also specify sampler-specific arguments. Note that ``input-file``, ``file-help``, and ``parameters`` are always added. - defaultparams : {'variable_params', 'all'}, optional + defaultparams : {'variable_params', 'samples', 'all'}, optional If no ``--parameters`` provided, which collection of parameters to - load. If 'all' will load all parameters in the file's - ``samples_group``. If 'variable_params' or None (the default) will load - the variable parameters. + load. If 'samples' will load all parameters in the file's + ``samples_group``, excluding likelihood stats (i.e. loglikelihood, + logwt). If 'all' will load all parameters in the file's + ``samples_group`` including likelihood stats. If 'variable_params' or + None (the default) will load the variable parameters. autoparamlabels : bool, optional Passed to ``add_results_option_group``; see that function for details. \**kwargs : @@ -462,11 +464,15 @@ def __init__(self, skip_args=None, defaultparams=None, # add attribute to communicate to arguments what to do when there is # no input files self.no_input_file_err = False + self.skip_params = [] if skip_args is None: skip_args = [] self.skip_args = skip_args if defaultparams is None: defaultparams = 'variable_params' + if defaultparams == 'samples': + defaultparams = 'all' + self.skip_params = ['loglikelihood', 'logwt'] self.defaultparams = defaultparams # add the results option grup self.add_results_option_group(autoparamlabels=autoparamlabels) @@ -510,6 +516,7 @@ def parse_known_args(self, args=None, namespace=None): if opts.parameters is None or opts.parameters == ['*']: parameters = get_common_parameters(opts.input_file, collection=self.defaultparams) + parameters = [i for i in parameters if i not in self.skip_params] # now call parse parameters action to re-populate the namespace self.actions['parameters'](self, opts, parameters) # check if we're being greedy or not @@ -526,7 +533,8 @@ def parse_known_args(self, args=None, namespace=None): add_params = set(all_params) - set(used_params) # repopulate the name space with the additional parameters if add_params: - opts.parameters += list(add_params) + add_params = [i for i in add_params if i not in self.skip_params] + opts.parameters += add_params # update the labels opts.parameters_labels.update({p: p for p in add_params}) # parse the sampler-specific options and check for any unknowns