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

units of nbodykit.transform.SkyToCartesian #607

Open SandyYuan opened 4 years ago

SandyYuan commented 4 years ago

The documentation says that the returned coordinates are in Mpc / h, but the results look like they are in Mpc instead.

rainwoodman commented 4 years ago

Did you check if the cosmology object has h=1. If so then Mpc/h and Mpc are the same.

SandyYuan commented 4 years ago

Yeah I passed it custom cosmology with H0 = 67.26. I assume internally the code converts that to an h = 0.6726.

rainwoodman commented 4 years ago

Indeed there is a conversion.

This is strange. Could be a serious bug or a regression -- although unlikely. Last time we checked this was definitely Mpc/h.

We shall figure it out and add a test case, to make sure it never goes bad again.

Could you post a code snippet & what you expect & what you get?

Thanks!

On Sun, Dec 1, 2019 at 9:52 PM Sihan (Sandy) Yuan notifications@github.com wrote:

Yeah I passed it custom cosmology with H0 = 67.26. I assume internally the code converts that to an h = 0.6726.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/bccp/nbodykit/issues/607?email_source=notifications&email_token=AABBWTEZ2PWYYND3LOPPFF3QWSPAHA5CNFSM4JTIMN3KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEFSKEQQ#issuecomment-560243266, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABBWTALLMMWEE2CIPH5BL3QWSPAHANCNFSM4JTIMN3A .

SandyYuan commented 4 years ago

code:

from nbodykit.transform import SkyToCartesian

from astropy.cosmology import FlatLambdaCDM
cosmo = FlatLambdaCDM(H0= 67.26 , Om0=0.316)

SkyToCartesian([0], [0], [1], cosmo, 
        observer=[0, 0, 0], degrees=True, frame='icrs').compute()

It gives

array([[ 3406.04607083, 0. , 0. ]])

That is the comoving distance in Mpc. To check that, we can simply do

cosmo.comoving_distance(1)

which gives

<Quantity 3406.046070834424 Mpc>

nickhand commented 4 years ago

You'll get back the coordinates in whatever units the input cosmo.comoving_distance() returns. In the case of nbodykit's Cosmology object, the comoving_distance() returns distances in units of Mpc/h since it's built on CLASS. The function

The function was intended to be used with nbodykit's cosmology object, but we should update the documentation to better reflect what is actually happening.

NiallJeffrey commented 4 years ago

I have also found this problem. It seems that CartesianToSky is taking only scalar values (ignoring units) and assuming the units are Mpc - not Mpc/h as the documentation says: https://nbodykit.readthedocs.io/en/latest/api/_autosummary/nbodykit.transform.html#nbodykit.transform.CartesianToSky

rainwoodman commented 4 years ago

What type is the cosmology object did you provide to the function?