Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ramses data, yt Internal length units are inconsistent with all other units #2866

Open
wadsley opened this issue Aug 15, 2020 · 2 comments
Open
Labels
bug code frontends Things related to specific frontends domain: astro

Comments

@wadsley
Copy link

wadsley commented Aug 15, 2020

#2800 # Bug report

Bug summary

Ramses has a length unit called unit_l (cgs), e.g. ds.parameters['unit_l']
This is the correct length unit for ramses that feeds into all derived units (densities, pressures, energies, velocities).
Similarly it has unit_t for time etc...

The yt code_length unit (for converting from code units) does not match this unless the boxlen=1

Code for reproduction

Read in any ramses dataset where boxlen !=1,
e.g.

ds=yt.load("output_00001/info_00001.txt")
>>> x=ds.arr(1,"code_length")
>>> x.in_cgs()
 YTArray(9.87424e+21) cm
>>> ds.parameters("unit_l")
 3.0857e+21

These differ by boxlen (in this case 3.2).
This means that any derived units a user makes from yt's code units are broken and wrong.

e.g. If you have a new energy variable in code units and want to set it up the following will
lead to incorrect results.

def _ergperg(field, data):
     return data.ds.arr(data["ergperg_new_raw"],"code_length**2/code_time**2")

ds.add_field(("ramses", "ergperg_new"), sampling_type="cell", function=_ergperg, units="erg/g")

Ramses sometimes uses a unit of boxlen*unit_l for some distance variables.
This is not the code length unit. yt should recognize that the units of some position data
for ramses datasets is not ramses code length units but fractions of boxlen x unit_l and avoid having
a broken code_length.

Right now there seems to be some kind of internal hack so that units for pressure and so on in yt
and calculated using the Ramses actual length unit ('unit_l') and then the code_length is set to be
inconsistent with that so all those units cannot be reproduced using combinations of code_length,
code_time and code_mass. This is a nasty gotcha for anyone trying to use yt and ramses.

A general solution is to set the units for position data appropriately, not
to break something so fundamental as the code_length.

@welcome
Copy link

welcome bot commented Aug 15, 2020

Hi, and welcome to yt! Thanks for opening your first issue. We have an issue template that helps us to gather relevant information to help diagnosing and fixing the issue.

@cphyc cphyc added bug code frontends Things related to specific frontends domain: astro labels Sep 16, 2020
@cphyc
Copy link
Member

cphyc commented Sep 16, 2020

Thanks for the report! That should definitely get fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug code frontends Things related to specific frontends domain: astro
Projects
None yet
Development

No branches or pull requests

2 participants