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