Skip to content
Snippets Groups Projects
Commit 3d2b09ce authored by Kendrick, Coleman's avatar Kendrick, Coleman
Browse files

Shift starting detector id in extract peak info

parent 3fdc1ce4
No related branches found
No related tags found
No related merge requests found
# Mantid Repository : https://github.com/mantidproject/mantid
#
# Copyright © 2021 ISIS Rutherford Appleton Laboratory UKRI,
# NScD Oak Ridge National Laboratory, European Spallation Source,
# Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
# SPDX - License - Identifier: GPL - 3.0 +
from mantid.plots.resampling_image.samplingimage import imshow_sampling from mantid.plots.resampling_image.samplingimage import imshow_sampling
from mantid.plots.datafunctions import get_axes_labels from mantid.plots.datafunctions import get_axes_labels
from mantid.simpleapi import CalculateDIFC, LoadDiffCal, mtd from mantid.simpleapi import CalculateDIFC, LoadDiffCal, mtd
...@@ -374,9 +381,10 @@ def extract_peak_info(wksp, outputname: str, peak_position: float): ...@@ -374,9 +381,10 @@ def extract_peak_info(wksp, outputname: str, peak_position: float):
x = single.dataX(0) x = single.dataX(0)
y = single.dataY(0) y = single.dataY(0)
e = single.dataE(0) e = single.dataE(0)
start_detid = np.searchsorted(detids, 0)
for wksp_index in range(numSpec): for wksp_index in range(numSpec):
if have_detids: if have_detids:
x[wksp_index] = detids[wksp_index] x[wksp_index] = detids[start_detid + wksp_index]
else: else:
x[wksp_index] = wksp_index x[wksp_index] = wksp_index
y[wksp_index] = wksp.readY(wksp_index)[peak_index] y[wksp_index] = wksp.readY(wksp_index)[peak_index]
......
...@@ -4,9 +4,10 @@ set(TEST_PY_FILES ...@@ -4,9 +4,10 @@ set(TEST_PY_FILES
test_ideal_tube.py test_ideal_tube.py
test_tube.py test_tube.py
test_tube_calib.py test_tube_calib.py
tofpd/test_diagnostics.py
) )
add_subdirectory(tofpd)
check_tests_valid(${CMAKE_CURRENT_SOURCE_DIR} ${TEST_PY_FILES}) check_tests_valid(${CMAKE_CURRENT_SOURCE_DIR} ${TEST_PY_FILES})
pyunittest_add_test(${CMAKE_CURRENT_SOURCE_DIR} python.Calibration pyunittest_add_test(${CMAKE_CURRENT_SOURCE_DIR} python.Calibration
......
# Unit tests for Calibration.tofpd
set(TEST_PY_FILES
test_diagnostics.py
)
check_tests_valid(${CMAKE_CURRENT_SOURCE_DIR} ${TEST_PY_FILES})
pyunittest_add_test(${CMAKE_CURRENT_SOURCE_DIR} python.Calibration.tofpd
${TEST_PY_FILES})
...@@ -30,20 +30,24 @@ class TestDiagnostics(unittest.TestCase): ...@@ -30,20 +30,24 @@ class TestDiagnostics(unittest.TestCase):
test_strain = diagnostics.collect_peaks('diag_dspacing', 'test_strain', infotype='strain') test_strain = diagnostics.collect_peaks('diag_dspacing', 'test_strain', infotype='strain')
result = CompareWorkspaces(test_strain, "strain", Tolerance=1e-6) result = CompareWorkspaces(test_strain, "strain", Tolerance=1e-6)
self.assertTrue(result) self.assertTrue(result)
DeleteWorkspaces(test_strain)
def test_collect_peaks_diff(self): def test_collect_peaks_diff(self):
test_diff = diagnostics.collect_peaks('diag_dspacing', 'test_diff', infotype='difference') test_diff = diagnostics.collect_peaks('diag_dspacing', 'test_diff', infotype='difference')
result = CompareWorkspaces(test_diff, "difference", Tolerance=1e-6) result = CompareWorkspaces(test_diff, "difference", Tolerance=1e-6)
self.assertTrue(result) self.assertTrue(result)
DeleteWorkspaces(test_diff)
def test_extract_peak_info(self): def test_extract_peak_info(self):
test_single_strain = diagnostics.extract_peak_info('strain', 'test_single_strain', self.PEAK) test_single_strain = diagnostics.extract_peak_info('strain', 'test_single_strain', self.PEAK)
result = CompareWorkspaces(test_single_strain, "single_strain", Tolerance=1e-6) result = CompareWorkspaces(test_single_strain, "single_strain", Tolerance=1e-6)
self.assertTrue(result) self.assertTrue(result)
DeleteWorkspaces(test_single_strain)
test_single_diff = diagnostics.extract_peak_info('difference', 'test_single_diff', self.PEAK) test_single_diff = diagnostics.extract_peak_info('difference', 'test_single_diff', self.PEAK)
result = CompareWorkspaces(test_single_diff, "single_diff", Tolerance=1e-6) result = CompareWorkspaces(test_single_diff, "single_diff", Tolerance=1e-6)
self.assertTrue(result) self.assertTrue(result)
DeleteWorkspaces(test_single_diff)
if __name__ == '__main__': if __name__ == '__main__':
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment