Ticket #10543: chk_SaveMD.py

File chk_SaveMD.py, 1.2 KB (added by Steve Miller, 6 years ago)
Line 
1#Basic python script to isolate a crash case when using SaveMD()
2
3import sys,os
4#Import Mantid computatinal modules
5sys.path.append(os.environ['MANTIDPATH'])
6from mantid.simpleapi import *     
7
8#Change path and file to point appropriately to the MD workspace you want to load
9path='C:\Users\mid\Documents\Mantid\Powder\CalcProj\\'  #will read input and save output to this directory
10file='zrh_1000_PCalcProj.nxs'
11print "*** Loading in Workspace: ",path+file
12md=LoadMD(path+file)
13print "  md.id(): ",md.id()
14
15#Create a 1D cut
16print "*** Using BinMD() to create a cut"
17cut=BinMD(md,AlignedDim0="|Q|,1,10,1",AlignedDim1="DeltaE,0,900,100")
18print "  cut.id(): ",cut.id()
19
20#Save this cut
21cutfile='cut.nxs'
22print "*** Saving cut to file: ",path+cutfile
23SaveMD(cut,path+cutfile)
24
25#Load the "cut" workspace back in
26print "*** Loading file: ",path+cutfile
27cut2=LoadMD(path+cutfile)
28print "  cut2.id(): ",cut2.id()
29
30#Now save the cut2 workspace back out - this step usually crashes
31cut2file='cut2.nxs'
32print "*** Attempting to re-save workspace"
33try:
34    print "*** Saving file: ",path+cut2file
35    SaveMD(cut2,path+cut2file)
36except:
37    print "*** Unable to save workspace to file: ",path+cut2file
38