CCL icon indicating copy to clipboard operation
CCL copied to clipboard

Pyccl.halos.profile

Open Jane550 opened this issue 2 years ago • 6 comments

Hi all! I want to compute the excess surface density of an NFW halo analytically using pyccl.halos.profile package. I now use 'HaloProfileNFW.cumul2d()-HaloProfileNFW.projected()'. Is it the right way to do it or is there any other simpler way? Also I want to check whether 'cumul2d' and 'projected' return the comoving or physical surface density.

Jane550 avatar Sep 22 '23 03:09 Jane550

I believe using cumul2d - projected is the only way to obtain the excess surface density profile. The functions return comoving density.

hsinfan1996 avatar Sep 22 '23 23:09 hsinfan1996

Sure, Many thanks!

Jane550 avatar Sep 24 '23 05:09 Jane550

Hi! I want to return an array 'ESD=cumul2d-projected' of size n for input of arrays 'M','z','R' all of the size n. i.e. for each combination of 'M,z,R', I got an ESD. Now the code seems to return an array of shape (N_M,N_R) where N_M, N_R are the length of the input arrays 'M','R'. But in my case, Each M corresponds to an array of R with different shapes and values so I don't think the current code is suitable. Is there anywhere in the code that I can modify to simply return an array the same size as the input 'M','z', and 'R'? If not, can you please give me the analytical form of ESD of an untruncated NFW profile? I may try writing a code myself.

Jane550 avatar Nov 27 '23 04:11 Jane550

Hi @Jane550 . Yes, the way the current code is structured is optimized for halo model power spectrum/correlation function calculations, which calculate all the possible combinations between M and r. For your case, would calling cumul2d inside a loop that runs over the different values of M, R, and z work? Or would that be too slow? My first guess is that the time wasted in looping would be small compared to evaluating the expressions that go into cumul2d, so perhaps it's not the worst solution...

damonge avatar Nov 27 '23 09:11 damonge

No, the loop is too slow. I'm calculating the ESD as model predictions in a Bayesian parameter inference, so I need to calculate these many many times. And each time calling the likelihood (calculating the ESD), the length of $M,R,z$ is of order $10^7$.

Jane550 avatar Nov 27 '23 10:11 Jane550

OK, I see. I think the easiest option for now would be for you to hack/reimplement this function: https://github.com/LSSTDESC/CCL/blob/6b08a255f2878ffd6ebe045d3d95b103fddef77f/pyccl/halos/profiles/nfw.py#L161 which implements the ESD of an NFW profile. Would that work?

Once you have that, we may be able to put it back into CCL (although it'd be great to think of a way to do it that is completely generalisable to the other profiles - including those in which the calculation needs to go through FFTLog).

damonge avatar Nov 27 '23 11:11 damonge