rmjarvis / TreeCorr

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

Add option to use eval to compute derived values for Catalog arrays. #173

Closed rmjarvis closed 4 months ago

rmjarvis commented 4 months ago

It is relatively common to want to compute some derived quantity from the columns in an input file rather than use them directly. For instance, when computing rho stats, the input catalog might have e_data and e_model, so you would want to compute the difference of these as "q".

Currently the standard practice is to just read the file directly, calculate the arrays you actually want and make a Catalog with the calculated arrays. @theoshutt suggested (#151) that we let TreeCorr do that work by specifying an eval calculation to be run on the columns that are in the file.

This PR implements this as follows for the case of a rho1 calculation:

rho1 = treecorr.GGCorrelation(min_sep=1, max_sep=200, nbins=20, sep_units='arcmin')
qcat = treecorr.Catalog(filename="catalog.fits", 
                        ra_col='RA', dec_col='DEC', ra_units='deg', dec_units='deg',
                        g1_eval='G1_DATA-G1_MODEL', g2_eval='G2_DATA-G2_MODEL',
                        extra_cols=['G1_DATA', 'G1_MODEL', 'G2_DATA', 'G2_MODEL'])
rho1.process(qcat)