Commit e5f04839 authored by Whitfield, Ross's avatar Whitfield, Ross
Browse files

Update IPTS-21442/MD_VSI_Save.py IPTS-21442/array_to_vtk.py IPTS-21442/make_4D_temp.py

parent 9f13e46b
ws = LoadMD('/SNS/users/rwp/wand/IPTS-21442/skyrmion_4D.nxs',LoadHistory=False)
#######
# Open VSI!
#######
from paraview.simple import *
import vtk
source=GetActiveSource()
SaveData('/SNS/users/rwp/wand/IPTS-21442/skyrmion_4D.vts', source)
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()
......@@ -23,8 +23,17 @@ for n, t in enumerate(range(5,30)):
output.setSignalArray(signal)
SaveMD(output,'/SNS/users/rwp/wand/IPTS-21442/skyrmion_4D.nxs')
SaveMDWorkspaceToVTK('output','/SNS/users/rwp/wand/IPTS-21442/skyrmion_4D.vts')
SliceMDHisto(InputWorkspace='output', Start='10,10,10,0', End='51,51,11,25', OutputWorkspace='slice')
SaveMD('slice','/SNS/users/rwp/wand/IPTS-21442/skyrmion_3D.nxs')
SaveMDWorkspaceToVTK('slice','/SNS/users/rwp/wand/IPTS-21442/skyrmion_3D.vts')
#output=LoadMD('/SNS/users/rwp/wand/IPTS-21442/skyrmion_4D.nxs')
#SaveMDWorkspaceToVTK('output','/SNS/users/rwp/wand/IPTS-21442/skyrmion_4D.vts')
for n in range(output.getDimension(3).getNBins()):
T=(output.getDimension(3).getX(n)+output.getDimension(3).getX(n+1))/2
#SliceMDHisto(InputWorkspace='output', Start='10,10,0,{}'.format(n), End='51,51,21,{}'.format(n+1), OutputWorkspace='slice')
IntegrateMDHistoWorkspace('output', P1Bin='-0.1,0,0.1',P2Bin='0.9,0,1.1',P4Bin='{},{}'.format(T-0.5,T+0.5), OutputWorkspace='slice')
SaveMD('slice','/SNS/users/rwp/wand/IPTS-21442/skyrmion_{}K.nxs'.format(int(T)))
SaveMDWorkspaceToVTK('slice','/SNS/users/rwp/wand/IPTS-21442/skyrmion_{}K.vts'.format(int(T)))
# 3D - 2D+T
#SliceMDHisto(InputWorkspace='output', Start='10,10,10,0', End='51,51,11,25', OutputWorkspace='slice')
IntegrateMDHistoWorkspace('output', P1Bin='-0.1,0,0.1',P2Bin='0.9,0,1.1',P3Bin='0.35,0.65', OutputWorkspace='slice')
SaveMD('slice','/SNS/users/rwp/wand/IPTS-21442/skyrmion_3D_T.nxs')
SaveMDWorkspaceToVTK('slice','/SNS/users/rwp/wand/IPTS-21442/skyrmion_3D_T.vts')
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment