Closed cphyc closed 6 years ago
I guess option 1 is least dangerous? What do you think?
The other way round is to automatically detect the first 9 records that are always here, and then assume all the remaning one to be of kind real, throwing a warning to the user like:
yt has detected N extra fields assuming real kind. Consider using the extra_particle_fields option if you have unexpected behavior.
Bug report
Bug summary
When RAMSES does a run with stars but none have been created yet, the number of star in the output is
0
. This leads to a bug as the frontend doesn't automatically read theparticle_age
andparticle_metallicity
fields as it should. This means that the field would be only present for outputs that have formed stars, even though they are present in the files for all outputs.This is due to line https://github.com/yt-project/yt/blob/736c39cbcf43b48358525df65db989b6426324a4/yt/frontends/ramses/data_structures.py#L170, where the check is wrong as long as no star have been created.
This lead to a bug if the
extra_particle_fields
is used. The explanation is the following. Imagine we have a dataset with 11 records (3 positions, 3 velocities, 1 mass, 1 id, and 1 for the refinement level + 1 particle age, 1 particle metallicity). As long as no star are formed, yt will only load the first 9 records, so that theextra_particle_fields
dict will be applied to the records >9. Once a star is formed, yt will load the first 11 records, so that theextra_particle_fields
will be applied to the records >11.There are 2 solutions to the problem:
extra_particle_fields
argument is passedparticle_field_1
,particle_field_2
, … and give the user the possibility to name to give them a name. However, this option would have to assume that all the optional fields have a single type (e.g.real
), because the Fortran data layout doesn't give any information about the type of the records.