[yt-dev] Issue #1258: potential unit error in cosmology.py (yt_analysis/yt)

Pengfei Chen issues-reply at bitbucket.org
Tue Aug 9 08:10:23 PDT 2016


New issue 1258: potential unit error in cosmology.py
https://bitbucket.org/yt_analysis/yt/issues/1258/potential-unit-error-in-cosmologypy

Pengfei Chen:

I was trying to generate light rays using yt 3.4-dev, but found that the light rays have wrong redshift intervals. The error happens when I make light rays from one single dataset. I reproduced the error with the dataset under src/yt-hg/tests. The code I used is here:
http://paste.yt-project.org/show/6751/

After running the code, I did 
h5ls -d lightray.h5/grid/redshift

and found the last redshift was 9.98999107782409. However, the correct value should be 9.97888260334447.

When I call LightRay this way, it will call the _deltaz_forward function in cosmology_splice.py, which will call the comoving_radial_distance in cosmology.py:
        distance2 = self.cosmology.comoving_radial_distance(z2, z)

, where distance2 is not in comoving units. Then it will calculate z2:

            z2 = ((target_distance - distance2) / m.in_units("Mpccm / h")) + z2

. I think the subtraction here is the problem, since it tries to convert distance2 to comoving units, even though the numerical value of distance2 is already comoving. So a wrong factor of (1+z) is multiplied.




More information about the yt-dev mailing list