Я пытаюсь добавить векторы вращения в виде стрелок к вершинам решетки. Однако я всегда получаю:
строку 2382, в глифе
if orient:
^^^^^^
ValueError: истинное значение массива с более чем одним элементом неоднозначно. Используйте a.any() или a.all()
Я впервые использую PyVista и понятия не имею.
import numpy as np
import vtk
import pyvista as pv
cols = 12
rows = 12
spacing = 10.0
points = []
# create lattice
for i in range(rows):
for j in range(cols):
x = j * spacing
y = i * (spacing * np.sqrt(3) / 2)
if i % 2 == 1:
x += spacing / 2
points.append([x, y, 0.0])
points = np.array(points)
spins = np.random.choice([-1, 1], size=(len(points), 3))
normed_spins = spins / np.linalg.norm(spins, axis=1)[:, np.newaxis]
lattice = pv.PolyData(points)
arrows = lattice.glyph(orient=normed_spins, scale=True, factor=0.5)
print(spins[:5])
plotter = pv.Plotter()
plotter.add_mesh(lattice, color="black", point_size=10, render_points_as_spheres=True, label="Gitterpunkte")
plotter.add_mesh(arrows, color="red", label="Spins")
plotter.show_bounds(grid="front", location="outer", all_edges=True)
plotter.show(title=)
Подробнее здесь: https://stackoverflow.com/questions/792 ... -recognize
Истинное значение массива неоднозначно в глифе PyVista, orient не распознает мой векторный массив ⇐ Python
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение