rmjarvis / TreeCorr

Code for efficiently computing 2-point and 3-point correlation functions. For documentation, go to
http://rmjarvis.github.io/TreeCorr/
Other
98 stars 37 forks source link

Add feature to write patch results to output file. #141

Closed rmjarvis closed 2 years ago

rmjarvis commented 2 years ago

Currently, when you write a Correlation object to a file, it only includes the main data -- whatever columns are appropriate to the kind of correlation being performed. But in particular, it does not include the extra information that is required to compute patch-based covariance matrix estimates. This means that if you write a correlation object to a file and then read it back in, it loses the ability to compute the various patch-based covariances.

This PR adds that as an optional feature. If you use corr.write(..., write_patch_results=True), then the output file will include all of the patch-based results as extra HDUs or groups (depending on the file type) in the output file. If you then read the object back in using the normal read method, then it will reconstruct the full results dict, allowing all the patch-based methods to work correctly.

Aside: The code for this involved a lot of refactoring of the I/O routines, and while working on it, I noticed a bug that correlation objects using bin_type=TwoD didn't round-trip correctly through a file. The information was all there in the file, but the read function didn't read it in correctly. This has been fixed.