Ticket #1688: AbsorptionTests.py

File AbsorptionTests.py, 3.0 KB (added by Martyn Gigg, 10 years ago)
Line 
1raw_wksp = LoadRaw('C:/Mantid/trunk/Test/Data/HRP39191.raw','hrpd39191').workspace()
2ConvertUnits(raw_wksp,raw_wksp, 'Wavelength')
3samplePos = raw_wksp.getInstrument().getSample().getPos()
4
5slabWidthInCM = 1.8
6slabHeightInCM = 2.3
7slabThicknessInCM = 1.5
8
9slabWidthInM = slabWidthInCM * 0.01
10slabHeightInM = slabHeightInCM * 0.01
11slabThicknessInM = slabThicknessInCM * 0.01
12
13szX = (slabWidthInM/2) + samplePos.getX()
14szY = (slabHeightInM/2) + samplePos.getY()
15szZ = (slabThicknessInM/2) + samplePos.getZ()
16
17sampleXML = " <cuboid id=\"sample-shape\"> " + \
18"<left-front-bottom-point x=\"" + str(szX) + "\" y=\"" + str(-szY) + "\" z=\"" + str(-szZ) + "\"  /> "  + \
19"<left-front-top-point  x=\"" +str(szX) + "\" y=\"" + str(szY) + "\" z=\"" + str(-szZ) + "\"  /> " + \
20"<left-back-bottom-point  x=\"" + str(szX) + "\" y=\"" + str(-szY) + "\" z=\"" + str(szZ) + "\"  /> " + \
21"<right-front-bottom-point  x=\"" + str(-szX) + "\" y=\"" + str(-szY) + "\" z=\"" + str(-szZ) + "\"  /> " +\
22"</cuboid>"
23
24gaugeWidthInCM = 1.3
25gaugeHeightInCM = 2.1 
26gaugeThicknessInCM = 1.2
27
28gaugeWidthInM = gaugeWidthInCM * 0.01
29gaugeHeightInM = gaugeHeightInCM * 0.01
30gaugeThicknessInM = gaugeThicknessInCM * 0.01
31
32gzX = (gaugeWidthInM/2) + samplePos.getX()
33gzY = (gaugeHeightInM/2) + samplePos.getY()
34gzZ = (gaugeThicknessInM/2) + samplePos.getZ()
35       
36gaugeXML = " <cuboid id=\"gauge-shape\"> " + \
37"<left-front-bottom-point x=\"" + str(gzX) + "\" y=\"" + str(-gzY) + "\" z=\"" + str(-gzZ) + "\"  /> "  + \
38"<left-front-top-point  x=\"" +str(gzX) + "\" y=\"" + str(gzY) + "\" z=\"" + str(-gzZ) + "\"  /> " + \
39"<left-back-bottom-point  x=\"" + str(gzX) + "\" y=\"" + str(-gzY) + "\" z=\"" + str(gzZ) + "\"  /> " + \
40"<right-front-bottom-point  x=\"" + str(-gzX) + "\" y=\"" + str(-gzY) + "\" z=\"" + str(-gzZ) + "\"  /> " +\
41"</cuboid>"
42
43# Define the sample shape and gauge volume on the workspace
44CreateSampleShape(raw_wksp, sampleXML)
45DefineGaugeVolume(raw_wksp, gaugeXML)
46
47attenXsec = 6.52
48scatterXsec = 19.876
49numberDensity = 0.0093
50npoints = 100
51
52AbsorptionCorrection(raw_wksp, 'anyshape_correction', attenXsec,scatterXsec,numberDensity,npoints)
53
54# Should equal CuboidGaugeVolumeAbsorption with same shape = FlatPlateAbsorption
55CuboidGaugeVolumeAbsorption(raw_wksp, 'cuboidgauge_correction', attenXsec,scatterXsec,numberDensity,gaugeHeightInCM,gaugeWidthInCM,gaugeThicknessInCM,npoints)
56
57checker = CheckWorkspacesMatch('anyshape_correction', 'cuboidgauge_correction', Tolerance=0.001)
58match = checker.getPropertyValue('Result')
59print 'Checking AnyShape against CuboidGaugeVolume:',match
60
61FlatPlateAbsorption(raw_wksp, 'flatplate_correction', attenXsec,scatterXsec,numberDensity,slabHeightInCM,slabWidthInCM,slabThicknessInCM,npoints)
62checker = CheckWorkspacesMatch('flatplate_correction', 'cuboidgauge_correction', Tolerance=0.001)
63match = checker.getPropertyValue('Result')
64print 'Checking FlatPlate against CuboidGaugeVolume:',match
65
66checker = CheckWorkspacesMatch('flatplate_correction', 'anyshape_correction', Tolerance=0.001)
67match = checker.getPropertyValue('Result')
68print 'Checking FlatPlate against AnyShape:',match