1 | ########################################################################### |
---|
2 | ## Sample script to build Mantid's combined MD workspace ## |
---|
3 | ## equivalent of Horace sqw object ## |
---|
4 | ########################################################################### |
---|
5 | data_path=os.path.dirname(os.path.realpath(__file__)) |
---|
6 | config.appendDataSearchDir(data_path) |
---|
7 | |
---|
8 | config['defaultsave.directory']=data_path |
---|
9 | save_dir = config.getString('defaultsave.directory') |
---|
10 | print "Data will be saved into: ",save_dir |
---|
11 | |
---|
12 | # |
---|
13 | print 'Start converting \n' |
---|
14 | # |
---|
15 | preprocessedDetectorsWSName='preprDetMAPS' |
---|
16 | # List of the comma-separated file names to merge |
---|
17 | MDWS_FilesList=''; |
---|
18 | |
---|
19 | #efix=34.96; |
---|
20 | |
---|
21 | # ConvertToMD parameters defined out of the loop |
---|
22 | pars = dict(); |
---|
23 | pars['InputWorkspace']='' |
---|
24 | pars['QDimensions']='Q3D' |
---|
25 | pars['dEAnalysisMode']='Direct' |
---|
26 | pars['Q3DFrames']='HKL' |
---|
27 | pars['QConversionScales']='HKL' |
---|
28 | pars['PreprocDetectorsWS']=preprocessedDetectorsWSName; |
---|
29 | pars['MinValues']='-3,-3,-3,-2' |
---|
30 | pars['MaxValues']='3,3,3,23' |
---|
31 | pars['SplitInto']='50,50,50,60' |
---|
32 | pars['OverwriteExisting']=False |
---|
33 | # Currently works only with 1 |
---|
34 | pars['MaxRecursionDepth']=1 |
---|
35 | pars['MinRecursionDepth']=1 |
---|
36 | pars['TopLevelSplitting']=1 |
---|
37 | |
---|
38 | nFiles = 2 |
---|
39 | print " processing {0} spe files".format(nFiles) |
---|
40 | |
---|
41 | for n in xrange(0,nFiles): |
---|
42 | source = 'MAP0'+str(5935+n)+'_4to1_033.nxspe'; |
---|
43 | target = 'MDMAP'+str(5935+n)+'_4to1_033.nxs'; |
---|
44 | #while not(os.path.exists(save_dir+source)): |
---|
45 | |
---|
46 | if not(os.path.exists(save_dir+target)): |
---|
47 | print 'Converting ',source |
---|
48 | cur_ws=LoadNXSPE(Filename=source) |
---|
49 | |
---|
50 | # save disk space, remove source file |
---|
51 | # (it should be stored somewhere) in archive |
---|
52 | #os.remove(source); |
---|
53 | |
---|
54 | # Add incident energy log. May be not necessary for NXSPE or nxs files |
---|
55 | #AddSampleLog(Workspace=cur_ws,LogName='Ei',LogText=str(efix),LogType='Number') |
---|
56 | # Add rotation angle log. May be not necessary for NXSPE or nxs files |
---|
57 | #AddSampleLog(Workspace=cur_ws,LogName='Psi',LogText=str(psi[n])+'.',LogType='Number') |
---|
58 | |
---|
59 | # Set projection matrix |
---|
60 | SetUB(Workspace=cur_ws,a=4.2275,b=4.2275,c=4.2275,u='1,1,0',v='0,0,1') |
---|
61 | # rotated by proper number of degrees around rotation axis, which in usual Horace set-up is parallel to second projection axis |
---|
62 | SetGoniometer(Workspace=cur_ws,Axis0='Psi,0,1,0,1') |
---|
63 | print "Goniometer angles: ",cur_ws.getRun().getGoniometer().getEulerAngles('XYZ') |
---|
64 | |
---|
65 | |
---|
66 | # set up source workspace |
---|
67 | pars['InputWorkspace']=cur_ws; |
---|
68 | # Convert To MD |
---|
69 | target_MDws=ConvertToMD(**pars) |
---|
70 | |
---|
71 | # Save data for future usage |
---|
72 | SaveMD(target_MDws,Filename=target ); |
---|
73 | # Clear memory |
---|
74 | DeleteWorkspace(target_MDws); |
---|
75 | DeleteWorkspace(cur_ws); |
---|
76 | |
---|
77 | if (len(MDWS_FilesList) == 0): |
---|
78 | MDWS_FilesList = target; |
---|
79 | else: |
---|
80 | MDWS_FilesList=MDWS_FilesList+','+target; |
---|
81 | |
---|
82 | |
---|
83 | ws4D = MergeMDFiles(MDWS_FilesList,OutputFilename='RbMnF3_test.nxs', Parallel='0'); |
---|
84 | |
---|
85 | ###################################################################### |
---|
86 | |
---|
87 | |
---|