| 1 | def runAlgorithm(): |
|---|
| 2 | workspace_name = "POLREF00004699" |
|---|
| 3 | workspace_nexus_file = workspace_name + ".nxs" |
|---|
| 4 | |
|---|
| 5 | PIX=1.1E-3 #m |
|---|
| 6 | SC=75 |
|---|
| 7 | avgDB=29 |
|---|
| 8 | Load(Filename=workspace_nexus_file,OutputWorkspace=workspace_name) |
|---|
| 9 | X=mtd[workspace_name] |
|---|
| 10 | X = ConvertUnits(InputWorkspace=X,Target="Wavelength",AlignBins="1") |
|---|
| 11 | # Reference intensity to normalise by |
|---|
| 12 | CropWorkspace(InputWorkspace=X,OutputWorkspace='Io',XMin=0.8,XMax=14.5,StartWorkspaceIndex=2,EndWorkspaceIndex=2) |
|---|
| 13 | # Crop out transmission and noisy data |
|---|
| 14 | CropWorkspace(InputWorkspace=X,OutputWorkspace='D',XMin=0.8,XMax=14.5,StartWorkspaceIndex=3) |
|---|
| 15 | Io=mtd['Io'] |
|---|
| 16 | D=mtd['D'] |
|---|
| 17 | |
|---|
| 18 | # Peform the normaisation step |
|---|
| 19 | Divide(LHSWorkspace=D,RHSWorkspace=Io,OutputWorkspace='I', |
|---|
| 20 | AllowDifferentNumberSpectra='1',ClearRHSWorkspace='1') |
|---|
| 21 | I=mtd['I'][0] |
|---|
| 22 | |
|---|
| 23 | # Automatically determine the SC and averageDB |
|---|
| 24 | FindReflectometryLines(InputWorkspace=I, StartWavelength=10, OutputWorkspace='spectrum_numbers') |
|---|
| 25 | spectrum_table = mtd['spectrum_numbers'] |
|---|
| 26 | |
|---|
| 27 | # Move the detector so that the detector channel matching the reflected beam is at 0,0 |
|---|
| 28 | MoveInstrumentComponent(Workspace=I,ComponentName="lineardetector",X=0,Y=0,Z=-PIX*( (SC-avgDB)/2.0 +avgDB) ) |
|---|
| 29 | |
|---|
| 30 | # Should now have signed theta vs Lambda |
|---|
| 31 | ConvertSpectrumAxis(InputWorkspace=I,OutputWorkspace='SignedTheta_vs_Wavelength',Target='signed_theta') |
|---|
| 32 | |
|---|
| 33 | # Check that signed two theta is being caluclated correctly (not normalised) |
|---|
| 34 | ws1 = mtd['SignedTheta_vs_Wavelength'] |
|---|
| 35 | upperHistogram = ws1.getNumberHistograms()-1 |
|---|
| 36 | # MD transformations |
|---|
| 37 | ConvertToReflectometryQ(InputWorkspace='SignedTheta_vs_Wavelength',OutputWorkspace='QxQyMD',OutputDimensions='Q (lab frame)', Extents='-0.0005,0.0005,0,0.12') |
|---|
| 38 | ConvertToReflectometryQ(InputWorkspace='SignedTheta_vs_Wavelength',OutputWorkspace='QxQy2D',OutputDimensions='Q (lab frame)', NumberBinsQx=100, NumberBinsQz=100, OutputAsMDWorkspace=False, Extents='-0.0005,0.0005,0,0.12') |
|---|
| 39 | |
|---|
| 40 | ConvertToReflectometryQ(InputWorkspace='SignedTheta_vs_Wavelength',OutputWorkspace='KiKfMD',OutputDimensions='K (incident, final)', Extents='0,0.05,0,0.05') |
|---|
| 41 | ConvertToReflectometryQ(InputWorkspace='SignedTheta_vs_Wavelength',OutputWorkspace='KiKf2D',OutputDimensions='K (incident, final)', Extents='0,0.05,0,0.05', NumberBinsQx=100, NumberBinsQz=100, OutputAsMDWorkspace=False) |
|---|
| 42 | |
|---|
| 43 | ConvertToReflectometryQ(InputWorkspace='SignedTheta_vs_Wavelength',OutputWorkspace='PiPfMD',OutputDimensions='P (lab frame)', Extents='0,0.1,-0.02,0.15') |
|---|
| 44 | ConvertToReflectometryQ(InputWorkspace='SignedTheta_vs_Wavelength',OutputWorkspace='PiPf2D',OutputDimensions='P (lab frame)', Extents='0,0.1,-0.02,0.15', NumberBinsQx=100, NumberBinsQz=100, OutputAsMDWorkspace=False) |
|---|
| 45 | |
|---|
| 46 | BinMD(InputWorkspace='QxQyMD',AxisAligned='0',BasisVector0='Qx,(Ang^-1),1,0',BasisVector1='Qz,(Ang^-1),0,1',OutputExtents='-0.0005,0.0005,0,0.12',OutputBins='100,100',Parallel='1',OutputWorkspace='QxQy_rebinned') |
|---|
| 47 | BinMD(InputWorkspace='KiKfMD',AxisAligned='0',BasisVector0='Ki,(Ang^-1),1,0',BasisVector1='Kf,(Ang^-1),0,1',OutputExtents='0,0.05,0,0.05',OutputBins='100,100',Parallel='1',OutputWorkspace='KiKf_rebinned') |
|---|
| 48 | BinMD(InputWorkspace='PiPfMD',AxisAligned='0',BasisVector0='Pz_i + Pz_f,(Ang^-1),1,0',BasisVector1='Pz_i - Pz_f,(Ang^-1),0,1',OutputExtents='0,0.1,-0.02,0.15',OutputBins='100,100',Parallel='1',OutputWorkspace='PiPf_rebinned') |
|---|
| 49 | |
|---|
| 50 | runAlgorithm() |
|---|
| 51 | |
|---|
| 52 | #Comparision 1 |
|---|
| 53 | plotSlice(source='QxQy_rebinned', colormin=2e2, colormax=3e9, colorscalelog=True) |
|---|
| 54 | plotSlice(source='QxQy2D', colormin=2e2, colormax=3e9, colorscalelog=True) |
|---|
| 55 | |
|---|
| 56 | #Comparision 2 |
|---|
| 57 | plotSlice(source='KiKf_rebinned', colormin=2e2, colormax=3e9, colorscalelog=True) |
|---|
| 58 | plotSlice(source='KiKf2D', colormin=2e2, colormax=3e9, colorscalelog=True) |
|---|
| 59 | |
|---|
| 60 | #Comparision 3 |
|---|
| 61 | plotSlice(source='PiPf_rebinned', colormin=2e2, colormax=3e9, colorscalelog=True) |
|---|
| 62 | plotSlice(source='PiPf2D', colormin=2e2, colormax=3e9, colorscalelog=True) |
|---|