Commit 114b5b78 authored by Kendrick, Coleman's avatar Kendrick, Coleman
Browse files

Update test workspace naming

parent e3aede1a
......@@ -20,17 +20,18 @@ class HB3ADetectorPeaksTest(unittest.TestCase):
DeleteWorkspace("data")
def testIntegratePeaksFitted(self):
data = mtd["data"]
# ChiSq is larger than maximum
peaks = HB3AIntegrateDetectorPeaks("data", ChiSqMax=10, ApplyLorentz=False, OptimizeQVector=False)
peaks = HB3AIntegrateDetectorPeaks(data, ChiSqMax=10, ApplyLorentz=False, OptimizeQVector=False)
self.assertEqual(peaks.getNumberPeaks(), 0)
# Signal/Noise ratio is lower than requested
peaks = HB3AIntegrateDetectorPeaks("data", ChiSqMax=100, SignalNoiseMin=100,
peaks = HB3AIntegrateDetectorPeaks(data, ChiSqMax=100, SignalNoiseMin=100,
ApplyLorentz=False, OptimizeQVector=False)
self.assertEqual(peaks.getNumberPeaks(), 0)
# Actually fit peak in this one
peaks = HB3AIntegrateDetectorPeaks("data", ChiSqMax=100, ApplyLorentz=False, OptimizeQVector=False)
peaks = HB3AIntegrateDetectorPeaks(data, ChiSqMax=100, ApplyLorentz=False, OptimizeQVector=False)
self.assertEqual(peaks.getNumberPeaks(), 1)
peak0 = peaks.getPeak(0)
......@@ -42,15 +43,15 @@ class HB3ADetectorPeaksTest(unittest.TestCase):
self.assertAlmostEqual(peak0.getWavelength(), 1.008)
self.assertAlmostEqual(peak0.getAzimuthal(), -np.pi, delta=2e-5)
self.assertAlmostEqual(peak0.getScattering(),
np.deg2rad(mtd["data"].getExperimentInfo(0).run()['2theta'].value[0]), delta=1e-5)
np.deg2rad(data.getExperimentInfo(0).run()['2theta'].value[0]), delta=1e-5)
q_sample = peak0.getQSampleFrame()
expected_q_sample = mtd["data"].getExperimentInfo(0).sample().getOrientedLattice().qFromHKL(peak0.getHKL())
expected_q_sample = data.getExperimentInfo(0).sample().getOrientedLattice().qFromHKL(peak0.getHKL())
for i in range(3):
self.assertAlmostEqual(q_sample[i], expected_q_sample[i])
# Try with larger ROI, should get slightly different intensity
peaks = HB3AIntegrateDetectorPeaks("data", ChiSqMax=100, LowerLeft=[0,0], UpperRight=[512,512],
peaks = HB3AIntegrateDetectorPeaks(data, ChiSqMax=100, LowerLeft=[0,0], UpperRight=[512,512],
ApplyLorentz=False, OptimizeQVector=False)
self.assertEqual(peaks.getNumberPeaks(), 1)
......@@ -63,30 +64,30 @@ class HB3ADetectorPeaksTest(unittest.TestCase):
self.assertAlmostEqual(peak0.getWavelength(), 1.008)
self.assertAlmostEqual(peak0.getAzimuthal(), -np.pi, delta=2e-5)
self.assertAlmostEqual(peak0.getScattering(),
np.deg2rad(mtd["data"].getExperimentInfo(0).run()['2theta'].value[0]), delta=1e-5)
np.deg2rad(data.getExperimentInfo(0).run()['2theta'].value[0]), delta=1e-5)
q_sample = peak0.getQSampleFrame()
for i in range(3):
self.assertAlmostEqual(q_sample[i], expected_q_sample[i])
# Lorentz correction should scale the intensity by `sin(2theta)`
peaks = HB3AIntegrateDetectorPeaks("data", ChiSqMax=100, ApplyLorentz=True, OptimizeQVector=False)
peaks = HB3AIntegrateDetectorPeaks(data, ChiSqMax=100, ApplyLorentz=True, OptimizeQVector=False)
self.assertEqual(peaks.getNumberPeaks(), 1)
peak0 = peaks.getPeak(0)
self.assertAlmostEqual(peak0.getScattering(),
np.deg2rad(mtd["data"].getExperimentInfo(0).run()['2theta'].value[0]), delta=1e-5)
np.deg2rad(data.getExperimentInfo(0).run()['2theta'].value[0]), delta=1e-5)
self.assertAlmostEqual(peak0.getIntensity(),
961.6164 * np.sin(np.deg2rad(mtd["data"].getExperimentInfo(0).run()['2theta'].value[0])),
961.6164 * np.sin(np.deg2rad(data.getExperimentInfo(0).run()['2theta'].value[0])),
delta=1e-2)
self.assertAlmostEqual(peak0.getSigmaIntensity(),
10.479567 * np.sin(np.deg2rad(mtd["data"].getExperimentInfo(0).run()['2theta'].value[0])),
10.479567 * np.sin(np.deg2rad(data.getExperimentInfo(0).run()['2theta'].value[0])),
delta=2e-2)
# Optimize Q vector, will change Q-sample but the integration
# should be the same except the Lorentz correction since the
# scattering angle is changed
peaks = HB3AIntegrateDetectorPeaks("data", ChiSqMax=100, ApplyLorentz=True, OptimizeQVector=True)
peaks = HB3AIntegrateDetectorPeaks(data, ChiSqMax=100, ApplyLorentz=True, OptimizeQVector=True)
self.assertEqual(peaks.getNumberPeaks(), 1)
peak0 = peaks.getPeak(0)
......@@ -98,7 +99,7 @@ class HB3ADetectorPeaksTest(unittest.TestCase):
self.assertNotAlmostEqual(q_sample[i], expected_q_sample[i])
# Try StartX and EndX, should just change the peak intensity slightly
peaks = HB3AIntegrateDetectorPeaks("data", ChiSqMax=100, ApplyLorentz=False, OptimizeQVector=False,
peaks = HB3AIntegrateDetectorPeaks(data, ChiSqMax=100, ApplyLorentz=False, OptimizeQVector=False,
StartX=12.6, EndX=100)
self.assertEqual(peaks.getNumberPeaks(), 1)
peak0 = peaks.getPeak(0)
......@@ -111,7 +112,8 @@ class HB3ADetectorPeaksTest(unittest.TestCase):
DeleteWorkspace(peaks)
def testIntegratePeaksCounts(self):
peaks = HB3AIntegrateDetectorPeaks("data", Method="Counts", ApplyLorentz=False, OptimizeQVector=False)
data = mtd["data"]
peaks = HB3AIntegrateDetectorPeaks(data, Method="Counts", ApplyLorentz=False, OptimizeQVector=False)
self.assertEqual(peaks.getNumberPeaks(), 1)
peak0 = peaks.getPeak(0)
......@@ -123,28 +125,28 @@ class HB3ADetectorPeaksTest(unittest.TestCase):
self.assertAlmostEqual(peak0.getWavelength(), 1.008)
self.assertAlmostEqual(peak0.getAzimuthal(), -np.pi, delta=2e-5)
self.assertAlmostEqual(peak0.getScattering(),
np.deg2rad(mtd["data"].getExperimentInfo(0).run()['2theta'].value[0]), delta=1e-5)
np.deg2rad(data.getExperimentInfo(0).run()['2theta'].value[0]), delta=1e-5)
q_sample = peak0.getQSampleFrame()
expected_q_sample = mtd["data"].getExperimentInfo(0).sample().getOrientedLattice().qFromHKL(peak0.getHKL())
expected_q_sample = data.getExperimentInfo(0).sample().getOrientedLattice().qFromHKL(peak0.getHKL())
for i in range(3):
self.assertAlmostEqual(q_sample[i], expected_q_sample[i])
# Lorentz correction should scale the intensity by `sin(2theta)`
peaks = HB3AIntegrateDetectorPeaks("data", Method="Counts", ApplyLorentz=True, OptimizeQVector=False)
peaks = HB3AIntegrateDetectorPeaks(data, Method="Counts", ApplyLorentz=True, OptimizeQVector=False)
self.assertEqual(peaks.getNumberPeaks(), 1)
peak0 = peaks.getPeak(0)
self.assertAlmostEqual(peak0.getScattering(),
np.deg2rad(mtd["data"].getExperimentInfo(0).run()['2theta'].value[0]), delta=1e-5)
np.deg2rad(data.getExperimentInfo(0).run()['2theta'].value[0]), delta=1e-5)
self.assertAlmostEqual(peak0.getIntensity(),
932.24967 * np.sin(np.deg2rad(mtd["data"].getExperimentInfo(0).run()['2theta'].value[0])),
932.24967 * np.sin(np.deg2rad(data.getExperimentInfo(0).run()['2theta'].value[0])),
delta=1e-2)
self.assertAlmostEqual(peak0.getSigmaIntensity(),
29.10343 * np.sin(np.deg2rad(mtd["data"].getExperimentInfo(0).run()['2theta'].value[0])),
29.10343 * np.sin(np.deg2rad(data.getExperimentInfo(0).run()['2theta'].value[0])),
delta=2e-2)
peaks = HB3AIntegrateDetectorPeaks("data", Method="Counts", ApplyLorentz=True, OptimizeQVector=True)
peaks = HB3AIntegrateDetectorPeaks(data, Method="Counts", ApplyLorentz=True, OptimizeQVector=True)
self.assertEqual(peaks.getNumberPeaks(), 1)
peak0 = peaks.getPeak(0)
......@@ -158,7 +160,8 @@ class HB3ADetectorPeaksTest(unittest.TestCase):
DeleteWorkspace(peaks)
def testIntegratePeaksCountsWithFitting(self):
peaks = HB3AIntegrateDetectorPeaks("data", Method="CountsWithFitting", ApplyLorentz=False, OptimizeQVector=False,
data = mtd["data"]
peaks = HB3AIntegrateDetectorPeaks(data, Method="CountsWithFitting", ApplyLorentz=False, OptimizeQVector=False,
ChiSqMax=100)
self.assertEqual(peaks.getNumberPeaks(), 1)
......@@ -171,29 +174,29 @@ class HB3ADetectorPeaksTest(unittest.TestCase):
self.assertAlmostEqual(peak0.getWavelength(), 1.008)
self.assertAlmostEqual(peak0.getAzimuthal(), -np.pi, delta=2e-5)
self.assertAlmostEqual(peak0.getScattering(),
np.deg2rad(mtd["data"].getExperimentInfo(0).run()['2theta'].value[0]), delta=1e-5)
np.deg2rad(data.getExperimentInfo(0).run()['2theta'].value[0]), delta=1e-5)
q_sample = peak0.getQSampleFrame()
expected_q_sample = mtd["data"].getExperimentInfo(0).sample().getOrientedLattice().qFromHKL(peak0.getHKL())
expected_q_sample = data.getExperimentInfo(0).sample().getOrientedLattice().qFromHKL(peak0.getHKL())
for i in range(3):
self.assertAlmostEqual(q_sample[i], expected_q_sample[i])
# Lorentz correction should scale the intensity by `sin(2theta)`
peaks = HB3AIntegrateDetectorPeaks("data", Method="CountsWithFitting", ApplyLorentz=True, OptimizeQVector=False,
peaks = HB3AIntegrateDetectorPeaks(data, Method="CountsWithFitting", ApplyLorentz=True, OptimizeQVector=False,
ChiSqMax=100)
self.assertEqual(peaks.getNumberPeaks(), 1)
peak0 = peaks.getPeak(0)
self.assertAlmostEqual(peak0.getScattering(),
np.deg2rad(mtd["data"].getExperimentInfo(0).run()['2theta'].value[0]), delta=1e-5)
np.deg2rad(data.getExperimentInfo(0).run()['2theta'].value[0]), delta=1e-5)
self.assertAlmostEqual(peak0.getIntensity(),
969.778546 * np.sin(np.deg2rad(mtd["data"].getExperimentInfo(0).run()['2theta'].value[0])),
969.778546 * np.sin(np.deg2rad(data.getExperimentInfo(0).run()['2theta'].value[0])),
delta=1e-2)
self.assertAlmostEqual(peak0.getSigmaIntensity(),
24.776354 * np.sin(np.deg2rad(mtd["data"].getExperimentInfo(0).run()['2theta'].value[0])),
24.776354 * np.sin(np.deg2rad(data.getExperimentInfo(0).run()['2theta'].value[0])),
delta=2e-2)
peaks = HB3AIntegrateDetectorPeaks("data", Method="CountsWithFitting", ApplyLorentz=True, OptimizeQVector=True,
peaks = HB3AIntegrateDetectorPeaks(data, Method="CountsWithFitting", ApplyLorentz=True, OptimizeQVector=True,
ChiSqMax=100)
self.assertEqual(peaks.getNumberPeaks(), 1)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment