Commit 995c0b79 authored by Kendrick, Coleman's avatar Kendrick, Coleman Committed by Peterson, Peter
Browse files

Reduced unit test data

parent f7112d96
......@@ -11,7 +11,7 @@ from mantid.simpleapi import ClearUB, HasUB, FindPeaksMD, HB3AAdjustSampleNorm,
class HB3AFindPeaksTest(unittest.TestCase):
_files = ["HB3A_exp0724_scan0182.nxs", "HB3A_exp0724_scan0183.nxs"]
_data_ws = []
_data_ws = None
@classmethod
def tearDownClass(cls):
......@@ -19,64 +19,66 @@ class HB3AFindPeaksTest(unittest.TestCase):
def __load_data(self):
# Loads in the testing files to workspaces to reduce testing overhead for multiple tests
if len(self._data_ws) == 0:
for scan in self._files:
name = scan[scan.find("scan"):].rstrip(".nxs")
HB3AAdjustSampleNorm(Filename=scan, OutputWorkspace=name)
self._data_ws.append(name)
if self._data_ws is None:
name = "HB3A_exp0724"
HB3AAdjustSampleNorm(Filename=",".join(f for f in self._files), OutputWorkspace=name)
self._data_ws = name
def test_find_ub_peaks(self):
# Make sure that this algorithm gives similar results to FindPeaksMD and creates a UB matrix
self.__load_data()
for scan in self._data_ws:
# Remove the UB matrix from the input data
ClearUB(mtd[scan])
# Remove the UB matrix from the input data
ClearUB(mtd[self._data_ws])
peaks_md = FindPeaksMD(InputWorkspace=mtd[scan],
PeakDistanceThreshold=0.25,
DensityThresholdFactor=2000,
CalculateGoniometerForCW=True,
Wavelength=1.008,
FlipX=True,
InnerGoniometer=True)
peaks_md = FindPeaksMD(InputWorkspace=mtd[self._data_ws],
PeakDistanceThreshold=0.25,
DensityThresholdFactor=2000,
CalculateGoniometerForCW=True,
Wavelength=1.008,
FlipX=True,
InnerGoniometer=True)
peaks = HB3AFindPeaks(InputWorkspace=mtd[scan], CellType="Orthorhombic", Centering="F")
# Verify that the algorithm found a UB matrix
self.assertTrue(HasUB(peaks))
peaks = HB3AFindPeaks(InputWorkspace=mtd[self._data_ws],
CellType="Orthorhombic",
Centering="F")
self.assertEqual(peaks_md.getNumberPeaks(), peaks.getNumberPeaks())
# Verify that the algorithm found a UB matrix
for i in range(peaks.size()):
self.assertTrue(HasUB(peaks[i]))
self.assertEqual(peaks_md[i].getNumberPeaks(), peaks[i].getNumberPeaks())
def test_find_ub_lattice(self):
# Test if the algorithm finds a UB matrix based on given lattice parameters
self.__load_data()
for scan in self._data_ws:
# Remove the UB matrix from the input data
ClearUB(mtd[scan])
peaks = HB3AFindPeaks(InputWorkspace=mtd[scan],
CellType="Orthorhombic",
Centering="F",
UseLattice=True,
LatticeA=5.2384,
LatticeB=5.2384,
LatticeC=19.6519,
LatticeAlpha=90.0,
LatticeBeta=90.0,
LatticeGamma=90.0)
# Verify that the algorithm found a UB matrix from lattice params
self.assertTrue(HasUB(peaks))
# Remove the UB matrix from the input data
ClearUB(mtd[self._data_ws])
peaks = HB3AFindPeaks(InputWorkspace=mtd[self._data_ws],
CellType="Orthorhombic",
Centering="F",
UseLattice=True,
LatticeA=5.2384,
LatticeB=5.2384,
LatticeC=19.6519,
LatticeAlpha=90.0,
LatticeBeta=90.0,
LatticeGamma=90.0)
# Verify that the algorithm found a UB matrix from lattice params
for ws in peaks:
self.assertTrue(HasUB(ws))
# Check that peaks were actually found
self.assertTrue(peaks.getNumberPeaks() > 0)
self.assertTrue(ws.getNumberPeaks() > 0)
def test_find_ub_van_norm(self):
# Test with vanadium normalization to make sure UB matrix and peaks can still be found
if self._data_ws is not None:
mtd.clear()
norm = HB3AAdjustSampleNorm(Filename=self._files[0],
VanadiumFile="HB3A_exp0722_scan0220.nxs")
peaks = HB3AFindPeaks(InputWorkspace=norm,
......
1a86584be1e96495299c2a86efcad436
08cdf46f22b2d23a6da7336c8bfdeb8d
1909e4b0fd283d9c6d03ddf606f924a3
f6d5e8a52af6f0ec08bbf81afad6142c
Supports Markdown
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