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

OffAxisSlicePlot does not appear to work with particle-based datasets #3518

Open
chummels opened this issue Sep 16, 2021 · 11 comments
Open

OffAxisSlicePlot does not appear to work with particle-based datasets #3518

chummels opened this issue Sep 16, 2021 · 11 comments
Labels
index: particle viz: 2D wishlist Things we'd like to do some day

Comments

@chummels
Copy link
Member

Bug report

Bug summary

When I attempt to generate an OffAxisSlicePlot for any particle-based datasets, I get unindexed type errors. The same code snippet is in our documentation for working with grid-based datasets and it works fine for those.

Code for reproduction

import yt
ds = yt.load_sample("GadgetDiskGalaxy")
yt.SlicePlot(ds, [1,1,0], ("gas", "density")).save()

Actual outcome

Traceback (most recent call last):
  File "test_slice2.py", line 3, in <module>
    yt.SlicePlot(ds, [1,1,0], ("gas", "density")).save()
  File "/Users/chummels/src/yt/yt/visualization/plot_window.py", line 2474, in SlicePlot
    return OffAxisSlicePlot(ds, normal, fields, *args, **kwargs)
  File "/Users/chummels/src/yt/yt/visualization/plot_window.py", line 1985, in __init__
    PWViewerMPL.__init__(
  File "/Users/chummels/src/yt/yt/visualization/plot_window.py", line 872, in __init__
    PlotWindow.__init__(self, *args, **kwargs)
  File "/Users/chummels/src/yt/yt/visualization/plot_window.py", line 256, in __init__
    self._setup_plots()
  File "/Users/chummels/src/yt/yt/visualization/plot_window.py", line 964, in _setup_plots
    self._recreate_frb()
  File "/Users/chummels/src/yt/yt/visualization/plot_window.py", line 316, in _recreate_frb
    self._frb._get_data_source_fields()
  File "/Users/chummels/src/yt/yt/visualization/fixed_resolution.py", line 176, in _get_data_source_fields
    self[f]
  File "/Users/chummels/src/yt/yt/visualization/fixed_resolution.py", line 139, in __getitem__
    buff = self.ds.coordinates.pixelize(
  File "/Users/chummels/src/yt/yt/geometry/coordinates/cartesian_coordinates.py", line 221, in pixelize
    return self._oblique_pixelize(data_source, field, bounds, size, antialias)
  File "/Users/chummels/src/yt/yt/geometry/coordinates/cartesian_coordinates.py", line 552, in _oblique_pixelize
    indices = np.argsort(data_source["pdx"])[::-1].astype(np.int_)
  File "/Users/chummels/src/yt/yt/data_objects/data_containers.py", line 255, in __getitem__
    self.field_data[f] = self.ds.arr(self._generate_container_field(f))
  File "/Users/chummels/src/yt/yt/data_objects/selection_objects/slices.py", line 270, in _generate_container_field
    return self._current_chunk.fwidth[:, 0] * 0.5
  File "/Users/chummels/src/yt/yt/geometry/geometry_handler.py", line 255, in cached_func
    tr = self._accumulate_values(n[1:])
  File "/Users/chummels/src/yt/yt/geometry/geometry_handler.py", line 292, in _accumulate_values
    arrs.append(f(self.dobj))
  File "/Users/chummels/src/yt/yt/data_objects/index_subobjects/particle_container.py", line 17, in _func_non_indexed
    raise YTNonIndexedDataContainer(self)
yt.utilities.exceptions.YTNonIndexedDataContainer: The data container (<class 'yt.data_objects.index_subobjects.particle_container.ParticleContainer'>) is an unindexed type.  Operations such as ires, icoords, fcoords and fwidth will not work on it.

Expected outcome

I expected it to produce an OffAxisSlicePlot.

Version Information

current tip of yt dev: 88b16fb

@neutrinoceros
Copy link
Member

neutrinoceros commented Sep 16, 2021

Does OffAxisProjectionPlot support particle datasets ?

@chummels
Copy link
Member Author

Yes--I use it all the time.

@neutrinoceros
Copy link
Member

Ok then should we deal with #3489 before or after fixing this ?

@jzuhone
Copy link
Contributor

jzuhone commented Sep 16, 2021

AFAIK we haven't supported this yet at all (probably an oversight in releasing 4.0)

@neutrinoceros
Copy link
Member

yeah so I'm hesitant to call this a "bug", rather a missing feature ? Though the fact that you hit a YTNonIndexedDataContainer instead of a NotImplementedError is a bug in itself, IMO.
I'd advise adding a "bug" and a "new feature" label here.

@chummels
Copy link
Member Author

It appears that you're right @jzuhone as per the message sort of buried here in the narrative docs: https://yt-project.org/docs/dev/visualizing/plots.html#additional-notes-for-plotting-particle-data (thanks, @brittonsmith for the link). Given that, I think we should update the docstring for OffAxisSlicePlot to say that it doesn't work with particle-based datasets and change the error to NotImplemented, but in an ideal world we would just implement it the code to work with particles, since this is sort of core-functionality.

@neutrinoceros
Copy link
Member

I think we should update the docstring for OffAxisSlicePlot to say that it doesn't work with particle-based datasets and change the error to NotImplemented, but in an ideal world we would just implement it the code to work with particles, since this is sort of core-functionality.

Unless anyone has time to implement it soon, how about we do the easy fix (docstring + NotImplementedError) now and keep this issue open within the 4.1 milestone so it is at least discussed (addressed ?) in time for the next feature release ?

@chummels
Copy link
Member Author

Yeah, that works for me. I am not sure how to go about implementing this to be honest, but I do think it's important that we address this at some point since we're actively courting particle-based simulation users with the release of yt4.

@neutrinoceros
Copy link
Member

Agreed. Can you make a PR with docs + the corrected error ?

@neutrinoceros neutrinoceros added wishlist Things we'd like to do some day viz: 2D labels Oct 21, 2021
@neutrinoceros
Copy link
Member

related to #2628

@neutrinoceros neutrinoceros added this to the 4.1.0 milestone Feb 16, 2022
@neutrinoceros neutrinoceros removed this from the 4.1.0 milestone Mar 15, 2022
@neutrinoceros
Copy link
Member

note that, while the example still fails, the error message was intentionally changed in #4038

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
index: particle viz: 2D wishlist Things we'd like to do some day
Projects
None yet
Development

No branches or pull requests

3 participants