Skip to content
Snippets Groups Projects

[WIP] Theory covariance matrix plots in validphys2

Merged Emanuele Roberto Nocera requested to merge scalevarcov into master

Created by: RosalynLP

Hello, as discussed in the phone conference just now Cameron and I have added some features to results.py and plots.py in validphys2 to reproduce the plots in "RP+CV notes" in the wiki.

There are a few changes we're planning to make in the near future:

  • Implement calculation of experiment and theory correlation matrices by taking in the corresponding covariance matrices as an input. Currently these are redefined within the correlation matrix action which is inefficient.

  • Remove unnecessary instances of t0 checks. These appear in the definitions of theory covariance matrices in an analogy with the pre-existing experiment covariance matrix action, but we think it shouldn't be necessary. However, we don't understand exactly what this bit of the code is doing.

  • Introduce user-controlled (as in inputted from runcard) limits for the colour bars in the matrix heat plots, and a legend which displays these values. Currently these limits are set values in the code.

  • Add experiment and data set labels to the matrix plots so it's clearer which elements correspond to which data sets

  • In the current output there seems to be a bug relative to some point in the past, where the theory covariance matrix has some very high valued elements:

image image

This means the version in this pull request has output with some discrepancy compared the plots in the wiki. We are working on fixing this currently.

Merge request reports

Merged by avatar (Apr 5, 2025 11:12am UTC)

Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Emanuele Roberto Nocera
  • Created by: Zaharid

    Review: Commented

    Will do more comments eventually.

  • Created by: Zaharid

    The color map you use for the matrix plots is nice as a "sequential" color map. However here we probably want to have a "divergent" one, that is cantered at zero. The one I like is Spectral_r. See

    https://github.com/NNPDF/nnpdf/blob/800ac01bab549bbf808f1fdb05430c3d3cb241a4/validphys2/src/validphys/plots.py#L1120

  • Emanuele Roberto Nocera
  • 1557 @figure
    1558 def plot_thcorrmat_heatmap(theory_corrmat_3pt):
    1559 """Matrix plot of the theory correlation matrix"""
    1560 df = theory_corrmat_3pt
    1561 matrix = df.as_matrix()
    1562 fig, ax = plt.subplots()
    1563 matrixplot = ax.matshow(matrix)
    1564 cbar = fig.colorbar(matrixplot)
    1565 ax.set_title('Theory correlation matrix')
    1566 ax.xaxis.set_ticks_position('bottom')
    1567 plt.xlabel('Data points', labelpad=10)
    1568 ax.set_ylabel('Data points')
    1569 return fig
    1570
    1571 @figure
    1572 def plot_covdiff_heatmap(theory_covmat_3pt, experiments_covmat):
  • Created by: RosalynLP

    Thanks, I've changed the colourmaps and will push the changes once I've seen the output of the runcard! At the moment it runs quite slow which may be in part due to the way we've continually calculated all the covariance/correlation matrices from scratch. It'll be interesting to see what effect there will be when we improve this.

  • Emanuele Roberto Nocera
  • Emanuele Roberto Nocera
  • Emanuele Roberto Nocera
  • Created by: RosalynLP

    If people are interested, the plot above now looks like: image

  • Emanuele Roberto Nocera
  • Created by: Zaharid

    The covariance matrices already come with the names of the experiments and datasets (the experiments_index thing), so it shouldn't be too hard to put that in matplotlib. It will probably be hard to make it look nice, and will involve fiddling with the relative size of the various elements.

  • Created by: Zaharid

    Also, ideally we would like to have even more levels, with the kinematics of each dataset. But let's leave that for later.

  • Emanuele Roberto Nocera
  • Created by: Zaharid

    Could you upload a few example reports to the vp repository?

  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Please register or sign in to reply
    Loading