Skip to content

Conversation

@acorreia61201
Copy link
Contributor

This PR fixes a bug when running pycbc_inference_plot_posterior with an extracted posterior file and wildcard parameters.

Standard information about the request

This is a bug fix. This change affects posterior plotting via plot_posterior. This change changes the behavior of plot_posterior when using a wildcard parameter argument to call only the parameters present in the file.

Motivation

Currently, if using a wildcard (i.e. --parameters '*'), this script calls the variable_params section of the file, which assumes that the parameters to be plotted are the same as the parameters that were sampled over during PE. However, if the user provides a posterior extracted using pycbc_inference_extract_samples, the parameters stored in the file are not guaranteed to be the same as the variable_params (e.g., a waveform transform may have been applied during extraction). Thus, the script will attempt to call parameter names that may not be in the posterior and throw an error. Ideally, the wildcard should call all the parameters present in the file regardless of what was sampled over during PE.

Contents

This PR changes the behavior of plot_posterior (via the ResultsArgumentParser call) to plot all parameters in the file rather than the variable_params section when using the '*' wildcard. All other functionality remains unchanged; i.e. if the user specifies all of the parameters manually, this PR has no effect.

Additional notes

This largely produces the same expected functionality of the wildcard parameter. There is one additional side effect: if the posterior contains likelihood parameters (e.g. loglikelihood, logwt), those will be plotted as their own scatter plots. Ideally, these wouldn't be plotted, but they have no effect on the plotting otherwise. Additional changes can be made to this PR to exclude these parameters if that is the optimal behavior.

  • [ x ] The author of this pull request confirms they will adhere to the code of conduct

@ahnitz
Copy link
Member

ahnitz commented Sep 22, 2025

@aleynaakyuz Can you please review this?

@acorreia61201 acorreia61201 marked this pull request as ready for review October 1, 2025 00:32
@acorreia61201
Copy link
Contributor Author

acorreia61201 commented Oct 1, 2025

I've added in a few lines to the ResultsArgumentParser that mimics the behavior of defaultparams = 'all', except avoiding parameters that share the names of likelihood stats (e.g. loglikelihood, logwt). This avoids plotting the likelihood stats when using a wildcard unless specified by the user (so, e.g. if someone specifies --parameters loglikelihood '*', it will plot the loglikelihood and not logwt in the scatter/corner plots).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants