Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Whitfield, Ross
wand
Commits
773bfbec
Commit
773bfbec
authored
Feb 15, 2019
by
Whitfield, Ross
Browse files
Update IPTS-21442/array_to_vtk.py
parent
9dff9a32
Changes
1
Hide whitespace changes
Inline
Side-by-side
IPTS-21442/array_to_vtk.py
0 → 100644
View file @
773bfbec
import
numpy
as
np
import
vtk
from
vtk.util.numpy_support
import
numpy_to_vtk
,
get_vtk_array_type
from
mantid.simpleapi
import
LoadMD
ws
=
LoadMD
(
'/SNS/users/rwp/wand/IPTS-21442/skyrmion_4D.nxs'
)
signal
=
ws
.
getSignalArray
()
vtkArray
=
numpy_to_vtk
(
num_array
=
signal
.
flatten
(
'F'
),
deep
=
True
,
array_type
=
get_vtk_array_type
(
signal
.
dtype
))
origin
=
np
.
array
([
ws
.
getDimension
(
d
).
getMinimum
()
for
d
in
range
(
4
)])
spacing
=
np
.
array
([
ws
.
getDimension
(
d
).
getBinWidth
()
for
d
in
range
(
4
)])
imageData
=
vtk
.
vtkImageData
()
imageData
.
SetOrigin
(
origin
)
imageData
.
SetSpacing
(
spacing
)
imageData
.
SetDimensions
(
signal
.
shape
)
imageData
.
GetPointData
().
SetScalars
(
vtkArray
)
writer
=
vtk
.
vtkXMLImageDataWriter
()
writer
.
SetFileName
(
'/SNS/users/rwp/wand/IPTS-21442/skyrmion_4D.vti'
)
writer
.
SetInputData
(
imageData
)
writer
.
Write
()
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment