nbodykit icon indicating copy to clipboard operation
nbodykit copied to clipboard

units of nbodykit.transform.SkyToCartesian

Open SandyYuan opened this issue 5 years ago • 7 comments

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

SandyYuan avatar Nov 30 '19 21:11 SandyYuan

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

rainwoodman avatar Dec 02 '19 04:12 rainwoodman

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

SandyYuan avatar Dec 02 '19 05:12 SandyYuan

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 [email protected] 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 .

rainwoodman avatar Dec 02 '19 17:12 rainwoodman

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>

SandyYuan avatar Dec 02 '19 18:12 SandyYuan

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.

nickhand avatar Dec 04 '19 02:12 nickhand

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

NiallJeffrey avatar Mar 12 '20 14:03 NiallJeffrey

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

rainwoodman avatar Mar 13 '20 02:03 rainwoodman