Open yohad opened 2 days ago
thanks for reporting Here's a reusable version of the reproducer
import yt
yt.load_sample('D9p_500', skip_particles=True)
So the bug is pretty simple to describe
self.parameters["ng"]
is only defined on the following line if particles aren't skipped
https://github.com/yt-project/yt/blob/9e483ce13c2737e4d1d2987c436c73917f7e9b47/yt/frontends/art/data_structures.py#L347
However, how to fix it is not (to me):
As we can see, the value of this parameter is heavily relied on to define the units
https://github.com/yt-project/yt/blob/9e483ce13c2737e4d1d2987c436c73917f7e9b47/yt/frontends/art/data_structures.py#L226-L236
(the good news is that ng
is the only such parameter that gets skipped with particles)
How should we address this ? I can see two options:
1) Would it make sense to have a default value for ng
when particles aren't read (and if so, what should this default value be) ?
2) should we still read it from file even with skip_particles=True
instead ?
Option 1 seems dangerous to me (given, I don't know what ng
stands for). Option 2 is probably better but may not be practical: I haven't studied the logic in detail; maybe we can't read this value and really skip reading particles, in which case it would make more sense to go with option 3: deprecate skip_particles
as broken and unfixable (not my favorite option).
For what it's worth, at least with 'D9p_500'
, up in the section where it reads the amr header info these two lines:
match the values that are read from the particle header:
that intermediate est
in the amr header section gets printed in a debug log, so comparing the calculated values in the amr header section to those in the particle header section:
import yt
yt.set_log_level('debug')
ds = yt.load_sample('D9p_500')
print(f"n cell from amr header = {ds.ncell}")
print(f"particle header parameters ng={ds.parameters['ng']}, ncell0={ds.parameters['ncell0']}")
skipping unrelated logs...
yt : [DEBUG ] 2024-11-14 10:17:37,775 Estimating 128 cells on a root grid side, 262144 root octs
n cell from amr header = 2097152
particle header parameters ng=128, ncell0=2097152
so based on that and the name of ng
in the particle header (Ngridc
), i'd hazard a guess that ng
is an amr grid-related parameter that happens to only exist in the particle header? and it could be safely set by est
from the amr header section if it's not reading particles? But it'd be nice to have confirmation of that from someone more familiar with art outputs....
Bug report
I'm trying to use
skip_particles
when runningyt.load
as I only need the gas data and the loading gets very long. The loading fails, but when I run it without skip_particles I can load just fineCode for reproduction
Version Information