Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions bin/inference/pycbc_inference_plot_posterior
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down
18 changes: 13 additions & 5 deletions pycbc/inference/io/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 :
Expand All @@ -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']
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You’re only skipping two parameters here, but there are other ones that could also be plotted. I plotted result_extracted.hdf here and the result looks like this

self.defaultparams = defaultparams
# add the results option grup
self.add_results_option_group(autoparamlabels=autoparamlabels)
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
Loading