You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I struggle with resampling a unstructured dataset to a structured grid and then convert the point dataset back to an numpy array on which I could do some math.
Here is a basic example utilizing the embryo dataset:
import pyvista as pv
from pyvista import examples
import matplotlib.pyplot as plt
# get a sample dataset
data_to_probe = examples.download_embryo()
# create a grid to resample
mesh = pv.create_grid(data_to_probe, dimensions=(70, 72, 74))
# resample the data
result = mesh.sample(data_to_probe)
# convert the resampled data to an numpy array
SLCImage = pv.point_array(result, 'SLCImage')
# attempt to reshape
SLCImage_shape = SLCImage.reshape((70, 72, 74))
# this should show a slice in the xy plane at the middel of z
plt.imshow(SLCImage_shape[:, :, 46])
plt.show()
I get the dataset and create a grid (which is structured) on a lower resolution. Then I utilize the point_array feature the extract the values from the point dataset 'SLCImage'. However in the last step when I attempt to reshape the numpy array values into a 3D array with the same dimensions as the resample grid, I fail. To prove my point I plot a slice through the extracted numpy array, which shows that the ordering of the numpy array is wrong.
Does anybody know how to reshape the point_array correctly? Any help would be highly appreciated.
Best wishes,
Alex
The text was updated successfully, but these errors were encountered:
Hi all,
I struggle with resampling a unstructured dataset to a structured grid and then convert the point dataset back to an numpy array on which I could do some math.
Here is a basic example utilizing the embryo dataset:
I get the dataset and create a grid (which is structured) on a lower resolution. Then I utilize the
point_array
feature the extract the values from the point dataset 'SLCImage'. However in the last step when I attempt to reshape the numpy array values into a 3D array with the same dimensions as the resample grid, I fail. To prove my point I plot a slice through the extracted numpy array, which shows that the ordering of the numpy array is wrong.Does anybody know how to reshape the point_array correctly? Any help would be highly appreciated.
Best wishes,
Alex
The text was updated successfully, but these errors were encountered: