yt-project / yt

Main yt repository
http://yt-project.org
Other
463 stars 276 forks source link

Metallicity values reported by LightRay in 3.0 significantly differ from metallicity values in 2.x #969

Closed yt-fido closed 7 years ago

yt-fido commented 9 years ago

Originally reported by: chummels (Bitbucket: chummels, GitHub: chummels)


I've run into an insidious bug in the LightRay analysis module, wherein metallicity values reported along the light ray in yt 3.0 differ by an OOM with metallicity values reported along the light ray in 2.x. Strangely enough, temperature values between the two versions don't change at all, and density values only change at the <1e-4 level.

I have investigated this to some degree and it appears that the bug is confined to the LightRay analysis module, as I'm seeing the same metallicity values for raw Ray and other data objects between the two versions of yt.

The following scripts demonstrate this problem with the enzo_cosmology_plus dataset. Because of the way in which the LightRay object operates, you'll need to run these scripts inside the enzo_cosmology_plus directory.

For yt-2.x, run this script in the enzo_cosmology_plus directory: http://paste.yt-project.org/show/5323/

With the resulting output:

#!python

Density: [  9.97279296e-32   9.20237619e-31]
Temperature: [  1706.254685    75236.83753987]
Metallicity: [  4.96203366e-09   4.62205944e-09]

For yt-3.0, run this script in the enzo_cosmology_plus directory: http://paste.yt-project.org/show/5324/

With the resulting output:

#!python

Density: [  9.97278399e-32   9.20236791e-31]     
Temperature: [  1706.254685    75236.83753987] 
Metallicity: [  1.01225503e-10   9.42900276e-11]

yt-fido commented 9 years ago

Original comment by Britton Smith (Bitbucket: brittonsmith, GitHub: brittonsmith):


This is less a bug than a change in behavior brought on by now explicitly outputting all fields in CGS units.

yt-fido commented 9 years ago

Original comment by Nathan Goldbaum (Bitbucket: ngoldbaum, GitHub: ngoldbaum):


@brittonsmith should this be marked as wontfix?

yt-fido commented 9 years ago

Original comment by Britton Smith (Bitbucket: brittonsmith, GitHub: brittonsmith):


@MatthewTurk is right, they are off by exactly a factor of Zsun. The reason is that all of the ray data is converted to cgs before it's written out to make sure that the segments are pieced together in the right units. Since metallicity is a dimensionless quantity, the cgs unit of metallicity is dimensionless (or absolute metallicity) and not in units of Zsun.

I think this is probably the safest way to do things and should not be changed. Instead, I would advocate that codes that use LightRay output files be updated to be unit aware. The LightRay generator already writes the units of the fields out as an attribute on each dataset, so these can be read in by other tools and fields can be converted to whatever units safely.

yt-fido commented 9 years ago

Original comment by Matt Turk (Bitbucket: MatthewTurk, GitHub: MatthewTurk):


Both of the metallicities are different by exactly a factor of 0.0204. This looks like a Zsun issue.

@brittonsmith any thoughts?