From b310a202aef3577de0a913fcb1c259e7a3918ede Mon Sep 17 00:00:00 2001 From: Pete Peterson Date: Fri, 16 Aug 2024 12:12:55 -0400 Subject: [PATCH 1/3] Change tofmin to be at the lowest event's tof Since histogramming is inclusive on the lower bound, there is need to shift the lower boundary to the left. The effect of the current implementation is that when the smallest TOF is <1, the workspace histogram started at negative values which makes a mess for log (re)binning. --- Framework/DataHandling/src/LoadEventNexus.cpp | 4 ++-- Framework/DataHandling/test/LoadEventNexusTest.h | 2 +- .../release/v6.11.0/Framework/Algorithms/Bugfixes/37815.rst | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) create mode 100644 docs/source/release/v6.11.0/Framework/Algorithms/Bugfixes/37815.rst diff --git a/Framework/DataHandling/src/LoadEventNexus.cpp b/Framework/DataHandling/src/LoadEventNexus.cpp index 6b6700a5571f..d9bb6549a65d 100644 --- a/Framework/DataHandling/src/LoadEventNexus.cpp +++ b/Framework/DataHandling/src/LoadEventNexus.cpp @@ -1271,8 +1271,8 @@ void LoadEventNexus::loadEvents(API::Progress *const prog, const bool monitors) if (eventsLoaded > 0) { int nBins = getProperty("NumberOfBins"); auto binEdgesVec = std::vector(nBins + 1); - binEdgesVec[0] = shortest_tof - 1; - binEdgesVec[nBins] = longest_tof + 1; + binEdgesVec[0] = shortest_tof; // left edge is inclusive + binEdgesVec[nBins] = longest_tof + 1; // right edge is exclusive double binStep = (binEdgesVec[nBins] - binEdgesVec[0]) / nBins; for (int binIndex = 1; binIndex < nBins; binIndex++) { binEdgesVec[binIndex] = binEdgesVec[0] + (binStep * binIndex); diff --git a/Framework/DataHandling/test/LoadEventNexusTest.h b/Framework/DataHandling/test/LoadEventNexusTest.h index 2dae11d38b58..4313a70d277c 100644 --- a/Framework/DataHandling/test/LoadEventNexusTest.h +++ b/Framework/DataHandling/test/LoadEventNexusTest.h @@ -538,7 +538,7 @@ class LoadEventNexusTest : public CxxTest::TestSuite { TS_ASSERT_EQUALS(WS->getNumberEvents(), 112266); // TOF limits found. There is a pad of +-1 given around the actual TOF // founds. - TS_ASSERT_DELTA((*WS->refX(0))[0], 44162.6, 0.05); + TS_ASSERT_DELTA((*WS->refX(0))[0], 44163.6, 0.05); TS_ASSERT_DELTA((*WS->refX(0))[1], 60830.2, 0.05); // Valid spectrum info TS_ASSERT_EQUALS(WS->getSpectrum(0).getSpectrumNo(), 1); diff --git a/docs/source/release/v6.11.0/Framework/Algorithms/Bugfixes/37815.rst b/docs/source/release/v6.11.0/Framework/Algorithms/Bugfixes/37815.rst new file mode 100644 index 000000000000..d8b8a554a019 --- /dev/null +++ b/docs/source/release/v6.11.0/Framework/Algorithms/Bugfixes/37815.rst @@ -0,0 +1 @@ +- Modify :ref:`LoadEventNexus ` so the minimum histogram bin edge is equal to the lowest time-of-flight event rather than one less. The effect is that there is no longer negative bin edges unless there is actually a negative time-of-flight in the data. From 1b79e1442638b5ff7452a5731a60e3bc8d58d56b Mon Sep 17 00:00:00 2001 From: Pete Peterson Date: Fri, 16 Aug 2024 16:34:15 -0400 Subject: [PATCH 2/3] Updating reference with small changes --- Testing/Data/SystemTest/3132_Orthorhombic_P.integrate.nxs.md5 | 2 +- Testing/Data/SystemTest/PowderReduceP2D_reference.p2d.md5 | 2 +- .../reference/ReflectometryApplyFloodWorkspace.nxs.md5 | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Testing/Data/SystemTest/3132_Orthorhombic_P.integrate.nxs.md5 b/Testing/Data/SystemTest/3132_Orthorhombic_P.integrate.nxs.md5 index 58c25d5eaeff..c91761152e35 100644 --- a/Testing/Data/SystemTest/3132_Orthorhombic_P.integrate.nxs.md5 +++ b/Testing/Data/SystemTest/3132_Orthorhombic_P.integrate.nxs.md5 @@ -1 +1 @@ -9e7cd5cb0a44319e99aa8a1fd2a5b549 +4eec33256ef34ab9cbc302eb4bdf9a7e diff --git a/Testing/Data/SystemTest/PowderReduceP2D_reference.p2d.md5 b/Testing/Data/SystemTest/PowderReduceP2D_reference.p2d.md5 index 209672ba09b6..ee6baec7a007 100644 --- a/Testing/Data/SystemTest/PowderReduceP2D_reference.p2d.md5 +++ b/Testing/Data/SystemTest/PowderReduceP2D_reference.p2d.md5 @@ -1 +1 @@ -8bb9ff77463d810b9a72f7d3aaf2b9a8 +9af80ceca5fe5d41c23940871f5783c1 diff --git a/Testing/SystemTests/tests/framework/reference/ReflectometryApplyFloodWorkspace.nxs.md5 b/Testing/SystemTests/tests/framework/reference/ReflectometryApplyFloodWorkspace.nxs.md5 index d3180667e826..ee2796f8e6e3 100644 --- a/Testing/SystemTests/tests/framework/reference/ReflectometryApplyFloodWorkspace.nxs.md5 +++ b/Testing/SystemTests/tests/framework/reference/ReflectometryApplyFloodWorkspace.nxs.md5 @@ -1 +1 @@ -00c4d103c9ef25d6b91490546b44e4f1 +b0387c5656e8396cb473835d38aa59c1 From 1af3dc5c83c6321d05357a249ff3bc24f53a04e3 Mon Sep 17 00:00:00 2001 From: Pete Peterson Date: Fri, 23 Aug 2024 14:53:42 -0400 Subject: [PATCH 3/3] Refactor test and update value of c lattice --- .../tests/framework/TOPAZPeakFinding.py | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/Testing/SystemTests/tests/framework/TOPAZPeakFinding.py b/Testing/SystemTests/tests/framework/TOPAZPeakFinding.py index de0dcb40ef1c..6873949f5d3d 100644 --- a/Testing/SystemTests/tests/framework/TOPAZPeakFinding.py +++ b/Testing/SystemTests/tests/framework/TOPAZPeakFinding.py @@ -14,6 +14,7 @@ import numpy from mantid.simpleapi import * from mantid.dataobjects import PeaksWorkspace, LeanElasticPeaksWorkspace +from mantid.geometry import UnitCell class TOPAZPeakFinding(systemtesting.MantidSystemTest): @@ -22,6 +23,8 @@ def requiredMemoryMB(self): return 2000 def runTest(self): + unitcell_exp = UnitCell(4.714, 6.06, 10.40) # orthorhombic + # Load then convert to Q in the lab frame LoadEventNexus(Filename=r"TOPAZ_3132_event.nxs", OutputWorkspace="topaz_3132") ConvertToDiffractionMDWorkspace( @@ -113,12 +116,12 @@ def runTest(self): w = mtd["topaz_3132"] s = w.sample() ol = s.getOrientedLattice() - self.assertDelta(ol.a(), 4.714, 0.01, "Correct lattice a value not found.") - self.assertDelta(ol.b(), 6.06, 0.01, "Correct lattice b value not found.") - self.assertDelta(ol.c(), 10.42, 0.01, "Correct lattice c value not found.") - self.assertDelta(ol.alpha(), 90, 0.4, "Correct lattice angle alpha value not found.") - self.assertDelta(ol.beta(), 90, 0.4, "Correct lattice angle beta value not found.") - self.assertDelta(ol.gamma(), 90, 0.4, "Correct lattice angle gamma value not found.") + self.assertDelta(ol.a(), unitcell_exp.a(), 0.01, "Correct lattice a value not found.") + self.assertDelta(ol.b(), unitcell_exp.b(), 0.01, "Correct lattice b value not found.") + self.assertDelta(ol.c(), unitcell_exp.c(), 0.01, "Correct lattice c value not found.") + self.assertDelta(ol.alpha(), unitcell_exp.alpha(), 0.4, "Correct lattice angle alpha value not found.") + self.assertDelta(ol.beta(), unitcell_exp.beta(), 0.4, "Correct lattice angle beta value not found.") + self.assertDelta(ol.gamma(), unitcell_exp.gamma(), 0.4, "Correct lattice angle gamma value not found.") # Compare new and old UBs newUB = numpy.array(mtd["topaz_3132"].sample().getOrientedLattice().getUB()) @@ -155,12 +158,12 @@ def runTest(self): w = mtd["topaz_3132"] s = w.sample() ol = s.getOrientedLattice() - self.assertDelta(ol.a(), 4.714, 0.01, "Correct lattice a value not found.") - self.assertDelta(ol.b(), 6.06, 0.01, "Correct lattice b value not found.") - self.assertDelta(ol.c(), 10.42, 0.01, "Correct lattice c value not found.") - self.assertDelta(ol.alpha(), 90, 0.4, "Correct lattice angle alpha value not found.") - self.assertDelta(ol.beta(), 90, 0.4, "Correct lattice angle beta value not found.") - self.assertDelta(ol.gamma(), 90, 0.4, "Correct lattice angle gamma value not found.") + self.assertDelta(ol.a(), unitcell_exp.a(), 0.01, "Correct lattice a value not found.") + self.assertDelta(ol.b(), unitcell_exp.b(), 0.01, "Correct lattice b value not found.") + self.assertDelta(ol.c(), unitcell_exp.c(), 0.01, "Correct lattice c value not found.") + self.assertDelta(ol.alpha(), unitcell_exp.alpha(), 0.4, "Correct lattice angle alpha value not found.") + self.assertDelta(ol.beta(), unitcell_exp.beta(), 0.4, "Correct lattice angle beta value not found.") + self.assertDelta(ol.gamma(), unitcell_exp.gamma(), 0.4, "Correct lattice angle gamma value not found.") # Compare new and old UBs newUB = numpy.array(mtd["topaz_3132"].sample().getOrientedLattice().getUB())