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

Getting high-level outputs in Python layer #19

Closed msimet closed 10 years ago

msimet commented 10 years ago

At the moment, it's possible to get the outputs of the correlation function in the Python layer:

xip = gg.xip

as you say in the documentation, and also to write out an array of quantities to a file including, say, the properly compensated estimators. Some of those have extra processing (I'm looking at writeNorm for the NG correlation function, as an example). I'd like to be able to get the outputs from something like the writeNorm function to use in a Python layer without a) having to duplicate your code or b) having to write the file to disk. Is there a way to do that now, or would it be possible to add a way to do that?

(At the moment I'm just doing b), which works fine for our current purposes, but for something where we're computing small correlation functions for many separate data sets--as we might do checking pipeline outputs on small regions--I start to worry about disk I/O.)

rmjarvis commented 10 years ago

You would use ng.calculateNMap, gg.calculateMapSq, and nn.calculateNapSq.

Here are the relevant documentation pages:

http://rmjarvis.github.io/TreeCorr/html/ng.html http://rmjarvis.github.io/TreeCorr/html/gg.html http://rmjarvis.github.io/TreeCorr/html/nn.html

I don't actually have a function that computes the two norms per se, but they are pretty straightforward from the previous outputs. You can look at the code for writeNorm to see what it does:

https://github.com/rmjarvis/TreeCorr/blob/releases/3.1/treecorr/ngcorrelation.py#L347

    nmap, nmx, varnmap = self.calculateNMap(rg=rg, m2_uform=m2_uform)
    mapsq, mapsq_im, mxsq, mxsq_im, varmapsq = gg.calculateMapSq(m2_uform=m2_uform)
    nsq, varnsq = dd.calculateNapSq(rr, dr=dr, m2_uform=m2_uform)

    nmnorm = nmap**2 / (nsq * mapsq)
    varnmnorm = nmnorm**2 * (4. * varnmap / nmap**2 + varnsq / nsq**2 + varmapsq / mapsq**2)
    nnnorm = nsq / mapsq
    varnnnorm = nnnorm**2 * (varnsq / nsq**2 + varmapsq / mapsq**2)
msimet commented 10 years ago

OK, that'll work--thanks.