| 1 | import os |
|---|
| 2 | |
|---|
| 3 | #----------------------------- WITHOUT INITIAL SPLITTING (woIS)----------------------------------------------------------- |
|---|
| 4 | # set up target ws name and remove target workspace with the same name which can occasionally exist. |
|---|
| 5 | # list of MD files (workspaces) to combine into target MD workspace |
|---|
| 6 | MD_FilesList_woIS=''; |
|---|
| 7 | |
|---|
| 8 | # define convetr to MD parameters |
|---|
| 9 | pars_woIS = dict(); |
|---|
| 10 | pars_woIS['InputWorkspace']='' |
|---|
| 11 | pars_woIS['QDimensions']='Q3D' |
|---|
| 12 | pars_woIS['dEAnalysisMode']='Direct' |
|---|
| 13 | pars_woIS['Q3DFrames']='HKL' |
|---|
| 14 | pars_woIS['QConversionScales']='HKL' |
|---|
| 15 | pars_woIS['PreprocDetectorsWS']='preprDetMantid' |
|---|
| 16 | pars_woIS['MinValues']='-3,-3,-3.,-50.0' |
|---|
| 17 | pars_woIS['MaxValues']='3.,3.,3.,50.0' |
|---|
| 18 | pars_woIS['SplitInto']=5 |
|---|
| 19 | pars_woIS['MaxRecursionDepth']=1 |
|---|
| 20 | pars_woIS['MinRecursionDepth']=1 |
|---|
| 21 | pars_woIS['OverwriteExisting']=1 # Change this to false, if the files should/can be added in memory |
|---|
| 22 | # test script combines all contributed files in memory |
|---|
| 23 | pars_woIS['OverwriteExisting']=0 # Change this to false, if the files should/can be added in memory |
|---|
| 24 | pars_woIS['InitialSplitting']=0 |
|---|
| 25 | # |
|---|
| 26 | #---> Start loop over contributing files |
|---|
| 27 | for n in xrange(0,5,1): |
|---|
| 28 | source_file_woIS = 'MER19566_22.0meV_one2one125.nxspe'; # redefine source files list as function of loop number |
|---|
| 29 | target_woIS = 'MDMAP_T1_woIS'+str(n)+'.nxs'; |
|---|
| 30 | # check if the file already been converted to MD and is there |
|---|
| 31 | if not(os.path.exists(target_woIS)): |
|---|
| 32 | print 'Converting ',source_file_woIS |
|---|
| 33 | #current_ws=LoadNXSPE(Filename=source) |
|---|
| 34 | #### For the sample script, simulate load operation above |
|---|
| 35 | current_ws_woIS = CreateSimulationWorkspace(Instrument='MAR',BinParams=[-3,1,3],UnitX='DeltaE',OutputWorkspace=source_file_woIS) |
|---|
| 36 | AddSampleLog(Workspace=current_ws_woIS,LogName='Ei',LogText='3.0',LogType='Number') |
|---|
| 37 | |
|---|
| 38 | #### Add iformation which is not stored in the nxspe file |
|---|
| 39 | # Add UB matrix (lattice and the beam direction) |
|---|
| 40 | SetUB(Workspace=current_ws_woIS,a='1.4165',b='1.4165',c='1.4165',u='1,0,0',v='0,1,0') |
|---|
| 41 | # Add crystal rotation (assume rotation abgle Psi=5*n where n is file number. Define list of angles if this is not correct |
|---|
| 42 | AddSampleLog(Workspace=current_ws_woIS,LogName='Psi',LogText=str(5*n)+'.',LogType='Number') # --correct Psi value may be already in nxspe file. This operation is then unnecessary |
|---|
| 43 | # set crystal rotation |
|---|
| 44 | SetGoniometer(Workspace=current_ws_woIS,Axis0='Psi,0,1,0,1') |
|---|
| 45 | |
|---|
| 46 | # Convert to MD |
|---|
| 47 | pars_woIS['InputWorkspace']=current_ws_woIS; |
|---|
| 48 | md_ws_woIS=ConvertToMD(**pars_woIS) |
|---|
| 49 | |
|---|
| 50 | # save MD for further usage -- disabled in test script |
|---|
| 51 | #SaveMD(md_ws,Filename=target); |
|---|
| 52 | #DeleteWorkspace(md_ws); # delete intermediate workspace to save memory |
|---|
| 53 | DeleteWorkspace(current_ws_woIS); |
|---|
| 54 | |
|---|
| 55 | # add the file name of the file to combine |
|---|
| 56 | if (len(MD_FilesList_woIS) == 0): |
|---|
| 57 | MD_FilesList_woIS = target_woIS; |
|---|
| 58 | else: |
|---|
| 59 | MD_FilesList_woIS=MD_FilesList_woIS+','+target_woIS; |
|---|
| 60 | |
|---|
| 61 | |
|---|
| 62 | |
|---|
| 63 | #----------------------------- WITH INITIAL SPLITTING (wIS)----------------------------------------------------------- |
|---|
| 64 | # set up target ws name and remove target workspace with the same name which can occasionally exist. |
|---|
| 65 | # list of MD files (workspaces) to combine into target MD workspace |
|---|
| 66 | MD_FilesList_wIS=''; |
|---|
| 67 | |
|---|
| 68 | # define convetr to MD parameters |
|---|
| 69 | pars_wIS = dict(); |
|---|
| 70 | pars_wIS['InputWorkspace']='' |
|---|
| 71 | pars_wIS['QDimensions']='Q3D' |
|---|
| 72 | pars_wIS['dEAnalysisMode']='Direct' |
|---|
| 73 | pars_wIS['Q3DFrames']='HKL' |
|---|
| 74 | pars_wIS['QConversionScales']='HKL' |
|---|
| 75 | pars_wIS['PreprocDetectorsWS']='preprDetMantid' |
|---|
| 76 | pars_wIS['MinValues']='-3,-3,-3.,-50.0' |
|---|
| 77 | pars_wIS['MaxValues']='3.,3.,3.,50.0' |
|---|
| 78 | pars_wIS['SplitInto']=5 |
|---|
| 79 | pars_wIS['MaxRecursionDepth']=1 |
|---|
| 80 | pars_wIS['MinRecursionDepth']=1 |
|---|
| 81 | pars_wIS['OverwriteExisting']=1 # Change this to false, if the files should/can be added in memory |
|---|
| 82 | # test script combines all contributed files in memory |
|---|
| 83 | pars_wIS['OverwriteExisting']=0 # Change this to false, if the files should/can be added in memory |
|---|
| 84 | pars_wIS['InitialSplitting']=1 |
|---|
| 85 | # |
|---|
| 86 | #---> Start loop over contributing files |
|---|
| 87 | for n in xrange(0,5,1): |
|---|
| 88 | source_file_wIS = 'MER19566_22.0meV_one2one125.nxspe'; # redefine source files list as function of loop number |
|---|
| 89 | target_wIS = 'MDMAP_T1_wIS'+str(n)+'.nxs'; |
|---|
| 90 | # check if the file already been converted to MD and is there |
|---|
| 91 | if not(os.path.exists(target_wIS)): |
|---|
| 92 | print 'Converting ',source_file_wIS |
|---|
| 93 | #current_ws=LoadNXSPE(Filename=source) |
|---|
| 94 | #### For the sample script, simulate load operation above |
|---|
| 95 | current_ws_wIS = CreateSimulationWorkspace(Instrument='MAR',BinParams=[-3,1,3],UnitX='DeltaE',OutputWorkspace=source_file_wIS) |
|---|
| 96 | AddSampleLog(Workspace=current_ws_wIS,LogName='Ei',LogText='3.0',LogType='Number') |
|---|
| 97 | |
|---|
| 98 | #### Add iformation which is not stored in the nxspe file |
|---|
| 99 | # Add UB matrix (lattice and the beam direction) |
|---|
| 100 | SetUB(Workspace=current_ws_wIS,a='1.4165',b='1.4165',c='1.4165',u='1,0,0',v='0,1,0') |
|---|
| 101 | # Add crystal rotation (assume rotation abgle Psi=5*n where n is file number. Define list of angles if this is not correct |
|---|
| 102 | AddSampleLog(Workspace=current_ws_wIS,LogName='Psi',LogText=str(5*n)+'.',LogType='Number') # --correct Psi value may be already in nxspe file. This operation is then unnecessary |
|---|
| 103 | # set crystal rotation |
|---|
| 104 | SetGoniometer(Workspace=current_ws_wIS,Axis0='Psi,0,1,0,1') |
|---|
| 105 | |
|---|
| 106 | # Convert to MD |
|---|
| 107 | pars_wIS['InputWorkspace']=current_ws_wIS; |
|---|
| 108 | md_ws_wIS=ConvertToMD(**pars_wIS) |
|---|
| 109 | |
|---|
| 110 | # save MD for further usage -- disabled in test script |
|---|
| 111 | #SaveMD(md_ws,Filename=target); |
|---|
| 112 | #DeleteWorkspace(md_ws); # delete intermediate workspace to save memory |
|---|
| 113 | DeleteWorkspace(current_ws_wIS); |
|---|
| 114 | |
|---|
| 115 | # add the file name of the file to combine |
|---|
| 116 | if (len(MD_FilesList_wIS) == 0): |
|---|
| 117 | MD_FilesList_wIS = target_wIS; |
|---|
| 118 | else: |
|---|
| 119 | MD_FilesList_wIS=MD_FilesList_wIS+','+target_wIS; |
|---|