Vector data not identified as VECTORS
See original GitHub issueDescription
I’m a bit of a VTK newbie, so I didn’t want to post this for sure as a bug. But there’s something strange going on with assigning point data. The pyvista sphere example provides a minimal working example of what happens, so no data is needed:
sphere = pv.Sphere(radius=3.14)
vectors = np.vstack(
(
np.sin(sphere.points[:, 0]),
np.cos(sphere.points[:, 1]),
np.cos(sphere.points[:, 2]),
)
).T
sphere.vectors = vectors * 0.3
sphere.arrows.plot(scalars='GlyphScale')
All of this, of course, works fine. However, suppose you try to save this data in ascii format:
sphere.save('sphere.vtk', binary=False)
If you open the resulting file in a text editor and scroll down to the POINT_DATA field, you get something that to me was rather unexpected:
POINT_DATA 842
SCALARS _vectors float 3
LOOKUP_TABLE default
So, it’s recording the vector data as scalar data with the name “_vectors”, type float, and 3 components (I’m referencing the vtk.org guidance on file-formats). This to me is rather weird. I was expecting a VECTOR dataset attribute with some kind of default name (I’m not sure how one assigns a name to vector data in the pyvista API). Something like:
POINT_DATA 842
VECTORS vectors float
I’m decently sure this is a bug because causes problems down the line: if I try to open this vtk file in something like VisIt to do a vector glyph plot, it can’t find the vector data. But maybe there’s some other way you are supposed to accomplish assigning vector point data? I thought the sphere example was a great showcase of how this should be done, but then there’s this weird formatting issue. Any help/guidance would be greatly appreciated!
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:8 (4 by maintainers)
Top GitHub Comments
Info about a workaround I am currently using:
I can currently find no way to set VECTOR data in pyvista without resorting to the underlying VTK API. For the moment, here is what I am doing in order to get VECTOR data. This code follows the sphere example in the original post:
I transferred this to the main repo as I think it has moved out of a support question and into a discussion about how to go about adding this functionality into the codebase (or whether it should be).