bccp / nbodykit

Analysis kit for large-scale structure datasets, the massively parallel way
http://nbodykit.rtfd.io
GNU General Public License v3.0
111 stars 60 forks source link

How to get log spaced bins? #658

Open danpryer opened 3 years ago

danpryer commented 3 years ago

Hi, Just doing an FKP based measurement on a data/randoms catalogue and wondering if there was a way to get log-spaced k bins for the P(k) measurement instead of linear, using the ConvolvedFFTPower class? Had a look at the source code but couldn't seem to see an option for this. Any help appreciated. Cheers, Dan

rainwoodman commented 3 years ago

Indeed I don't see how to use log bins neither.

The result is a BinnedStatistic object, which appears to allow non-uniform edges.

Unfortunately the reindex method assumes uniform edges/bins.

I think the algorithm can be extended to deal with non-uniform edges/bins (with cumsum + interp1d + diff) Do you want to take a stab at this? If not I can look at it in a week or two.

danpryer commented 3 years ago

Thanks for the reply, and no worries if it's going to be complicated, the linear bins are ok for what i'm currently using it for... I would take a stab at it myself but currently pretty busy with thesis writing to be trying to hack the source code of this library, never tried messing with something quite so elaborate 🙃 . For my 'homebrew' estimator code I just specify the kmin/max and the number of bins rather than specifying dk, then the edges/mids are simply k_edges = np.logspace(np.log10(kmin), np.log10(kmax), nkbin+1) k_mid = np.exp(0.5*(np.log(kbins[1:]) + np.log(kbins[:-1])))

As you say though.. this would break the reindex function. I guess specifying dk is a better method for when you have linear bins.

I think long term though it would be useful to have log bins, particularly for measuring the very large scales, which upcoming LSS redshift surveys will start to approach with more accuracy.