Nathan,
I digged a bit deeper, and the problem seems to be in file yt/frontends/artio/data_structures.py, in function fill_particles(self, fields):
species_data = self.oct_handler.fill_sfc_particles(art_fields)
...
for s, f in fields:
...
count += species_data[i, f].size
...
v = species_data.pop((i, f))
The function is entered with field =
[('N-BODY', 'POSITION_X'), ('N-BODY', 'POSITION_X'), ('N-BODY', 'POSITION_X'), ('STAR', 'POSITION_X'), ('N-BODY', 'POSITION_Y'), ('N-BODY', 'POSITION_Z'), ('STAR', 'POSITION_Y'), ('STAR', 'POSITION_Z')]
while species_data is set as
{(0, 'POSITION_X'): array([], dtype=float64), (0, 'POSITION_Y'): array([], dtype=float64), (0, 'POSITION_Z'): array([], dtype=float64), (3, 'POSITION_X'): array([], dtype=float64), (3, 'POSITION_Y'): array([], dtype=float64), (3, 'POSITION_Z'): array([], dtype=float64)}
After the first iteration of the loop ('N-BODY', 'POSITION_X') is popped out of the dictionary, so the second iteration returns the key error.
It looks like there is a bug in artio backend for file sets that contain more than 1 DM species (my file set contains 3, hence 3 separate ('N-BODY', 'POSITION_X') inside fields list.
I tried replacing
for s, f in fields:
with
for s, f in set(fields):
but then it causes a problem further down the line with arrays not being compatible, which I cannot decipher.
Curiously, if I call ParticleProjectionPlot as
yt.ParticleProjectionPlot(d,'z',fields=[('N-BODY',"MASS")],c enter=[x0,y0,z0],width=(50,'kp c'))
(with fields argument specified explicitly), the call completes. In this case it appears that the fields argument selects just one of the three DM species for plotting.
I can provide you a file set and a code snippet that illustrates the problem if you think it is worth debugging further.
n
On 05/24/2018 10:06 PM, Nathan Goldbaum wrote:
Hi Nick,
I seem to be able to make this plot using the public artio test dataset we have at yt-project.org/data <http://yt-project.org/data>:
http://yt-project.org/data/sizmbhloz-clref04SNth-rs9_a0.9011 .tar.gz
Using that dataset I'm able to run the following script:
```python
import yt
ds = yt.load('sizmbhloz-clref04SNth-rs9_a0.9011/sizmbhloz- On Thu, May 24, 2018 at 7:02 PM, Cameron Hummels <chummels@gmail.com <mailto:chummels@gmail.com>> wrote:clref04SNth-rs9_a0.9011.art')
p = yt.ParticleProjectionPlot(ds, 'z')
p.save()
```
which produces this image: https://i.imgur.com/0lt31xR.png
So I think there's something about the dataset you're working with that's breaking the artio frontend somehow. Judging from the traceback, yt is trying to get the particle counts to allocate the numpy arrays that will contain the particle position fields needed by the ParticleProjectionPlot machinery. Somehow when we ask the artio octree handler how many particles there are, we get a dict back that's either missing some of those counts or is empty. It's hard for me to say more about what's going wrong without being able to debug on a live dataset triggering the issue.
Is there any chance you can share either the dataset you're working with or some other dataset that triggers this error? There's something different about the dataset you're working with compared with the test dataset we have which will help to explain what's going wrong.
-Nathan
Hi Nick,
I think you need to explicitly set the fields that you're plotting,
like ("Stars", "particle_position_x") and so forth. Here is an example:
http://yt-project.org/docs/dev/visualizing/plots.html#partic le-plots
<http://yt-project.org/docs/dev/visualizing/plots.html#parti >cle-plots
You can see what fields are available to plot by looking at the
"derived_field_list" hanging off of your dataset:
ds = yt.load("dataset")
print(ds.derived_field_list)
Look for particle-based ones that have "particle_position_x" and
"particle_position_y" present. I'm not sure the field_types
associated with ARTIO.
Hope this helps!
Cameron
On Thu, May 24, 2018 at 3:25 PM, Nick Gnedin <gnedin@fnal.gov<mailto:yt-users@python.org><mailto:gnedin@fnal.gov>> wrote:
Guys,
I get an error trying to use a simple ParticleProjectionPlot on
a ARTIO dataset. It looks like ParticleProjectionPlot expect
particular names for particle fields that the reader does not
create.
imp =
yt.ParticleProjectionPlot(d,'z',center=[x0,y0,z0],width=(10, 'kpc'))
File
"/data/gnedin/soft/anaconda3/lib/python3.6/site-packages/yt/ visualization/particle_plots. py",
line 249, in __init__
splat_color=splat_color)
File
"/data/gnedin/soft/anaconda3/lib/python3.6/site-packages/yt/ visualization/plot_window.py",
line 660, in __init__
PlotWindow.__init__(self, *args, **kwargs)
File
"/data/gnedin/soft/anaconda3/lib/python3.6/site-packages/yt/ visualization/plot_window.py",
line 219, in __init__
self._setup_plots()
File
"/data/gnedin/soft/anaconda3/lib/python3.6/site-packages/yt/ visualization/plot_window.py",
line 748, in _setup_plots
self._recreate_frb()
File
"/data/gnedin/soft/anaconda3/lib/python3.6/site-packages/yt/ visualization/plot_window.py",
line 272, in _recreate_frb
self._frb._get_data_source_fields()
File
"/data/gnedin/soft/anaconda3/lib/python3.6/site-packages/yt/ visualization/fixed_resolution .py",
line 646, in _get_data_source_fields
self[f]
File
"/data/gnedin/soft/anaconda3/lib/python3.6/site-packages/yt/ visualization/fixed_resolution .py",
line 586, in __getitem__
x_data = self.data_source.dd[ftype, self.x_field]
File
"/data/gnedin/soft/anaconda3/lib/python3.6/site-packages/yt/ data_objects/data_containers. py",
line 282, in __getitem__
self.get_data(f)
File
"/data/gnedin/soft/anaconda3/lib/python3.6/site-packages/yt/ data_objects/data_containers. py",
line 1331, in get_data
particles, self, self._current_chunk)
File
"/data/gnedin/soft/anaconda3/lib/python3.6/site-packages/yt/ geometry/geometry_handler.py",
line 227, in _read_particle_fields
fields_to_read)
File
"/data/gnedin/soft/anaconda3/lib/python3.6/site-packages/yt/ utilities/io_handler.py",
line 219, in _read_particle_selection
for field_r, vals in self._read_particle_fields(chunks,
ptf, selector):
File
"/data/gnedin/soft/anaconda3/lib/python3.6/site-packages/yt/ frontends/artio/io.py",
line 63, in _read_particle_fields
rv = dict(**subset.fill_particles(fields))
File
"/data/gnedin/soft/anaconda3/lib/python3.6/site-packages/yt/ frontends/artio/data_structure s.py",
line 107, in fill_particles
count += species_data[i, f].size
KeyError: (0, 'POSITION_X')
_______________________________________________
yt-users mailing list -- yt-users@python.org
To unsubscribe send an email to yt-users-leave@python.org
<mailto:yt-users-leave@python.org >
-- Cameron Hummels
NSF Postdoctoral Fellow
Department of Astronomy
California Institute of Technology
http://chummels.org
_______________________________________________ <mailto:yt-users@python.org>
yt-users mailing list -- yt-users@python.org
To unsubscribe send an email to yt-users-leave@python.org
<mailto:yt-users-leave@python.org >