From 9fdde691d8ad2f698e16f974b90d83cc9411eec4 Mon Sep 17 00:00:00 2001 From: sf1919 Date: Mon, 12 Aug 2024 10:16:21 +0100 Subject: [PATCH 01/27] Remove AlignDetectors algorithm - Remove head and main files - Remove references from CMake --- Framework/Algorithms/CMakeLists.txt | 2 - .../inc/MantidAlgorithms/AlignDetectors.h | 77 ----- Framework/Algorithms/src/AlignDetectors.cpp | 311 ------------------ 3 files changed, 390 deletions(-) delete mode 100644 Framework/Algorithms/inc/MantidAlgorithms/AlignDetectors.h delete mode 100644 Framework/Algorithms/src/AlignDetectors.cpp diff --git a/Framework/Algorithms/CMakeLists.txt b/Framework/Algorithms/CMakeLists.txt index 3a44091c90bf..25c4744aa64e 100644 --- a/Framework/Algorithms/CMakeLists.txt +++ b/Framework/Algorithms/CMakeLists.txt @@ -5,7 +5,6 @@ set(SRC_FILES src/AddPeak.cpp src/AddSampleLog.cpp src/AddTimeSeriesLog.cpp - src/AlignDetectors.cpp src/AnnularRingAbsorption.cpp src/AnyShapeAbsorption.cpp src/ApodizationFunctions.cpp @@ -355,7 +354,6 @@ set(INC_FILES inc/MantidAlgorithms/AddPeak.h inc/MantidAlgorithms/AddSampleLog.h inc/MantidAlgorithms/AddTimeSeriesLog.h - inc/MantidAlgorithms/AlignDetectors.h inc/MantidAlgorithms/AnnularRingAbsorption.h inc/MantidAlgorithms/AnyShapeAbsorption.h inc/MantidAlgorithms/ApodizationFunctions.h diff --git a/Framework/Algorithms/inc/MantidAlgorithms/AlignDetectors.h b/Framework/Algorithms/inc/MantidAlgorithms/AlignDetectors.h deleted file mode 100644 index e94927c2d12b..000000000000 --- a/Framework/Algorithms/inc/MantidAlgorithms/AlignDetectors.h +++ /dev/null @@ -1,77 +0,0 @@ -// Mantid Repository : https://github.com/mantidproject/mantid -// -// Copyright © 2008 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 + -#pragma once - -#include "MantidAPI/Algorithm.h" -#include "MantidAPI/DeprecatedAlgorithm.h" -#include "MantidAPI/ITableWorkspace_fwd.h" -#include "MantidAlgorithms/DllConfig.h" -#include "MantidDataObjects/OffsetsWorkspace.h" - -namespace Mantid { - -namespace DataObjects { -class EventWorkspace; -} - -namespace Algorithms { - -namespace { -class ConversionFactors; -} - -/** Performs a unit change from TOF to dSpacing, correcting the X values to - account for small - errors in the detector positions. - - Required Properties: - - - @author Russell Taylor, Tessella Support Services plc - @date 18/08/2008 -*/ -class MANTID_ALGORITHMS_DLL AlignDetectors final : public API::Algorithm, public API::DeprecatedAlgorithm { -public: - AlignDetectors(); - - /// Algorithms name for identification. @see Algorithm::name - const std::string name() const override; - /// Algorithm's summary for use in the GUI and help. @see Algorithm::summary - const std::string summary() const override; - - /// Algorithm's version for identification. @see Algorithm::version - int version() const override; - const std::vector seeAlso() const override { return {"DiffractionFocussing", "AlignAndFocusPowder"}; } - /// Algorithm's category for identification. @see Algorithm::category - const std::string category() const override; - /// Cross-check properties with each other @see IAlgorithm::validateInputs - std::map validateInputs() override; - -private: - // Implement abstract Algorithm methods - void init() override; - void exec() override; - - void align(const ConversionFactors &converter, API::Progress &progress, API::MatrixWorkspace_sptr &outputWS); - - void loadCalFile(const API::MatrixWorkspace_sptr &inputWS, const std::string &filename); - void getCalibrationWS(const API::MatrixWorkspace_sptr &inputWS); - - Mantid::API::ITableWorkspace_sptr m_calibrationWS; - - /// number of spectra in input workspace - int64_t m_numberOfSpectra; -}; - -} // namespace Algorithms -} // namespace Mantid diff --git a/Framework/Algorithms/src/AlignDetectors.cpp b/Framework/Algorithms/src/AlignDetectors.cpp deleted file mode 100644 index 1164705030a1..000000000000 --- a/Framework/Algorithms/src/AlignDetectors.cpp +++ /dev/null @@ -1,311 +0,0 @@ -// Mantid Repository : https://github.com/mantidproject/mantid -// -// Copyright © 2018 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 + -//---------------------------------------------------------------------- -// Includes -//---------------------------------------------------------------------- -#include "MantidAlgorithms/AlignDetectors.h" - -#include "MantidAPI/Axis.h" -#include "MantidAPI/FileProperty.h" -#include "MantidAPI/ITableWorkspace.h" -#include "MantidAPI/RawCountValidator.h" -#include "MantidAPI/WorkspaceUnitValidator.h" -#include "MantidDataObjects/EventWorkspace.h" -#include "MantidDataObjects/OffsetsWorkspace.h" -#include "MantidKernel/CompositeValidator.h" -#include "MantidKernel/PhysicalConstants.h" -#include "MantidKernel/UnitFactory.h" -#include "MantidKernel/V3D.h" - -#include -#include -#include - -using namespace Mantid::Kernel; -using namespace Mantid::API; -using namespace Mantid::Geometry; -using namespace Mantid::DataObjects; -using namespace Mantid::HistogramData; -using Mantid::DataObjects::OffsetsWorkspace; - -namespace Mantid::Algorithms { -// Register the algorithm into the algorithm factory -DECLARE_ALGORITHM(AlignDetectors) - -namespace { // anonymous namespace - -class ConversionFactors { -public: - explicit ConversionFactors(const ITableWorkspace_const_sptr &table) - : m_difcCol(table->getColumn("difc")), m_difaCol(table->getColumn("difa")), - m_tzeroCol(table->getColumn("tzero")) { - this->generateDetidToRow(table); - } - - std::tuple getDiffConstants(const std::set &detIds) const { - const std::set rows = this->getRow(detIds); - double difc = 0.; - double difa = 0.; - double tzero = 0.; - for (auto row : rows) { - difc += m_difcCol->toDouble(row); - difa += m_difaCol->toDouble(row); - tzero += m_tzeroCol->toDouble(row); - } - if (rows.size() > 1) { - double norm = 1. / static_cast(rows.size()); - difc = norm * difc; - difa = norm * difa; - tzero = norm * tzero; - } - - return {difc, difa, tzero}; - } - -private: - void generateDetidToRow(const ITableWorkspace_const_sptr &table) { - ConstColumnVector detIDs = table->getVector("detid"); - const size_t numDets = detIDs.size(); - for (size_t i = 0; i < numDets; ++i) { - m_detidToRow[static_cast(detIDs[i])] = i; - } - } - - std::set getRow(const std::set &detIds) const { - std::set rows; - for (auto detId : detIds) { - auto rowIter = m_detidToRow.find(detId); - if (rowIter != m_detidToRow.end()) { // skip if not found - rows.insert(rowIter->second); - } - } - if (rows.empty()) { - std::string detIdsStr = std::accumulate(std::begin(detIds), std::end(detIds), std::string{}, - [](const std::string &a, const detid_t &b) { - return a.empty() ? std::to_string(b) : a + ',' + std::to_string(b); - }); - throw Exception::NotFoundError("None of the detectors were found in the calibration table", detIdsStr); - } - return rows; - } - - std::map m_detidToRow; - Column_const_sptr m_difcCol; - Column_const_sptr m_difaCol; - Column_const_sptr m_tzeroCol; -}; -} // anonymous namespace - -const std::string AlignDetectors::name() const { return "AlignDetectors"; } - -int AlignDetectors::version() const { return 1; } - -const std::string AlignDetectors::category() const { return "Diffraction\\Calibration"; } - -const std::string AlignDetectors::summary() const { - return "Performs a unit change from TOF to dSpacing, correcting the X " - "values to account for small errors in the detector positions."; -} - -/// Constructor -AlignDetectors::AlignDetectors() : m_numberOfSpectra(0) { - useAlgorithm("ConvertUnits"); - deprecatedDate("2021-01-04"); -} - -void AlignDetectors::init() { - auto wsValidator = std::make_shared(); - // Workspace unit must be TOF. - wsValidator->add("TOF"); - wsValidator->add(); - - declareProperty( - std::make_unique>("InputWorkspace", "", Direction::Input, wsValidator), - "A workspace with units of TOF"); - - declareProperty(std::make_unique>("OutputWorkspace", "", Direction::Output), - "The name to use for the output workspace"); - - const std::vector exts{".h5", ".hd5", ".hdf", ".cal"}; - declareProperty(std::make_unique("CalibrationFile", "", FileProperty::OptionalLoad, exts), - "Optional: The .cal file containing the position correction factors. " - "Either this or OffsetsWorkspace needs to be specified."); - - declareProperty(std::make_unique>("CalibrationWorkspace", "", Direction::Input, - PropertyMode::Optional), - "Optional: A Workspace containing the calibration information. Either " - "this or CalibrationFile needs to be specified."); - - declareProperty(std::make_unique>("OffsetsWorkspace", "", Direction::Input, - PropertyMode::Optional), - "Optional: A OffsetsWorkspace containing the calibration offsets. Either " - "this or CalibrationFile needs to be specified."); - - // make group associations. - std::string calibrationGroup("Calibration"); - setPropertyGroup("CalibrationFile", calibrationGroup); - setPropertyGroup("CalibrationWorkspace", calibrationGroup); - setPropertyGroup("OffsetsWorkspace", calibrationGroup); -} - -std::map AlignDetectors::validateInputs() { - std::map result; - - int numWays = 0; - - const std::string calFileName = getProperty("CalibrationFile"); - if (!calFileName.empty()) - numWays += 1; - - ITableWorkspace_const_sptr calibrationWS = getProperty("CalibrationWorkspace"); - if (bool(calibrationWS)) - numWays += 1; - - OffsetsWorkspace_const_sptr offsetsWS = getProperty("OffsetsWorkspace"); - if (bool(offsetsWS)) - numWays += 1; - - std::string message; - if (numWays == 0) { - message = "You must specify only one of CalibrationFile, " - "CalibrationWorkspace, OffsetsWorkspace."; - } - if (numWays > 1) { - message = "You must specify one of CalibrationFile, " - "CalibrationWorkspace, OffsetsWorkspace."; - } - - if (!message.empty()) { - result["CalibrationFile"] = message; - result["CalibrationWorkspace"] = message; - } - - return result; -} - -void AlignDetectors::loadCalFile(const MatrixWorkspace_sptr &inputWS, const std::string &filename) { - auto alg = createChildAlgorithm("LoadDiffCal"); - alg->setProperty("InputWorkspace", inputWS); - alg->setPropertyValue("Filename", filename); - alg->setProperty("MakeCalWorkspace", true); - alg->setProperty("MakeGroupingWorkspace", false); - alg->setProperty("MakeMaskWorkspace", false); - alg->setPropertyValue("WorkspaceName", "temp"); - alg->executeAsChildAlg(); - - m_calibrationWS = alg->getProperty("OutputCalWorkspace"); -} - -void AlignDetectors::getCalibrationWS(const MatrixWorkspace_sptr &inputWS) { - m_calibrationWS = getProperty("CalibrationWorkspace"); - if (m_calibrationWS) - return; // nothing more to do - - OffsetsWorkspace_sptr offsetsWS = getProperty("OffsetsWorkspace"); - if (offsetsWS) { - auto alg = createChildAlgorithm("ConvertDiffCal"); - alg->setProperty("OffsetsWorkspace", offsetsWS); - alg->executeAsChildAlg(); - m_calibrationWS = alg->getProperty("OutputWorkspace"); - m_calibrationWS->setTitle(offsetsWS->getTitle()); - return; - } - - const std::string calFileName = getPropertyValue("CalibrationFile"); - if (!calFileName.empty()) { - progress(0.0, "Reading calibration file"); - loadCalFile(inputWS, calFileName); - return; - } - - throw std::runtime_error("Failed to determine calibration information"); -} - -void setXAxisUnits(const API::MatrixWorkspace_sptr &outputWS) { - outputWS->getAxis(0)->unit() = UnitFactory::Instance().create("dSpacing"); -} - -/** Executes the algorithm - * @throw Exception::FileError If the calibration file cannot be opened and - * read successfully - * @throw Exception::InstrumentDefinitionError If unable to obtain the - * source-sample distance - */ -void AlignDetectors::exec() { - // Get the input workspace - MatrixWorkspace_sptr inputWS = getProperty("InputWorkspace"); - - this->getCalibrationWS(inputWS); - - // Initialise the progress reporting object - m_numberOfSpectra = static_cast(inputWS->getNumberHistograms()); - - API::MatrixWorkspace_sptr outputWS = getProperty("OutputWorkspace"); - // If input and output workspaces are not the same, create a new workspace for - // the output - if (outputWS != inputWS) { - outputWS = inputWS->clone(); - setProperty("OutputWorkspace", outputWS); - } - - // Set the final unit that our output workspace will have - setXAxisUnits(outputWS); - - ConversionFactors converter = ConversionFactors(m_calibrationWS); - - Progress progress(this, 0.0, 1.0, m_numberOfSpectra); - - align(converter, progress, outputWS); -} - -void AlignDetectors::align(const ConversionFactors &converter, Progress &progress, MatrixWorkspace_sptr &outputWS) { - auto eventW = std::dynamic_pointer_cast(outputWS); - PARALLEL_FOR_IF(Kernel::threadSafe(*outputWS)) - for (int64_t i = 0; i < m_numberOfSpectra; ++i) { - PARALLEL_START_INTERRUPT_REGION - try { - // Get the input spectrum number at this workspace index - auto &spec = outputWS->getSpectrum(size_t(i)); - auto [difc, difa, tzero] = converter.getDiffConstants(spec.getDetectorIDs()); - - auto &x = outputWS->dataX(i); - Kernel::Units::dSpacing dSpacingUnit; - std::vector yunused; - dSpacingUnit.fromTOF(x, yunused, -1., 0, - UnitParametersMap{{Kernel::UnitParams::difa, difa}, - {Kernel::UnitParams::difc, difc}, - {Kernel::UnitParams::tzero, tzero}}); - - if (eventW) { - Kernel::Units::TOF tofUnit; - tofUnit.initialize(0, 0, {}); - // EventWorkspace part, modifying the EventLists. - eventW->getSpectrum(i).convertUnitsViaTof(&tofUnit, &dSpacingUnit); - } - } catch (const std::runtime_error &) { - if (!eventW) { - // Zero the data in this case (detectors not found in cal table or - // conversion fails) - outputWS->setHistogram(i, BinEdges(outputWS->x(i).size()), Counts(outputWS->y(i).size())); - } - } - progress.report(); - PARALLEL_END_INTERRUPT_REGION - } - PARALLEL_CHECK_INTERRUPT_REGION - if (eventW) { - if (eventW->getTofMin() < 0.) { - std::stringstream msg; - msg << "Something wrong with the calibration. Negative minimum d-spacing " - "created. d_min = " - << eventW->getTofMin() << " d_max " << eventW->getTofMax(); - g_log.warning(msg.str()); - } - eventW->clearMRU(); - } -} -} // namespace Mantid::Algorithms From 085afb05e183152f5f86b24a507d2761aa6ab929 Mon Sep 17 00:00:00 2001 From: sf1919 Date: Mon, 12 Aug 2024 10:17:53 +0100 Subject: [PATCH 02/27] Remove aligndetectorstest - Remove test and reference from CMake --- Framework/Algorithms/CMakeLists.txt | 1 - .../Algorithms/test/AlignDetectorsTest.h | 169 ------------------ 2 files changed, 170 deletions(-) delete mode 100644 Framework/Algorithms/test/AlignDetectorsTest.h diff --git a/Framework/Algorithms/CMakeLists.txt b/Framework/Algorithms/CMakeLists.txt index 25c4744aa64e..636dea4819e7 100644 --- a/Framework/Algorithms/CMakeLists.txt +++ b/Framework/Algorithms/CMakeLists.txt @@ -710,7 +710,6 @@ set(TEST_FILES AddPeakTest.h AddSampleLogTest.h AddTimeSeriesLogTest.h - AlignDetectorsTest.h AnnularRingAbsorptionTest.h AnyShapeAbsorptionTest.h AppendSpectraTest.h diff --git a/Framework/Algorithms/test/AlignDetectorsTest.h b/Framework/Algorithms/test/AlignDetectorsTest.h deleted file mode 100644 index 1a70ee2707bb..000000000000 --- a/Framework/Algorithms/test/AlignDetectorsTest.h +++ /dev/null @@ -1,169 +0,0 @@ -// Mantid Repository : https://github.com/mantidproject/mantid -// -// Copyright © 2018 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 + -#pragma once - -#include "MantidFrameworkTestHelpers/WorkspaceCreationHelper.h" -#include - -#include "MantidAPI/Axis.h" -#include "MantidAlgorithms/AlignDetectors.h" -#include "MantidDataHandling/LoadNexus.h" -#include "MantidDataObjects/EventWorkspace.h" -#include "MantidKernel/Unit.h" - -using namespace Mantid::Algorithms; -using namespace Mantid::DataHandling; -using namespace Mantid::DataObjects; -using namespace Mantid::Kernel; -using namespace Mantid::API; - -class AlignDetectorsTest : public CxxTest::TestSuite { -public: - // This pair of boilerplate methods prevent the suite being created statically - // This means the constructor isn't called when running other tests - static AlignDetectorsTest *createSuite() { return new AlignDetectorsTest(); } - static void destroySuite(AlignDetectorsTest *suite) { delete suite; } - - /** Setup for loading Nexus data */ - void setUp_HRP38692() { - - LoadNexus loader; - loader.initialize(); - loader.setPropertyValue("Filename", "HRP38692a.nxs"); - inputWS = "nexusWS"; - loader.setPropertyValue("OutputWorkspace", inputWS); - loader.execute(); - } - - void testTheBasics() { - TS_ASSERT_EQUALS(align.name(), "AlignDetectors"); - TS_ASSERT_EQUALS(align.version(), 1); - } - - void testInit() { - TS_ASSERT_THROWS_NOTHING(align.initialize()); - TS_ASSERT(align.isInitialized()); - } - - /** Test alignDetectors for a Workspace2D loaded from some - * raw data file. - */ - void testExecWorkspace2D() { - setUp_HRP38692(); - if (!align.isInitialized()) - align.initialize(); - - TS_ASSERT_THROWS(align.execute(), const std::runtime_error &); - - align.setPropertyValue("InputWorkspace", inputWS); - const std::string outputWS = "aligned"; - align.setPropertyValue("OutputWorkspace", outputWS); - align.setPropertyValue("CalibrationFile", "hrpd_new_072_01.cal"); - - TS_ASSERT_THROWS_NOTHING(align.execute()); - TS_ASSERT(align.isExecuted()); - - std::shared_ptr inWS = AnalysisDataService::Instance().retrieveWS(inputWS); - std::shared_ptr outWS = AnalysisDataService::Instance().retrieveWS(outputWS); - - TS_ASSERT_EQUALS(outWS->getAxis(0)->unit()->unitID(), "dSpacing"); - TS_ASSERT_EQUALS(outWS->size(), inWS->size()); - TS_ASSERT_EQUALS(outWS->blocksize(), inWS->blocksize()); - - TS_ASSERT_DELTA(outWS->x(2)[50], 0.7223, 0.0001); - TS_ASSERT_EQUALS(outWS->y(2)[50], inWS->y(1)[50]); - TS_ASSERT_EQUALS(outWS->y(2)[50], inWS->y(1)[50]); - - for (size_t i = 0; i < outWS->getNumberHistograms(); i++) { - TS_ASSERT_EQUALS(outWS->getSpectrum(i).getSpectrumNo(), inWS->getSpectrum(i).getSpectrumNo()); - TS_ASSERT_EQUALS(outWS->getSpectrum(i).getDetectorIDs().size(), inWS->getSpectrum(i).getDetectorIDs().size()); - TS_ASSERT_EQUALS(*outWS->getSpectrum(i).getDetectorIDs().begin(), *inWS->getSpectrum(i).getDetectorIDs().begin()); - } - - AnalysisDataService::Instance().remove(outputWS); - } - - /** Setup for loading raw data */ - void setUp_Event() { - inputWS = "eventWS"; - EventWorkspace_sptr ws = WorkspaceCreationHelper::createEventWorkspaceWithFullInstrument(1, 10, false); - ws->getAxis(0)->setUnit("TOF"); - AnalysisDataService::Instance().addOrReplace(inputWS, ws); - } - - void testExecEventWorkspace_sameOutputWS() { - this->setUp_Event(); - std::size_t wkspIndex = 1; // a good workspace index (with events) - - // Retrieve Workspace - WS = AnalysisDataService::Instance().retrieveWS(inputWS); - TS_ASSERT(WS); // workspace is loaded - size_t start_blocksize = WS->blocksize(); - size_t num_events = WS->getNumberEvents(); - double a_tof = WS->getSpectrum(wkspIndex).getEvents()[0].tof(); - - // Start by init'ing the algorithm - TS_ASSERT_THROWS_NOTHING(align.initialize()); - TS_ASSERT(align.isInitialized()); - - // Set all the properties - align.setPropertyValue("InputWorkspace", inputWS); - const std::string outputWS = inputWS; - align.setPropertyValue("OutputWorkspace", outputWS); - align.setPropertyValue("CalibrationFile", "refl_fake.cal"); - - TS_ASSERT_THROWS_NOTHING(align.execute()); - TS_ASSERT(align.isExecuted()); - - // WS hasn;t changed - - // Things that haven't changed - TS_ASSERT_EQUALS(start_blocksize, WS->blocksize()); - TS_ASSERT_EQUALS(num_events, WS->getNumberEvents()); - // But a TOF changed. - TS_ASSERT_DIFFERS(a_tof, WS->getSpectrum(wkspIndex).getEvents()[0].tof()); - } - - void testExecEventWorkspace_differentOutputWS() { - this->setUp_Event(); - std::size_t wkspIndex = 1; // a good workspace index (with events) - - // Retrieve Workspace - WS = AnalysisDataService::Instance().retrieveWS(inputWS); - TS_ASSERT(WS); // workspace is loaded - - // Start by init'ing the algorithm - TS_ASSERT_THROWS_NOTHING(align.initialize()); - TS_ASSERT(align.isInitialized()); - - // Set all the properties - align.setPropertyValue("InputWorkspace", inputWS); - const std::string outputWS = "eventWS_changed"; - align.setPropertyValue("OutputWorkspace", outputWS); - align.setPropertyValue("CalibrationFile", "refl_fake.cal"); - - TS_ASSERT_THROWS_NOTHING(align.execute()); - TS_ASSERT(align.isExecuted()); - - // Retrieve Workspace changed - EventWorkspace_sptr outWS; - outWS = AnalysisDataService::Instance().retrieveWS(outputWS); - TS_ASSERT(outWS); // workspace is loaded - - // Things that haven't changed - TS_ASSERT_EQUALS(outWS->blocksize(), WS->blocksize()); - TS_ASSERT_EQUALS(outWS->getNumberEvents(), WS->getNumberEvents()); - // But a TOF changed. - TS_ASSERT_DIFFERS(outWS->getSpectrum(wkspIndex).getEvents()[0].tof(), - WS->getSpectrum(wkspIndex).getEvents()[0].tof()); - } - -private: - AlignDetectors align; - std::string inputWS; - EventWorkspace_sptr WS; -}; From 09537b139a2dea95f831d33e0485ed83e0467fda Mon Sep 17 00:00:00 2001 From: sf1919 Date: Mon, 12 Aug 2024 11:50:43 +0100 Subject: [PATCH 03/27] Remove user documentation - Removed the User documentation of the algorithm - Removed links from previous release notes - Removed references to the AlignDetectors Algorithm as an example in documentation --- docs/source/algorithms/AlignDetectors-v1.rst | 93 -------------------- docs/source/algorithms/ApplyDiffCal-v1.rst | 3 +- docs/source/algorithms/CalculateDIFC-v1.rst | 3 +- docs/source/release/v6.1.0/diffraction.rst | 2 +- 4 files changed, 3 insertions(+), 98 deletions(-) delete mode 100644 docs/source/algorithms/AlignDetectors-v1.rst diff --git a/docs/source/algorithms/AlignDetectors-v1.rst b/docs/source/algorithms/AlignDetectors-v1.rst deleted file mode 100644 index bfa5e80ca869..000000000000 --- a/docs/source/algorithms/AlignDetectors-v1.rst +++ /dev/null @@ -1,93 +0,0 @@ -.. algorithm:: - -.. summary:: - -.. relatedalgorithms:: - -.. properties:: - -.. note:: As of 2021-01-04, this algorithm is officially deprecated. - As a result, developers and users are recommend to use - :ref:`ApplyDiffCal`, followed by - :ref:`ConvertUnits`, followed by - :ref:`ApplyDiffCal` (ClearCalibration=true) to - produce the equivalent results. - -Description ------------ - -This algorithm applies a :ref:`calibration table -` to convert a workspace from -time-of-flight to dSpacing as described below. The equation in `GSAS -`_ converts from -d-spacing (:math:`d`) to time-of-flight (:math:`TOF`) by the equation: - -.. math:: TOF = DIFC * d + DIFA * d^2 + TZERO - -The manual describes these terms in more detail. Roughly, -:math:`TZERO` is related to the difference between the measured and -actual time-of-flight base on emission time from the moderator, :math:`DIFA` is an empirical term (ideally zero), and :math:`DIFC` is - -.. math:: DIFC = \frac{2m_N}{h} L_{tot} sin \theta - -Measuring peak positions using a crystal with a very well known -lattice constant will give a good value for converting the data. The -d-spacing of the data will be calculated using whichever equation -below is appropriate for solving the quadratic. - -When :math:`DIFA = 0` then the solution is just for a line and - -.. math:: d = \frac{TOF - TZERO}{DIFC} - -For the case of needing to solve the actual quadratic equation - -.. math:: d = \frac{-DIFC}{2 DIFA} \pm \sqrt{\frac{TOF}{DIFA} + \left(\frac{DIFC}{2 DIFA}\right)^2 - \frac{TZERO}{DIFA}} - -Here the positive root is used when :math:`DIFA > 0` and the negative -when :math:`DIFA < 0`. - -This algorithm always uses a :ref:`calibration table -` which it either reads from the -`CalibrationWorkspace` property, or uses :ref:`ConvertDiffCal -` to produce from the ``OffsetsWorkspace``. - -.. note:: The workspace that this algorithms outputs is a - :ref:`ragged workspace `. - -Restrictions on the input workspace -################################### - -The input workspace must contain histogram or event data where the X -unit is time-of-flight and the Y data is raw counts. The -:ref:`instrument ` associated with the workspace must be -fully defined because detector, source & sample position are needed if -an OffsetsWorkspace is provided. - -Usage ------ - -**Example: Use offset to move peak in Dspace** - -.. testcode:: ExAlignDetectors - - ws = CreateSampleWorkspace("Event",NumBanks=1,BankPixelWidth=1) - ws = MoveInstrumentComponent(Workspace='ws', ComponentName='bank1', X=0.5, RelativePosition=False) - wsD = ConvertUnits(InputWorkspace='ws', Target='dSpacing') - maxD = Max(wsD) - offset = GetDetectorOffsets(InputWorkspace='wsD', DReference=2.5, XMin=2, XMax=3) - wsA = AlignDetectors(InputWorkspace='ws', OutputWorkspace='wsA', OffsetsWorkspace='offset') - maxA = Max(wsA) - print("Peak in dSpace {:.11f}".format(maxD.readX(0)[0])) - print("Peak from calibration {:.10f}".format(maxA.readX(0)[0])) - -Output: - -.. testoutput:: ExAlignDetectors - - Peak in dSpace 2.66413186052 - Peak from calibration 2.5622683421 - - -.. categories:: - -.. sourcelink:: diff --git a/docs/source/algorithms/ApplyDiffCal-v1.rst b/docs/source/algorithms/ApplyDiffCal-v1.rst index 487240933431..b67c7988ec35 100644 --- a/docs/source/algorithms/ApplyDiffCal-v1.rst +++ b/docs/source/algorithms/ApplyDiffCal-v1.rst @@ -25,8 +25,7 @@ calibrated diffractometer constants to be performed using the reads the constants from the instrument parameter map. When used together with :ref:`ConvertUnits ` this algorithm provides a way of -converting in both directions between time of flight and d spacing and it is an alternative to -using :ref:`AlignDetectors `. +converting in both directions between time of flight and d spacing. The values of the diffractometer constants that are stored in the instrument parameter map can be viewed on the Show Detectors screen of a workspace. diff --git a/docs/source/algorithms/CalculateDIFC-v1.rst b/docs/source/algorithms/CalculateDIFC-v1.rst index d46ec692b7e2..88e2709c0a41 100644 --- a/docs/source/algorithms/CalculateDIFC-v1.rst +++ b/docs/source/algorithms/CalculateDIFC-v1.rst @@ -24,8 +24,7 @@ DIFC is used in the equation .. math:: TOF = DIFC \times d -This algorithm uses the same underlying calculation as :ref:`algm-ConvertUnits` -and :ref:`algm-AlignDetectors`. +This algorithm uses the same underlying calculation as :ref:`algm-ConvertUnits`. When specifying the ``CalibrationWorkspace``, this algorithm copies the values in the ``detid`` and ``difc`` columns of the calibration workspace. diff --git a/docs/source/release/v6.1.0/diffraction.rst b/docs/source/release/v6.1.0/diffraction.rst index bd921a618fcc..e05b5f48d1b8 100644 --- a/docs/source/release/v6.1.0/diffraction.rst +++ b/docs/source/release/v6.1.0/diffraction.rst @@ -10,7 +10,7 @@ Powder Diffraction New features ############ -- The :ref:`ConvertUnits ` algorithm has been extended to use a calibration when converting between d spacing, momentum transfer and TOF. A calibration can be loaded into a workspace using a new :ref:`ApplyDiffCal ` algorithm and then viewed in the Show Detectors screen. The calibration consists of the diffractometer constants DIFA, DIFC and TZERO that determine the form of the quadratic relationship between d spacing and TOF. This functionality was previously only available in :ref:`AlignDetectors ` which only performed the conversion in the direction TOF to d spacing. This change will provide several benefits: +- The :ref:`ConvertUnits ` algorithm has been extended to use a calibration when converting between d spacing, momentum transfer and TOF. A calibration can be loaded into a workspace using a new :ref:`ApplyDiffCal ` algorithm and then viewed in the Show Detectors screen. The calibration consists of the diffractometer constants DIFA, DIFC and TZERO that determine the form of the quadratic relationship between d spacing and TOF. This functionality was previously only available in ``AlignDetectors`` which only performed the conversion in the direction TOF to d spacing. This change will provide several benefits: - Allow the user to choose the calibration to use when converting focused data from d-spacing to TOF - Improved integration with GSAS e.g. both the calibration and the data will be loaded from GSAS files when running the algorithm :ref:`LoadGSS ` and subsequent unit conversions will respect the calibration From d15d7d04935231da8585a05c479691e8db968526 Mon Sep 17 00:00:00 2001 From: sf1919 Date: Wed, 14 Aug 2024 12:32:34 +0100 Subject: [PATCH 04/27] Remove references for AlignDetectors in algorithm documentation - Where possible remove or convert reference to AlignDetectors to ConvertUnits --- docs/source/algorithms/EnggFitTOFFromPeaks-v1.rst | 5 ----- docs/source/algorithms/LoadDspacemap-v1.rst | 2 +- docs/source/algorithms/PDCalibration-v1.rst | 4 ++-- docs/source/algorithms/SaveGDA-v1.rst | 2 +- 4 files changed, 4 insertions(+), 9 deletions(-) diff --git a/docs/source/algorithms/EnggFitTOFFromPeaks-v1.rst b/docs/source/algorithms/EnggFitTOFFromPeaks-v1.rst index 18357490711c..faede32ae005 100644 --- a/docs/source/algorithms/EnggFitTOFFromPeaks-v1.rst +++ b/docs/source/algorithms/EnggFitTOFFromPeaks-v1.rst @@ -39,11 +39,6 @@ If a name is given in OutParametersTable this algorithm also produces a table workspace with that name, containing the parameters fitted (DIFA, DIFC, TZERO). -The parameters DIFA, DIFC, TZERO are also used in other Mantid -algorithms. For example see :ref:`AlignDetectors -` where these parameters are used to convert -units from time-of-flight to d-spacing. - Usage ----- diff --git a/docs/source/algorithms/LoadDspacemap-v1.rst b/docs/source/algorithms/LoadDspacemap-v1.rst index 209df49fb654..f179db4b8374 100644 --- a/docs/source/algorithms/LoadDspacemap-v1.rst +++ b/docs/source/algorithms/LoadDspacemap-v1.rst @@ -13,7 +13,7 @@ Loads a Dspacemap file (POWGEN binary, VULCAN binary or ascii format) into an OffsetsWorkspace. The resulting workspace can then be used with, e.g. -:ref:`AlignDetectors ` to perform calibration. +:ref:`ConvertUnits ` to perform calibration. Usage ----- diff --git a/docs/source/algorithms/PDCalibration-v1.rst b/docs/source/algorithms/PDCalibration-v1.rst index 0329485b819d..621e7421bec7 100644 --- a/docs/source/algorithms/PDCalibration-v1.rst +++ b/docs/source/algorithms/PDCalibration-v1.rst @@ -13,7 +13,7 @@ Description This algorithm takes an ``InputWorkspace`` containing powder diffraction spectra from a standard sample with x-units of time-of-flight (TOF). These spectra are fitted to extract the Bragg peak positions. The extracted peak positions are then used to determine the diffractometer constants that convert diffraction spectra from TOF to d-spacing. These constants are described in detail -in :ref:`algm-AlignDetectors`. The number of the constants being determined (1,2,or 3) is controlled by ``CalibrationParameters``. +in :ref:`algm-EnggFitPeaks`. The number of the constants being determined (1,2,or 3) is controlled by ``CalibrationParameters``. The results are output to a :ref:`diffraction calibration workspace `. Unlike other calibration algorithms (see `Time-of-Flight Powder Diffraction Calibration <../concepts/calibration/PowderDiffractionCalibration.html>`_), @@ -43,7 +43,7 @@ When not specified using the ``MaskWorkspace`` parameter, the default name for t The resulting calibration table can be saved with :ref:`algm-SaveDiffCal`, loaded with :ref:`algm-LoadDiffCal` and -applied to a workspace with :ref:`algm-AlignDetectors`. There are also +applied to a workspace with :ref:`algm-ConvertUnits`. There are also three workspaces placed in the ``DiagnosticWorkspace`` group. They are: * evaluated fit functions (``_fitted``) which is the ``OutputPeakParametersWorkspace`` from :ref:`FitPeaks ` diff --git a/docs/source/algorithms/SaveGDA-v1.rst b/docs/source/algorithms/SaveGDA-v1.rst index def556fa4baa..8e53afbc06d6 100644 --- a/docs/source/algorithms/SaveGDA-v1.rst +++ b/docs/source/algorithms/SaveGDA-v1.rst @@ -56,7 +56,7 @@ D to TOF Conversion conversion factors for each bank. SaveGDA takes input in D-spacing, and applies the GSAS conversion -(explained at :ref:`AlignDetectors `), using +(explained at :ref:`EnggFitPeaks `), using parameters from the calibration file, to convert back to time-of-flight. The caveat here is that, if the calibration file contains the wrong conversion factors, then the TOF values will not From 69e734acf02a6f6e32d4b3a0d1b81dde1a9987f4 Mon Sep 17 00:00:00 2001 From: sf1919 Date: Wed, 14 Aug 2024 12:36:41 +0100 Subject: [PATCH 05/27] Update algorithm documentation with maths from AlignDetectors - For some algorithm documentation there are references made to the GSAS equations in AlignDetectors. This commit moves that information into the relevant documentation to enable the references to AlignDetectorsto be removed. --- docs/source/algorithms/AlignComponents-v1.rst | 7 ++-- docs/source/algorithms/EnggFitPeaks-v1.rst | 35 ++++++++++++++++--- 2 files changed, 36 insertions(+), 6 deletions(-) diff --git a/docs/source/algorithms/AlignComponents-v1.rst b/docs/source/algorithms/AlignComponents-v1.rst index f063c3084937..9cb85e3d7cf0 100644 --- a/docs/source/algorithms/AlignComponents-v1.rst +++ b/docs/source/algorithms/AlignComponents-v1.rst @@ -20,8 +20,11 @@ the absolute value of the fractional difference between the observed peak center for detector pixel :math:`i` and peak :math:`j`, :math:`DIFC_i * TOF_{i,j}`, and a reference experimental value for the d-spacing of peak :math:`j`, :math:`d^{exp}_j`. The conversion from peak center in TOF units (:math:`TOF_{i,j}`) to d-spacing units is carried out via the -geometrical parameter :math:`DIFC_i` -- see :ref:`algm-AlignDetectors` for more information -regarding this parameter. As we change the location and orientations of the instrument components +geometrical parameter :math:`DIFC_i`. For reference :math:`DIFC` is + +.. math:: DIFC = \frac{2m_N}{h} L_{tot} sin \theta + +As we change the location and orientations of the instrument components during the minimization, the geometrical parameter :math:`DIFC_i` is bound to change. Below's an example of the table of peak-center positions in TOF units for a sample having two peaks diff --git a/docs/source/algorithms/EnggFitPeaks-v1.rst b/docs/source/algorithms/EnggFitPeaks-v1.rst index 547b5b1788fd..11b3edfa62b8 100644 --- a/docs/source/algorithms/EnggFitPeaks-v1.rst +++ b/docs/source/algorithms/EnggFitPeaks-v1.rst @@ -33,11 +33,38 @@ then the algorithm fails. After the conversion of units, the algorithm tries to fit (in time-of-flight) a peak in the neighborhood of every expected peak -using a peak shape or function. The conversion is done as in the -Mantid algorithm :ref:`AlignDetectors ` -(following GSAS equations) if the workspace is focused (single +using a peak shape or function. If the workspace is focused (single spectrum) and has a log entry named "difc", where the GSAS DIFC -parameter is expected. Otherwise the conversion of units is done as in +parameter is expected, the conversion is done following GSAS equations. +The equation in `GSAS +`_ converts from +d-spacing (:math:`d`) to time-of-flight (:math:`TOF`) by the equation: + +.. math:: TOF = DIFC * d + DIFA * d^2 + TZERO + +The manual describes these terms in more detail. Roughly, +:math:`TZERO` is related to the difference between the measured and +actual time-of-flight base on emission time from the moderator, :math:`DIFA` is an empirical term (ideally zero), and :math:`DIFC` is + +.. math:: DIFC = \frac{2m_N}{h} L_{tot} sin \theta + +Measuring peak positions using a crystal with a very well known +lattice constant will give a good value for converting the data. The +d-spacing of the data will be calculated using whichever equation +below is appropriate for solving the quadratic. + +When :math:`DIFA = 0` then the solution is just for a line and + +.. math:: d = \frac{TOF - TZERO}{DIFC} + +For the case of needing to solve the actual quadratic equation + +.. math:: d = \frac{-DIFC}{2 DIFA} \pm \sqrt{\frac{TOF}{DIFA} + \left(\frac{DIFC}{2 DIFA}\right)^2 - \frac{TZERO}{DIFA}} + +Here the positive root is used when :math:`DIFA > 0` and the negative +when :math:`DIFA < 0`. + +Otherwise the conversion of units is done as in the Mantid :ref:`ConvertUnits `. .. seealso:: :ref:`EnggFitTOFFromPeaks `. From 5897496b4785b813fa7bec1039ba2c21c2a05b0e Mon Sep 17 00:00:00 2001 From: sf1919 Date: Wed, 14 Aug 2024 14:48:07 +0100 Subject: [PATCH 06/27] Move GSAS equation information - The GSAS equation information would be best situated in the Unit Factory concept documentation. This commit makes that change and updates references to this concept documentation instead. --- docs/source/algorithms/AlignComponents-v1.rst | 7 ++-- docs/source/algorithms/EnggFitPeaks-v1.rst | 32 +++---------------- .../algorithms/EnggFitTOFFromPeaks-v1.rst | 3 ++ docs/source/algorithms/PDCalibration-v1.rst | 2 +- docs/source/concepts/UnitFactory.rst | 29 +++++++++++++++++ 5 files changed, 39 insertions(+), 34 deletions(-) diff --git a/docs/source/algorithms/AlignComponents-v1.rst b/docs/source/algorithms/AlignComponents-v1.rst index 9cb85e3d7cf0..11795001924f 100644 --- a/docs/source/algorithms/AlignComponents-v1.rst +++ b/docs/source/algorithms/AlignComponents-v1.rst @@ -20,11 +20,8 @@ the absolute value of the fractional difference between the observed peak center for detector pixel :math:`i` and peak :math:`j`, :math:`DIFC_i * TOF_{i,j}`, and a reference experimental value for the d-spacing of peak :math:`j`, :math:`d^{exp}_j`. The conversion from peak center in TOF units (:math:`TOF_{i,j}`) to d-spacing units is carried out via the -geometrical parameter :math:`DIFC_i`. For reference :math:`DIFC` is - -.. math:: DIFC = \frac{2m_N}{h} L_{tot} sin \theta - -As we change the location and orientations of the instrument components +geometrical parameter :math:`DIFC_i` -- see :ref:`Unit Factory` for more information +regarding this parameter. As we change the location and orientations of the instrument components during the minimization, the geometrical parameter :math:`DIFC_i` is bound to change. Below's an example of the table of peak-center positions in TOF units for a sample having two peaks diff --git a/docs/source/algorithms/EnggFitPeaks-v1.rst b/docs/source/algorithms/EnggFitPeaks-v1.rst index 11b3edfa62b8..7cedb464b3ea 100644 --- a/docs/source/algorithms/EnggFitPeaks-v1.rst +++ b/docs/source/algorithms/EnggFitPeaks-v1.rst @@ -33,36 +33,12 @@ then the algorithm fails. After the conversion of units, the algorithm tries to fit (in time-of-flight) a peak in the neighborhood of every expected peak -using a peak shape or function. If the workspace is focused (single +using a peak shape or function. The conversion is done following GSAS equations +(see :ref:`Unit Factory ` for more details) if the workspace is focused (single spectrum) and has a log entry named "difc", where the GSAS DIFC -parameter is expected, the conversion is done following GSAS equations. -The equation in `GSAS -`_ converts from -d-spacing (:math:`d`) to time-of-flight (:math:`TOF`) by the equation: - -.. math:: TOF = DIFC * d + DIFA * d^2 + TZERO - -The manual describes these terms in more detail. Roughly, -:math:`TZERO` is related to the difference between the measured and -actual time-of-flight base on emission time from the moderator, :math:`DIFA` is an empirical term (ideally zero), and :math:`DIFC` is - -.. math:: DIFC = \frac{2m_N}{h} L_{tot} sin \theta - -Measuring peak positions using a crystal with a very well known -lattice constant will give a good value for converting the data. The -d-spacing of the data will be calculated using whichever equation -below is appropriate for solving the quadratic. - -When :math:`DIFA = 0` then the solution is just for a line and - -.. math:: d = \frac{TOF - TZERO}{DIFC} - -For the case of needing to solve the actual quadratic equation - -.. math:: d = \frac{-DIFC}{2 DIFA} \pm \sqrt{\frac{TOF}{DIFA} + \left(\frac{DIFC}{2 DIFA}\right)^2 - \frac{TZERO}{DIFA}} +parameter is expected. Otherwise the conversion of units is done as in +the Mantid :ref:`ConvertUnits `. -Here the positive root is used when :math:`DIFA > 0` and the negative -when :math:`DIFA < 0`. Otherwise the conversion of units is done as in the Mantid :ref:`ConvertUnits `. diff --git a/docs/source/algorithms/EnggFitTOFFromPeaks-v1.rst b/docs/source/algorithms/EnggFitTOFFromPeaks-v1.rst index faede32ae005..e0e04d20e42f 100644 --- a/docs/source/algorithms/EnggFitTOFFromPeaks-v1.rst +++ b/docs/source/algorithms/EnggFitTOFFromPeaks-v1.rst @@ -39,6 +39,9 @@ If a name is given in OutParametersTable this algorithm also produces a table workspace with that name, containing the parameters fitted (DIFA, DIFC, TZERO). +The parameters DIFA, DIFC, TZERO are also used in other Mantid algorithms. See +:ref:`Unit Factory ` for more details. + Usage ----- diff --git a/docs/source/algorithms/PDCalibration-v1.rst b/docs/source/algorithms/PDCalibration-v1.rst index 621e7421bec7..39ffdbfa7e0c 100644 --- a/docs/source/algorithms/PDCalibration-v1.rst +++ b/docs/source/algorithms/PDCalibration-v1.rst @@ -13,7 +13,7 @@ Description This algorithm takes an ``InputWorkspace`` containing powder diffraction spectra from a standard sample with x-units of time-of-flight (TOF). These spectra are fitted to extract the Bragg peak positions. The extracted peak positions are then used to determine the diffractometer constants that convert diffraction spectra from TOF to d-spacing. These constants are described in detail -in :ref:`algm-EnggFitPeaks`. The number of the constants being determined (1,2,or 3) is controlled by ``CalibrationParameters``. +in :ref:`Unit Factory`. The number of the constants being determined (1,2,or 3) is controlled by ``CalibrationParameters``. The results are output to a :ref:`diffraction calibration workspace `. Unlike other calibration algorithms (see `Time-of-Flight Powder Diffraction Calibration <../concepts/calibration/PowderDiffractionCalibration.html>`_), diff --git a/docs/source/concepts/UnitFactory.rst b/docs/source/concepts/UnitFactory.rst index f5795c657596..bd4514d71347 100644 --- a/docs/source/concepts/UnitFactory.rst +++ b/docs/source/concepts/UnitFactory.rst @@ -81,6 +81,35 @@ of :math:`\mu s` per :math:`\mathrm{\AA}`. of angular and wavelength-dispersive neutron time-of-flight powder diffraction data. Together with the d-Spacing :math:`d`, d-SpacingPerpendicular :math:`d_{\perp}` forms a new orthogonal coordinate system. +**Note on converting time-of-flight to dSpacing using GSAS** +The equation in `GSAS +`_ converts from +d-spacing (:math:`d`) to time-of-flight (:math:`TOF`) by the equation: + +.. math:: TOF = DIFC * d + DIFA * d^2 + TZERO + +The manual describes these terms in more detail. Roughly, +:math:`TZERO` is related to the difference between the measured and +actual time-of-flight base on emission time from the moderator, :math:`DIFA` is an empirical term (ideally zero), and :math:`DIFC` is + +.. math:: DIFC = \frac{2m_N}{h} L_{tot} sin \theta + +Measuring peak positions using a crystal with a very well known +lattice constant will give a good value for converting the data. The +d-spacing of the data will be calculated using whichever equation +below is appropriate for solving the quadratic. + +When :math:`DIFA = 0` then the solution is just for a line and + +.. math:: d = \frac{TOF - TZERO}{DIFC} + +For the case of needing to solve the actual quadratic equation + +.. math:: d = \frac{-DIFC}{2 DIFA} \pm \sqrt{\frac{TOF}{DIFA} + \left(\frac{DIFC}{2 DIFA}\right)^2 - \frac{TZERO}{DIFA}} + +Here the positive root is used when :math:`DIFA > 0` and the negative +when :math:`DIFA < 0`. + Available non-TOF Convertible units ----------------------------------- From aef03e96ab1653aae5825e743024f347bfc8bc6b Mon Sep 17 00:00:00 2001 From: sf1919 Date: Wed, 14 Aug 2024 14:52:23 +0100 Subject: [PATCH 07/27] Add mention of ApplyDiffCal algorithm in PDCalibration documentation --- docs/source/algorithms/PDCalibration-v1.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/source/algorithms/PDCalibration-v1.rst b/docs/source/algorithms/PDCalibration-v1.rst index 39ffdbfa7e0c..cbf41e88f186 100644 --- a/docs/source/algorithms/PDCalibration-v1.rst +++ b/docs/source/algorithms/PDCalibration-v1.rst @@ -43,7 +43,8 @@ When not specified using the ``MaskWorkspace`` parameter, the default name for t The resulting calibration table can be saved with :ref:`algm-SaveDiffCal`, loaded with :ref:`algm-LoadDiffCal` and -applied to a workspace with :ref:`algm-ConvertUnits`. There are also +applied to a workspace with :ref:`algm-ConvertUnits`. The calibration can also be used with :ref:`algm-ApplyDiffCal` which uses the calibration table +and updates the diffractometer constants in the ``UnitParams`` map of the workspace that is then used in :ref:`algm-ConvertUnits`. There are also three workspaces placed in the ``DiagnosticWorkspace`` group. They are: * evaluated fit functions (``_fitted``) which is the ``OutputPeakParametersWorkspace`` from :ref:`FitPeaks ` From 3be459852957e3df08f24cbbe4f931e1b08c4f49 Mon Sep 17 00:00:00 2001 From: sf1919 Date: Wed, 14 Aug 2024 15:39:57 +0100 Subject: [PATCH 08/27] Update calibration concept documentation - Remove references to AlignDetectors from CalFile and PowderDiffractionCalibration. - Replace references where necessary with suitable alternatives --- docs/source/concepts/calibration/CalFile.rst | 3 +-- .../concepts/calibration/PowderDiffractionCalibration.rst | 7 ++----- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/docs/source/concepts/calibration/CalFile.rst b/docs/source/concepts/calibration/CalFile.rst index 503a59383ba5..0593300a3a1f 100644 --- a/docs/source/concepts/calibration/CalFile.rst +++ b/docs/source/concepts/calibration/CalFile.rst @@ -35,8 +35,7 @@ The file is a simple text file with the following format - ``number``: ignored - ``UDET``: detector ID -- ``offset``: calibration offset used in :ref:`AlignDetectors - `. Comes from the ``OffsetsWorkspace``, or 0.0 +- ``offset``: calibration offset. Comes from the ``OffsetsWorkspace``, or 0.0 if none is given. - ``select``: 1 if selected (use the pixel). Comes from the ``MaskWorkspace``, or 1 if none is given. diff --git a/docs/source/concepts/calibration/PowderDiffractionCalibration.rst b/docs/source/concepts/calibration/PowderDiffractionCalibration.rst index 8edbeef606ca..b68593451e9c 100644 --- a/docs/source/concepts/calibration/PowderDiffractionCalibration.rst +++ b/docs/source/concepts/calibration/PowderDiffractionCalibration.rst @@ -34,10 +34,7 @@ the rest of the instrument to. The main algorithm that does this is 1. :ref:`Load ` the calibration data 2. Convert the X-Units to d-spacing using :ref:`ConvertUnits `. The "offsets" calculated are relative - reference spectrum's geometry so using :ref:`AlignDetectors - ` will violate the assumptions for other - algorithms used with time-of-flight powder diffraction and give the - wrong results for focused data. + reference spectrum's geometry. 3. Run :ref:`Rebin ` to set a common d-spacing bin structure across all of the spectra, you will need fine enough bins to allow fitting of your peak. Whatever you choose, make a note of @@ -597,7 +594,7 @@ The easiest way to do this is to apply the calibration to your calibration data and check that the bragg peaks align as expected. 1. Load the calibration data using :ref:`Load ` -2. Run :ref:`AlignDetectors `, this will convert the data to d-spacing and apply the calibration. You can provide the calibration using the ``CalibrationFile``, the ``CalibrationWorkspace``, or ``OffsetsWorkspace``. +2. Run :ref:`ConvertUnits `, this will convert the data to d-spacing and apply the calibration. You can provide the calibration using the ``CalibrationFile``, the ``CalibrationWorkspace``, or ``OffsetsWorkspace``. 3. Plot the workspace as a Color Fill plot, in the spectrum view, or a few spectra in a line plot. Further insight can be gained by comparing the grouped (after aligning From 4616174e9d9498cb30cfcc76722e632871e9fd33 Mon Sep 17 00:00:00 2001 From: sf1919 Date: Mon, 19 Aug 2024 10:14:26 +0100 Subject: [PATCH 09/27] Update DiffractionFocussing2 - DiffractionFocussing2 made reference to using AlignDetectors. This has been changed to ConvertUnits - The associated test used AlignDetectors. This has been changed to ConvertUnits and variables renamed accordingly - Updated DiffractionFocussing2 documentation --- .../MantidAlgorithms/DiffractionFocussing2.h | 2 +- .../test/DiffractionFocussing2Test.h | 18 +++++++++--------- .../algorithms/DiffractionFocussing-v2.rst | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Framework/Algorithms/inc/MantidAlgorithms/DiffractionFocussing2.h b/Framework/Algorithms/inc/MantidAlgorithms/DiffractionFocussing2.h index 734ecabcabed..9cc38b63c7f9 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/DiffractionFocussing2.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/DiffractionFocussing2.h @@ -29,7 +29,7 @@ namespace Algorithms { detector, the third column corresponds to an offset in Deltad/d (not applied, usually applied using - the AlignDetectors algorithm). The forth column is a flag to indicate whether + the ConvertUnits algorithm). The forth column is a flag to indicate whether the detector is selected. The fifth column indicates the group this detector belongs to (number >=1), diff --git a/Framework/Algorithms/test/DiffractionFocussing2Test.h b/Framework/Algorithms/test/DiffractionFocussing2Test.h index 34929f024d1b..a5bfe0fa94b7 100644 --- a/Framework/Algorithms/test/DiffractionFocussing2Test.h +++ b/Framework/Algorithms/test/DiffractionFocussing2Test.h @@ -8,7 +8,7 @@ #include "MantidAPI/FrameworkManager.h" #include "MantidAPI/SpectraAxis.h" -#include "MantidAlgorithms/AlignDetectors.h" +#include "MantidAlgorithms/ConvertUnits.h" #include "MantidAlgorithms/DiffractionFocussing2.h" #include "MantidAlgorithms/MaskBins.h" #include "MantidAlgorithms/Rebin.h" @@ -52,14 +52,14 @@ class DiffractionFocussing2Test : public CxxTest::TestSuite { TS_ASSERT_THROWS_NOTHING(loader.execute()); TS_ASSERT(loader.isExecuted()); - // Have to align because diffraction focussing wants d-spacing - Mantid::Algorithms::AlignDetectors align; - align.initialize(); - align.setPropertyValue("InputWorkspace", outputSpace); - align.setPropertyValue("OutputWorkspace", outputSpace); - align.setPropertyValue("CalibrationFile", "hrpd_new_072_01.cal"); - TS_ASSERT_THROWS_NOTHING(align.execute()); - TS_ASSERT(align.isExecuted()); + // Have to convert units because diffraction focussing wants d-spacing + Mantid::Algorithms::ConvertUnits convert; + convert.initialize(); + convert.setPropertyValue("InputWorkspace", outputSpace); + convert.setPropertyValue("OutputWorkspace", outputSpace); + convert.setPropertyValue("CalibrationFile", "hrpd_new_072_01.cal"); + TS_ASSERT_THROWS_NOTHING(convert.execute()); + TS_ASSERT(convert.isExecuted()); focus.setPropertyValue("InputWorkspace", outputSpace); focus.setPropertyValue("OutputWorkspace", "focusedWS"); diff --git a/docs/source/algorithms/DiffractionFocussing-v2.rst b/docs/source/algorithms/DiffractionFocussing-v2.rst index b340dd9e2cee..69774e192342 100644 --- a/docs/source/algorithms/DiffractionFocussing-v2.rst +++ b/docs/source/algorithms/DiffractionFocussing-v2.rst @@ -80,7 +80,7 @@ Usage cal_file = "hrpd_new_072_01_corr.cal" # For HRPD data, perform a unit conversion TOF->d-spacing, taking into account detector position offsets - ws = AlignDetectors(InputWorkspace='ws',CalibrationFile=cal_file) + ws = ConvertUnits(InputWorkspace='ws',CalibrationFile=cal_file) # Focus the data ws = DiffractionFocussing(InputWorkspace='ws',GroupingFileName=cal_file) From 1bf7cda5d71e9446b583c0c2d7010134c15b2fd6 Mon Sep 17 00:00:00 2001 From: sf1919 Date: Mon, 19 Aug 2024 13:32:06 +0100 Subject: [PATCH 10/27] Add ApplyDIffCal to DiffractionFocussing2 - ConvertUnits is not a direct swap with AlignDetectors. Instead a combination of ApplyDIffCal and ConvertUnits is needed. This makes that fix, --- .../Algorithms/test/DiffractionFocussing2Test.h | 13 +++++++++++-- docs/source/algorithms/DiffractionFocussing-v2.rst | 3 ++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Framework/Algorithms/test/DiffractionFocussing2Test.h b/Framework/Algorithms/test/DiffractionFocussing2Test.h index a5bfe0fa94b7..5321799acf23 100644 --- a/Framework/Algorithms/test/DiffractionFocussing2Test.h +++ b/Framework/Algorithms/test/DiffractionFocussing2Test.h @@ -12,6 +12,7 @@ #include "MantidAlgorithms/DiffractionFocussing2.h" #include "MantidAlgorithms/MaskBins.h" #include "MantidAlgorithms/Rebin.h" +#include "MantidDataHandling/ApplyDiffCal.h" #include "MantidDataHandling/LoadNexus.h" #include "MantidDataHandling/LoadRaw3.h" #include "MantidDataObjects/EventWorkspace.h" @@ -52,12 +53,20 @@ class DiffractionFocussing2Test : public CxxTest::TestSuite { TS_ASSERT_THROWS_NOTHING(loader.execute()); TS_ASSERT(loader.isExecuted()); - // Have to convert units because diffraction focussing wants d-spacing + Mantid::DataHandling::ApplyDiffCal applyDiffCal; + applyDiffCal.setChild(true); + applyDiffCal.initialize(); + applyDiffCal.setPropertyValue("InstrumentWorkspace", outputSpace); + applyDiffCal.setPropertyValue("CalibrationFile", "hrpd_new_072_01.cal"); + TS_ASSERT_THROWS_NOTHING(applyDiffCal.execute()); + TS_ASSERT(applyDiffCal.isExecuted()); + + // Have to convert because diffraction focussing wants d-spacing Mantid::Algorithms::ConvertUnits convert; convert.initialize(); convert.setPropertyValue("InputWorkspace", outputSpace); convert.setPropertyValue("OutputWorkspace", outputSpace); - convert.setPropertyValue("CalibrationFile", "hrpd_new_072_01.cal"); + convert.setPropertyValue("Target", "dSpacing"); TS_ASSERT_THROWS_NOTHING(convert.execute()); TS_ASSERT(convert.isExecuted()); diff --git a/docs/source/algorithms/DiffractionFocussing-v2.rst b/docs/source/algorithms/DiffractionFocussing-v2.rst index 69774e192342..59d47f21ea13 100644 --- a/docs/source/algorithms/DiffractionFocussing-v2.rst +++ b/docs/source/algorithms/DiffractionFocussing-v2.rst @@ -80,7 +80,8 @@ Usage cal_file = "hrpd_new_072_01_corr.cal" # For HRPD data, perform a unit conversion TOF->d-spacing, taking into account detector position offsets - ws = ConvertUnits(InputWorkspace='ws',CalibrationFile=cal_file) + ws = ApplyDiffCal(InstrumentWorkspace='ws', CalibrationFile=cal_file) + ws = ConvertUnits(InputWorkspace='ws', Target="dSpacing") # Focus the data ws = DiffractionFocussing(InputWorkspace='ws',GroupingFileName=cal_file) From 1489a7d65e8b47749489a270a4e79911c5eabad7 Mon Sep 17 00:00:00 2001 From: sf1919 Date: Wed, 28 Aug 2024 14:42:55 +0100 Subject: [PATCH 11/27] Remove see also references Remove links from other algorithms for AlignDetectors under the 'see also' section --- .../Algorithms/inc/MantidAlgorithms/CreateCalFileByNames.h | 2 +- .../Algorithms/inc/MantidAlgorithms/CreateDummyCalFile.h | 2 +- .../Algorithms/inc/MantidAlgorithms/ReadGroupsFromFile.h | 2 +- Framework/DataHandling/inc/MantidDataHandling/ApplyDiffCal.h | 4 +--- Framework/DataHandling/inc/MantidDataHandling/LoadCalFile.h | 4 ++-- Framework/DataHandling/inc/MantidDataHandling/SaveCalFile.h | 4 ++-- .../plugins/algorithms/BASISCrystalDiffraction.py | 2 +- .../PythonInterface/plugins/algorithms/BASISDiffraction.py | 2 +- Framework/PythonInterface/plugins/algorithms/EnggFocus.py | 2 +- .../plugins/algorithms/MaskWorkspaceToCalFile.py | 1 - Framework/PythonInterface/plugins/algorithms/MergeCalFiles.py | 1 - .../WorkflowAlgorithms/CorelliPowderCalibrationCreate.py | 2 +- .../WorkflowAlgorithms/ISISIndirectDiffractionReduction.py | 2 +- 13 files changed, 13 insertions(+), 17 deletions(-) diff --git a/Framework/Algorithms/inc/MantidAlgorithms/CreateCalFileByNames.h b/Framework/Algorithms/inc/MantidAlgorithms/CreateCalFileByNames.h index 5aefbe4032d1..35beb07a14f5 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/CreateCalFileByNames.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/CreateCalFileByNames.h @@ -59,7 +59,7 @@ class MANTID_ALGORITHMS_DLL CreateCalFileByNames final : public API::Algorithm { /// Algorithm's version int version() const override { return (1); } const std::vector seeAlso() const override { - return {"ReadGroupsFromFile", "CreateDummyCalFile", "AlignDetectors", "DiffractionFocussing", + return {"ReadGroupsFromFile", "CreateDummyCalFile", "DiffractionFocussing", "LoadCalFile", "SaveCalFile", "MergeCalFiles"}; } /// Algorithm's category for identification diff --git a/Framework/Algorithms/inc/MantidAlgorithms/CreateDummyCalFile.h b/Framework/Algorithms/inc/MantidAlgorithms/CreateDummyCalFile.h index 0d9e6f252e5b..60bf4876bc3c 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/CreateDummyCalFile.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/CreateDummyCalFile.h @@ -58,7 +58,7 @@ class MANTID_ALGORITHMS_DLL CreateDummyCalFile final : public API::Algorithm { /// Algorithm's version int version() const override { return (1); } const std::vector seeAlso() const override { - return {"ReadGroupsFromFile", "CreateCalFileByNames", "AlignDetectors", "DiffractionFocussing", + return {"ReadGroupsFromFile", "CreateCalFileByNames", "DiffractionFocussing", "LoadCalFile", "SaveCalFile", "MergeCalFiles"}; } /// Algorithm's category for identification diff --git a/Framework/Algorithms/inc/MantidAlgorithms/ReadGroupsFromFile.h b/Framework/Algorithms/inc/MantidAlgorithms/ReadGroupsFromFile.h index 3cd4172e0eaa..3e2e8afa7d07 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/ReadGroupsFromFile.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/ReadGroupsFromFile.h @@ -76,7 +76,7 @@ class MANTID_ALGORITHMS_DLL ReadGroupsFromFile final : public API::Algorithm { /// Algorithm's version int version() const override { return (1); } const std::vector seeAlso() const override { - return {"CreateDummyCalFile", "CreateCalFileByNames", "AlignDetectors", "DiffractionFocussing", + return {"CreateDummyCalFile", "CreateCalFileByNames", "DiffractionFocussing", "LoadCalFile", "SaveCalFile", "MergeCalFiles"}; } /// Algorithm's category for identification diff --git a/Framework/DataHandling/inc/MantidDataHandling/ApplyDiffCal.h b/Framework/DataHandling/inc/MantidDataHandling/ApplyDiffCal.h index 2e52c24e5573..05f6421e1cb9 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/ApplyDiffCal.h +++ b/Framework/DataHandling/inc/MantidDataHandling/ApplyDiffCal.h @@ -21,9 +21,7 @@ class MANTID_DATAHANDLING_DLL ApplyDiffCal final : public API::Algorithm { public: const std::string name() const override; int version() const override; - const std::vector seeAlso() const override { - return {"AlignDetectors", "ConvertDiffCal", "ConvertUnits", "LoadDiffCal"}; - } + const std::vector seeAlso() const override { return {"ConvertDiffCal", "ConvertUnits", "LoadDiffCal"}; } const std::string category() const override; const std::string summary() const override; /// Cross-check properties with each other @see IAlgorithm::validateInputs diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadCalFile.h b/Framework/DataHandling/inc/MantidDataHandling/LoadCalFile.h index fb56056e29a5..0e34d5c4d44c 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadCalFile.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadCalFile.h @@ -37,8 +37,8 @@ class MANTID_DATAHANDLING_DLL LoadCalFile final : public API::Algorithm { /// Algorithm's version for identification int version() const override { return 1; }; const std::vector seeAlso() const override { - return {"LoadDiffCal", "ReadGroupsFromFile", "CreateDummyCalFile", "CreateCalFileByNames", - "AlignDetectors", "DiffractionFocussing", "SaveCalFile", "MergeCalFiles"}; + return {"LoadDiffCal", "ReadGroupsFromFile", "CreateDummyCalFile", "CreateCalFileByNames", + "DiffractionFocussing", "SaveCalFile", "MergeCalFiles"}; } /// Algorithm's category for identification const std::string category() const override { return R"(DataHandling\Text;Diffraction\DataHandling\CalFiles)"; } diff --git a/Framework/DataHandling/inc/MantidDataHandling/SaveCalFile.h b/Framework/DataHandling/inc/MantidDataHandling/SaveCalFile.h index 7ad72cdcada2..54b88d098385 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/SaveCalFile.h +++ b/Framework/DataHandling/inc/MantidDataHandling/SaveCalFile.h @@ -35,8 +35,8 @@ class MANTID_DATAHANDLING_DLL SaveCalFile final : public API::Algorithm { /// Algorithm's version for identification int version() const override { return 1; }; const std::vector seeAlso() const override { - return {"SaveDiffCal", "ReadGroupsFromFile", "CreateDummyCalFile", "CreateCalFileByNames", - "AlignDetectors", "DiffractionFocussing", "LoadCalFile", "MergeCalFiles"}; + return {"SaveDiffCal", "ReadGroupsFromFile", "CreateDummyCalFile", "CreateCalFileByNames", + "DiffractionFocussing", "LoadCalFile", "MergeCalFiles"}; } /// Algorithm's category for identification const std::string category() const override { return R"(DataHandling\Text;Diffraction\DataHandling\CalFiles)"; } diff --git a/Framework/PythonInterface/plugins/algorithms/BASISCrystalDiffraction.py b/Framework/PythonInterface/plugins/algorithms/BASISCrystalDiffraction.py index 7150714e2e9f..04a69d2d440a 100644 --- a/Framework/PythonInterface/plugins/algorithms/BASISCrystalDiffraction.py +++ b/Framework/PythonInterface/plugins/algorithms/BASISCrystalDiffraction.py @@ -139,7 +139,7 @@ def summary(): @staticmethod def seeAlso(): - return ["AlignDetectors", "DiffractionFocussing", "SNSPowderReduction"] + return ["DiffractionFocussing", "SNSPowderReduction"] @staticmethod def _run_list(runs): diff --git a/Framework/PythonInterface/plugins/algorithms/BASISDiffraction.py b/Framework/PythonInterface/plugins/algorithms/BASISDiffraction.py index 3ae6bf4cdb3c..86c22683e84e 100644 --- a/Framework/PythonInterface/plugins/algorithms/BASISDiffraction.py +++ b/Framework/PythonInterface/plugins/algorithms/BASISDiffraction.py @@ -129,7 +129,7 @@ def summary(self): return DEPRECATION_NOTICE def seeAlso(self): - return ["AlignDetectors", "DiffractionFocussing", "SNSPowderReduction"] + return ["DiffractionFocussing", "SNSPowderReduction"] def PyInit(self): # Input validators diff --git a/Framework/PythonInterface/plugins/algorithms/EnggFocus.py b/Framework/PythonInterface/plugins/algorithms/EnggFocus.py index 0bce9a734d12..758348a96310 100644 --- a/Framework/PythonInterface/plugins/algorithms/EnggFocus.py +++ b/Framework/PythonInterface/plugins/algorithms/EnggFocus.py @@ -17,7 +17,7 @@ def category(self): return "Diffraction\\Engineering" def seeAlso(self): - return ["AlignDetectors", "DiffractionFocussing"] + return ["DiffractionFocussing"] def name(self): return "EnggFocus" diff --git a/Framework/PythonInterface/plugins/algorithms/MaskWorkspaceToCalFile.py b/Framework/PythonInterface/plugins/algorithms/MaskWorkspaceToCalFile.py index ae86ae3665b8..c7f8ac9e0965 100644 --- a/Framework/PythonInterface/plugins/algorithms/MaskWorkspaceToCalFile.py +++ b/Framework/PythonInterface/plugins/algorithms/MaskWorkspaceToCalFile.py @@ -33,7 +33,6 @@ def seeAlso(self): "ReadGroupsFromFile", "CreateDummyCalFile", "CreateCalFileByNames", - "AlignDetectors", "DiffractionFocussing", "LoadCalFile", "SaveCalFile", diff --git a/Framework/PythonInterface/plugins/algorithms/MergeCalFiles.py b/Framework/PythonInterface/plugins/algorithms/MergeCalFiles.py index 8e57d985cd1e..fd24d2059848 100644 --- a/Framework/PythonInterface/plugins/algorithms/MergeCalFiles.py +++ b/Framework/PythonInterface/plugins/algorithms/MergeCalFiles.py @@ -17,7 +17,6 @@ def seeAlso(self): "ReadGroupsFromFile", "CreateDummyCalFile", "CreateCalFileByNames", - "AlignDetectors", "DiffractionFocussing", "LoadCalFile", "SaveCalFile", diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/CorelliPowderCalibrationCreate.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/CorelliPowderCalibrationCreate.py index 74774a32d419..1bbb14dd03fc 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/CorelliPowderCalibrationCreate.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/CorelliPowderCalibrationCreate.py @@ -123,7 +123,7 @@ def category(self): return "Diffraction\\Reduction" def seeAlso(self): - return ["PDCalibration", "AlignDetectors", "AlignComponents"] + return ["PDCalibration", "AlignComponents"] def summary(self): return "Adjust bank positions and orientations to optimize peak determination in d-spacing" diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ISISIndirectDiffractionReduction.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ISISIndirectDiffractionReduction.py index 8a27d5becf28..6286aa5a32ff 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ISISIndirectDiffractionReduction.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ISISIndirectDiffractionReduction.py @@ -107,7 +107,7 @@ def summary(self): return "Performs a diffraction reduction for a set of raw run files for an ISIS indirect spectrometer" def seeAlso(self): - return ["AlignDetectors", "DiffractionFocussing", "SNSPowderReduction"] + return ["DiffractionFocussing", "SNSPowderReduction"] # ------------------------------------------------------------------------------ From 284ddbe5207454da570b07276415dca0e54f987f Mon Sep 17 00:00:00 2001 From: sf1919 Date: Wed, 28 Aug 2024 14:57:46 +0100 Subject: [PATCH 12/27] Update the gem_routines/gem_calibration_algs script - Remove AlignDetectors and replace with ApplyDiffCal and COnvertUnits algorithms --- .../isis_powder/gem_routines/gem_calibration_algs.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/Diffraction/isis_powder/gem_routines/gem_calibration_algs.py b/scripts/Diffraction/isis_powder/gem_routines/gem_calibration_algs.py index eb34e8f82c3b..06bd1b2e100a 100644 --- a/scripts/Diffraction/isis_powder/gem_routines/gem_calibration_algs.py +++ b/scripts/Diffraction/isis_powder/gem_routines/gem_calibration_algs.py @@ -138,7 +138,8 @@ def _calibration_processing( InputWorkspace=cross_correlated, GroupingFileName=offset_file, OutputWorkspace=offsets_ws_name, **get_det_offset_params ) rebinned_tof = mantid.ConvertUnits(InputWorkspace=rebinned, Target="TOF") - aligned = mantid.AlignDetectors(InputWorkspace=rebinned_tof, CalibrationFile=offset_file) + applyDiffCal = mantid.ApplyDiffCal(InputWorkspace=rebinned_tof, CalibrationFile=offset_file) + aligned = mantid.ConvertUnits(InputWorkspace=applyDiffCal, Target="dSpacing") grouping_file = os.path.join(calibration_dir, grouping_file_name) focused = mantid.DiffractionFocussing( InputWorkspace=aligned, From b70f8efe5acad45bd5557aae24cd4de48abdb480 Mon Sep 17 00:00:00 2001 From: sf1919 Date: Wed, 28 Aug 2024 15:00:53 +0100 Subject: [PATCH 13/27] Remove AlignDetectors from WishAnalysis System test - Replaced with ApplyDiffCal and ConvertUnits algorithms --- Testing/SystemTests/tests/framework/WishAnalysis.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Testing/SystemTests/tests/framework/WishAnalysis.py b/Testing/SystemTests/tests/framework/WishAnalysis.py index 29ed81441cd0..25b839665f82 100644 --- a/Testing/SystemTests/tests/framework/WishAnalysis.py +++ b/Testing/SystemTests/tests/framework/WishAnalysis.py @@ -64,9 +64,8 @@ def runTest(self): # align detectors ConvertUnits(InputWorkspace="w16748-1", OutputWorkspace="w16748-1", Target="TOF") ReplaceSpecialValues(InputWorkspace="w16748-1", OutputWorkspace="w16748-1", NaNValue="0", InfinityValue="0") - AlignDetectors( - InputWorkspace="w16748-1", OutputWorkspace="w16748-1", CalibrationFile="wish_grouping_noends2_no_offsets_nov2009.cal" - ) + ApplyDiffCal(InputWorkspace="w16748-1", OutputWorkspace="w16748-1", CalibrationFile="wish_grouping_noends2_no_offsets_nov2009.cal") + AConvertUnits(InputWorkspace="w16748-1", OutputWorkspace="w16748-1", Target="d-spacing") # focus data DiffractionFocussing( InputWorkspace="w16748-1", OutputWorkspace="w16748-1foc", GroupingFileName="wish_grouping_noends2_no_offsets_nov2009.cal" From 058db30e3803bdc00bca7d1a7dcb8bf542d9f600 Mon Sep 17 00:00:00 2001 From: sf1919 Date: Mon, 2 Sep 2024 12:18:36 +0100 Subject: [PATCH 14/27] Use correct parameters for ApplyDiffCal - ApplyDiffCal does not take an InputWorkspace. Instead it takes an InstrumentWorkspace. --- Testing/SystemTests/tests/framework/WishAnalysis.py | 4 +++- .../isis_powder/gem_routines/gem_calibration_algs.py | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Testing/SystemTests/tests/framework/WishAnalysis.py b/Testing/SystemTests/tests/framework/WishAnalysis.py index 25b839665f82..0865963568e1 100644 --- a/Testing/SystemTests/tests/framework/WishAnalysis.py +++ b/Testing/SystemTests/tests/framework/WishAnalysis.py @@ -64,7 +64,9 @@ def runTest(self): # align detectors ConvertUnits(InputWorkspace="w16748-1", OutputWorkspace="w16748-1", Target="TOF") ReplaceSpecialValues(InputWorkspace="w16748-1", OutputWorkspace="w16748-1", NaNValue="0", InfinityValue="0") - ApplyDiffCal(InputWorkspace="w16748-1", OutputWorkspace="w16748-1", CalibrationFile="wish_grouping_noends2_no_offsets_nov2009.cal") + ApplyDiffCal( + InstrumentWorkspace="w16748-1", OutputWorkspace="w16748-1", CalibrationFile="wish_grouping_noends2_no_offsets_nov2009.cal" + ) AConvertUnits(InputWorkspace="w16748-1", OutputWorkspace="w16748-1", Target="d-spacing") # focus data DiffractionFocussing( diff --git a/scripts/Diffraction/isis_powder/gem_routines/gem_calibration_algs.py b/scripts/Diffraction/isis_powder/gem_routines/gem_calibration_algs.py index 06bd1b2e100a..7c42b26f67b2 100644 --- a/scripts/Diffraction/isis_powder/gem_routines/gem_calibration_algs.py +++ b/scripts/Diffraction/isis_powder/gem_routines/gem_calibration_algs.py @@ -138,7 +138,7 @@ def _calibration_processing( InputWorkspace=cross_correlated, GroupingFileName=offset_file, OutputWorkspace=offsets_ws_name, **get_det_offset_params ) rebinned_tof = mantid.ConvertUnits(InputWorkspace=rebinned, Target="TOF") - applyDiffCal = mantid.ApplyDiffCal(InputWorkspace=rebinned_tof, CalibrationFile=offset_file) + applyDiffCal = mantid.ApplyDiffCal(InstrumentWorkspace=rebinned_tof, CalibrationFile=offset_file) aligned = mantid.ConvertUnits(InputWorkspace=applyDiffCal, Target="dSpacing") grouping_file = os.path.join(calibration_dir, grouping_file_name) focused = mantid.DiffractionFocussing( From 8454905b047b2125a059b24e1a070c04c3f4c06f Mon Sep 17 00:00:00 2001 From: sf1919 Date: Mon, 2 Sep 2024 15:22:15 +0100 Subject: [PATCH 15/27] More documentation cleaning - Removed link to alignDetectors from See Also in SaveGDA - Removed reference from explanation of OffsetsWorkspace --- Framework/DataHandling/src/SaveGDA.cpp | 2 +- Framework/DataObjects/inc/MantidDataObjects/OffsetsWorkspace.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Framework/DataHandling/src/SaveGDA.cpp b/Framework/DataHandling/src/SaveGDA.cpp index 629a0c155a95..25e70e221451 100644 --- a/Framework/DataHandling/src/SaveGDA.cpp +++ b/Framework/DataHandling/src/SaveGDA.cpp @@ -93,7 +93,7 @@ const std::string SaveGDA::summary() const { int SaveGDA::version() const { return 1; } -const std::vector SaveGDA::seeAlso() const { return {"SaveBankScatteringAngles", "AlignDetectors"}; } +const std::vector SaveGDA::seeAlso() const { return {"SaveBankScatteringAngles"}; } const std::string SaveGDA::category() const { return "DataHandling\\Text;Diffraction\\DataHandling"; } diff --git a/Framework/DataObjects/inc/MantidDataObjects/OffsetsWorkspace.h b/Framework/DataObjects/inc/MantidDataObjects/OffsetsWorkspace.h index 1c5340b7b447..b7e93c3ccaf3 100644 --- a/Framework/DataObjects/inc/MantidDataObjects/OffsetsWorkspace.h +++ b/Framework/DataObjects/inc/MantidDataObjects/OffsetsWorkspace.h @@ -15,7 +15,7 @@ namespace DataObjects { /** An OffsetsWorkspace is a specialized Workspace2D where * the Y value at each pixel is the offset to be used for correcting - * calculations (specifically AlignDetectors). + * calculations. * * @author Janik Zikovsky * @date 2011-05-09 From 34e480fec9d05a6a621dc5505f08c48e7c01da1e Mon Sep 17 00:00:00 2001 From: sf1919 Date: Thu, 5 Sep 2024 14:42:24 +0100 Subject: [PATCH 16/27] Fix problems with WishAnalysis test --- Testing/SystemTests/tests/framework/WishAnalysis.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Testing/SystemTests/tests/framework/WishAnalysis.py b/Testing/SystemTests/tests/framework/WishAnalysis.py index 0865963568e1..c1a0b7795a9f 100644 --- a/Testing/SystemTests/tests/framework/WishAnalysis.py +++ b/Testing/SystemTests/tests/framework/WishAnalysis.py @@ -64,10 +64,8 @@ def runTest(self): # align detectors ConvertUnits(InputWorkspace="w16748-1", OutputWorkspace="w16748-1", Target="TOF") ReplaceSpecialValues(InputWorkspace="w16748-1", OutputWorkspace="w16748-1", NaNValue="0", InfinityValue="0") - ApplyDiffCal( - InstrumentWorkspace="w16748-1", OutputWorkspace="w16748-1", CalibrationFile="wish_grouping_noends2_no_offsets_nov2009.cal" - ) - AConvertUnits(InputWorkspace="w16748-1", OutputWorkspace="w16748-1", Target="d-spacing") + ApplyDiffCal(InstrumentWorkspace="w16748-1", CalibrationFile="wish_grouping_noends2_no_offsets_nov2009.cal") + ConvertUnits(InputWorkspace="w16748-1", OutputWorkspace="w16748-1", Target="d-spacing") # focus data DiffractionFocussing( InputWorkspace="w16748-1", OutputWorkspace="w16748-1foc", GroupingFileName="wish_grouping_noends2_no_offsets_nov2009.cal" From 813a78d36101b066f7be782f525a89ff1e9af0a8 Mon Sep 17 00:00:00 2001 From: sf1919 Date: Mon, 9 Sep 2024 09:35:19 +0100 Subject: [PATCH 17/27] Fix failing system tests --- Testing/SystemTests/tests/framework/WishAnalysis.py | 2 +- .../isis_powder/gem_routines/gem_calibration_algs.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Testing/SystemTests/tests/framework/WishAnalysis.py b/Testing/SystemTests/tests/framework/WishAnalysis.py index c1a0b7795a9f..4ee5a56d4ace 100644 --- a/Testing/SystemTests/tests/framework/WishAnalysis.py +++ b/Testing/SystemTests/tests/framework/WishAnalysis.py @@ -65,7 +65,7 @@ def runTest(self): ConvertUnits(InputWorkspace="w16748-1", OutputWorkspace="w16748-1", Target="TOF") ReplaceSpecialValues(InputWorkspace="w16748-1", OutputWorkspace="w16748-1", NaNValue="0", InfinityValue="0") ApplyDiffCal(InstrumentWorkspace="w16748-1", CalibrationFile="wish_grouping_noends2_no_offsets_nov2009.cal") - ConvertUnits(InputWorkspace="w16748-1", OutputWorkspace="w16748-1", Target="d-spacing") + ConvertUnits(InputWorkspace="w16748-1", OutputWorkspace="w16748-1", Target="dSpacing") # focus data DiffractionFocussing( InputWorkspace="w16748-1", OutputWorkspace="w16748-1foc", GroupingFileName="wish_grouping_noends2_no_offsets_nov2009.cal" diff --git a/scripts/Diffraction/isis_powder/gem_routines/gem_calibration_algs.py b/scripts/Diffraction/isis_powder/gem_routines/gem_calibration_algs.py index 7c42b26f67b2..f00dfceaf737 100644 --- a/scripts/Diffraction/isis_powder/gem_routines/gem_calibration_algs.py +++ b/scripts/Diffraction/isis_powder/gem_routines/gem_calibration_algs.py @@ -138,8 +138,8 @@ def _calibration_processing( InputWorkspace=cross_correlated, GroupingFileName=offset_file, OutputWorkspace=offsets_ws_name, **get_det_offset_params ) rebinned_tof = mantid.ConvertUnits(InputWorkspace=rebinned, Target="TOF") - applyDiffCal = mantid.ApplyDiffCal(InstrumentWorkspace=rebinned_tof, CalibrationFile=offset_file) - aligned = mantid.ConvertUnits(InputWorkspace=applyDiffCal, Target="dSpacing") + mantid.ApplyDiffCal(InstrumentWorkspace="rebinned_tof", CalibrationFile=offset_file) + aligned = mantid.ConvertUnits(InputWorkspace=rebinned_tof, Target="dSpacing") grouping_file = os.path.join(calibration_dir, grouping_file_name) focused = mantid.DiffractionFocussing( InputWorkspace=aligned, From 0dad46baae15d25005f15badee88c98dae5f0bb6 Mon Sep 17 00:00:00 2001 From: sf1919 Date: Tue, 10 Sep 2024 08:19:01 +0100 Subject: [PATCH 18/27] Add release note --- .../release/v6.11.0/Framework/Algorithms/Removed/37799.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 docs/source/release/v6.11.0/Framework/Algorithms/Removed/37799.rst diff --git a/docs/source/release/v6.11.0/Framework/Algorithms/Removed/37799.rst b/docs/source/release/v6.11.0/Framework/Algorithms/Removed/37799.rst new file mode 100644 index 000000000000..132362c9ec25 --- /dev/null +++ b/docs/source/release/v6.11.0/Framework/Algorithms/Removed/37799.rst @@ -0,0 +1 @@ +- The AlignDetectors algorithm was deprecated in :ref:`Release 6.1 ` and has now been removed. Please use a combination of :ref:`ApplyDiffCal ` and :ref:`ConvertUnits ` instead. \ No newline at end of file From 470e13f6db1bc9fbd673549b15747231ea4fb903 Mon Sep 17 00:00:00 2001 From: sf1919 Date: Tue, 10 Dec 2024 16:33:44 +0000 Subject: [PATCH 19/27] Upate imports in WishAnalyis.py test --- Testing/SystemTests/tests/framework/WishAnalysis.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Testing/SystemTests/tests/framework/WishAnalysis.py b/Testing/SystemTests/tests/framework/WishAnalysis.py index 4ee5a56d4ace..963ad49a072f 100644 --- a/Testing/SystemTests/tests/framework/WishAnalysis.py +++ b/Testing/SystemTests/tests/framework/WishAnalysis.py @@ -7,7 +7,7 @@ # pylint: disable=no-init import systemtesting from mantid.simpleapi import ( - AlignDetectors, + ApplyDiffCal, ConvertFromDistribution, ConvertToDistribution, ConvertUnits, From d4866155a3ca4189fdf411c58151ae2e4a92215a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 10 Dec 2024 16:40:23 +0000 Subject: [PATCH 20/27] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- .../release/v6.11.0/Framework/Algorithms/Removed/37799.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/release/v6.11.0/Framework/Algorithms/Removed/37799.rst b/docs/source/release/v6.11.0/Framework/Algorithms/Removed/37799.rst index 132362c9ec25..d327be642672 100644 --- a/docs/source/release/v6.11.0/Framework/Algorithms/Removed/37799.rst +++ b/docs/source/release/v6.11.0/Framework/Algorithms/Removed/37799.rst @@ -1 +1 @@ -- The AlignDetectors algorithm was deprecated in :ref:`Release 6.1 ` and has now been removed. Please use a combination of :ref:`ApplyDiffCal ` and :ref:`ConvertUnits ` instead. \ No newline at end of file +- The AlignDetectors algorithm was deprecated in :ref:`Release 6.1 ` and has now been removed. Please use a combination of :ref:`ApplyDiffCal ` and :ref:`ConvertUnits ` instead. From 778fa13317bce6c2a092cb1bbc19beca7abf48bf Mon Sep 17 00:00:00 2001 From: sf1919 Date: Fri, 17 Jan 2025 07:46:45 +0000 Subject: [PATCH 21/27] Move release note --- .../Removed => v6.13.0/Framework/Algorithms/Deprecated}/37799.rst | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename docs/source/release/{v6.11.0/Framework/Algorithms/Removed => v6.13.0/Framework/Algorithms/Deprecated}/37799.rst (100%) diff --git a/docs/source/release/v6.11.0/Framework/Algorithms/Removed/37799.rst b/docs/source/release/v6.13.0/Framework/Algorithms/Deprecated/37799.rst similarity index 100% rename from docs/source/release/v6.11.0/Framework/Algorithms/Removed/37799.rst rename to docs/source/release/v6.13.0/Framework/Algorithms/Deprecated/37799.rst From d33526203a77c445fe8d17300f87db05a605acab Mon Sep 17 00:00:00 2001 From: Richard Waite Date: Thu, 30 Jan 2025 17:35:05 +0000 Subject: [PATCH 22/27] Fix WISH system test by clearing calibration Reference file was converted back to TOF so for backwards compatibility need to clear calibration (so uncalibrated FIC used for backward conversion) --- Testing/SystemTests/tests/framework/WishAnalysis.py | 1 + 1 file changed, 1 insertion(+) diff --git a/Testing/SystemTests/tests/framework/WishAnalysis.py b/Testing/SystemTests/tests/framework/WishAnalysis.py index 963ad49a072f..b8d5e78ca11d 100644 --- a/Testing/SystemTests/tests/framework/WishAnalysis.py +++ b/Testing/SystemTests/tests/framework/WishAnalysis.py @@ -66,6 +66,7 @@ def runTest(self): ReplaceSpecialValues(InputWorkspace="w16748-1", OutputWorkspace="w16748-1", NaNValue="0", InfinityValue="0") ApplyDiffCal(InstrumentWorkspace="w16748-1", CalibrationFile="wish_grouping_noends2_no_offsets_nov2009.cal") ConvertUnits(InputWorkspace="w16748-1", OutputWorkspace="w16748-1", Target="dSpacing") + ApplyDiffCal(InstrumentWorkspace="w16748-1", ClearCalibration=True) # focus data DiffractionFocussing( InputWorkspace="w16748-1", OutputWorkspace="w16748-1foc", GroupingFileName="wish_grouping_noends2_no_offsets_nov2009.cal" From 3fb3cdc07ffaf39b5405bed726929e8d4a3b43fe Mon Sep 17 00:00:00 2001 From: Richard Waite Date: Thu, 30 Jan 2025 18:10:38 +0000 Subject: [PATCH 23/27] Fix gem calibration test by clearing calibration Even though the reference is the focussed d-spacing spectrum (so no conversion back to TOF required), the test was failing because the parameter map in the two workspaces was different. --- .../Diffraction/isis_powder/gem_routines/gem_calibration_algs.py | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/Diffraction/isis_powder/gem_routines/gem_calibration_algs.py b/scripts/Diffraction/isis_powder/gem_routines/gem_calibration_algs.py index f00dfceaf737..f5997c27a087 100644 --- a/scripts/Diffraction/isis_powder/gem_routines/gem_calibration_algs.py +++ b/scripts/Diffraction/isis_powder/gem_routines/gem_calibration_algs.py @@ -140,6 +140,7 @@ def _calibration_processing( rebinned_tof = mantid.ConvertUnits(InputWorkspace=rebinned, Target="TOF") mantid.ApplyDiffCal(InstrumentWorkspace="rebinned_tof", CalibrationFile=offset_file) aligned = mantid.ConvertUnits(InputWorkspace=rebinned_tof, Target="dSpacing") + mantid.ApplyDiffCal(InstrumentWorkspace=aligned, ClearCalibration=True) grouping_file = os.path.join(calibration_dir, grouping_file_name) focused = mantid.DiffractionFocussing( InputWorkspace=aligned, From 47af5f50258d3bf75bc0276b1ac53285fab1e372 Mon Sep 17 00:00:00 2001 From: Richard Waite Date: Fri, 31 Jan 2025 09:06:16 +0000 Subject: [PATCH 24/27] Fix doc test still using AlignDetectors --- docs/source/algorithms/DiffractionFocussing-v2.rst | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/source/algorithms/DiffractionFocussing-v2.rst b/docs/source/algorithms/DiffractionFocussing-v2.rst index 59d47f21ea13..62af1a685abe 100644 --- a/docs/source/algorithms/DiffractionFocussing-v2.rst +++ b/docs/source/algorithms/DiffractionFocussing-v2.rst @@ -125,9 +125,11 @@ Output: cal_file = "hrpd_new_072_01_corr.cal" # For HRPD data, perform a unit conversion TOF->d-spacing, taking into account detector position offsets - ws = AlignDetectors(InputWorkspace='ws',CalibrationFile=cal_file) + ApplyDiffCal(InstrumentWorkspace=ws, CalibrationFile=cal_file) + ws = ConvertUnits(InputWorkspace=ws, Target="dSpacing") + ApplyDiffCal(InstrumentWorkspace=ws, ClearCalibration=True) # use uncalibrated DIFC to convert from d-spacing to TOF # Focus the data with defined binning parameters - ws = DiffractionFocussing(InputWorkspace='ws',GroupingFileName=cal_file, DMin=[0.6,1.0,2.2], DMax=[1.0,1.5,4.0], Delta=0.1) + ws = DiffractionFocussing(InputWorkspace=ws,GroupingFileName=cal_file, DMin=[0.6,1.0,2.2], DMax=[1.0,1.5,4.0], Delta=0.1) print(f"Output has {ws.getNumberHistograms()} spectra with number of bins {len(ws.readY(0))}, {len(ws.readY(1))} and {len(ws.readY(2))}") From e824e9e5703bc9cc33dd5665e89ab695a08ef5c6 Mon Sep 17 00:00:00 2001 From: Richard Waite Date: Fri, 31 Jan 2025 09:32:53 +0000 Subject: [PATCH 25/27] Remove references to AlignDetectors in docs and comments etc. --- .../Algorithms/inc/MantidAlgorithms/CreateCalFileByNames.h | 4 ++-- .../Algorithms/inc/MantidAlgorithms/CreateDummyCalFile.h | 2 +- .../Algorithms/inc/MantidAlgorithms/DiffractionFocussing2.h | 4 +--- .../Algorithms/inc/MantidAlgorithms/ReadGroupsFromFile.h | 5 ++--- docs/source/algorithms/CreateCalFileByNames-v1.rst | 2 +- docs/source/algorithms/CreateDummyCalFile-v1.rst | 4 ++-- .../concepts/calibration/PowderDiffractionCalibration.rst | 6 +++--- 7 files changed, 12 insertions(+), 15 deletions(-) diff --git a/Framework/Algorithms/inc/MantidAlgorithms/CreateCalFileByNames.h b/Framework/Algorithms/inc/MantidAlgorithms/CreateCalFileByNames.h index 35beb07a14f5..c66f60066bb9 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/CreateCalFileByNames.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/CreateCalFileByNames.h @@ -22,8 +22,8 @@ namespace Algorithms { * The offsets are all sets to zero and all detectors are selected. Detectors not assigned * to any group will appear as group 0, i.e. not included when using - AlignDetector or - * DiffractionFocussing algorithms. + the + * DiffractionFocussing algorithm. * The group number is assigned based on a descent in the instrument tree assembly. * If two assemblies are parented, say Bank1 and module1, and both assembly diff --git a/Framework/Algorithms/inc/MantidAlgorithms/CreateDummyCalFile.h b/Framework/Algorithms/inc/MantidAlgorithms/CreateDummyCalFile.h index 60bf4876bc3c..4bc9828351f7 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/CreateDummyCalFile.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/CreateDummyCalFile.h @@ -18,7 +18,7 @@ namespace Algorithms { * The offsets are all sets to zero and all detectors are selected. Detectors not assigned * to any group will appear as group 0, i.e. not included when using - AlignDetector or +the * DiffractionFocussing algorithms. * The group number is assigned based on a descent in the instrument tree assembly. diff --git a/Framework/Algorithms/inc/MantidAlgorithms/DiffractionFocussing2.h b/Framework/Algorithms/inc/MantidAlgorithms/DiffractionFocussing2.h index 9cc38b63c7f9..7c1cd80645b5 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/DiffractionFocussing2.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/DiffractionFocussing2.h @@ -74,9 +74,7 @@ class MANTID_ALGORITHMS_DLL DiffractionFocussing2 final : public API::Algorithm /// Algorithm's version for identification overriding a virtual method int version() const override { return 2; } - const std::vector seeAlso() const override { - return {"AlignDetectors", "AlignAndFocusPowder", "LoadCalFile"}; - } + const std::vector seeAlso() const override { return {"AlignAndFocusPowder", "LoadCalFile"}; } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "Diffraction\\Focussing"; } diff --git a/Framework/Algorithms/inc/MantidAlgorithms/ReadGroupsFromFile.h b/Framework/Algorithms/inc/MantidAlgorithms/ReadGroupsFromFile.h index 3e2e8afa7d07..60c79e895468 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/ReadGroupsFromFile.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/ReadGroupsFromFile.h @@ -35,9 +35,8 @@ namespace Algorithms { * 4 621 0.0000000 1 0 * The first column is simply an index, the second is a UDET identifier for the detector, - * the third column corresponds to an offset in Deltad/d (not applied, usually - applied using - * the AlignDetectors algorithm). The forth column is a flag to indicate + * the third column corresponds to an offset in Deltad/d (not applied, this can be interpreted by the ApplyDiffCal + * algorithm). The forth column is a flag to indicate whether the detector * is selected. The fifth column indicates the group this detector belongs to (number >=1), diff --git a/docs/source/algorithms/CreateCalFileByNames-v1.rst b/docs/source/algorithms/CreateCalFileByNames-v1.rst index e968228dbe98..e94dbdceec9f 100644 --- a/docs/source/algorithms/CreateCalFileByNames-v1.rst +++ b/docs/source/algorithms/CreateCalFileByNames-v1.rst @@ -24,7 +24,7 @@ then any existing offsets and selection values will be maintained and only the grouping values changed. Detectors not assigned to any group will appear as group 0, i.e. not -included when using AlignDetector or DiffractionFocussing algorithms. +included when using the DiffractionFocussing algorithm. The group number is assigned based on a descent in the instrument tree assembly. If two assemblies are parented, say Bank1 and module1, and diff --git a/docs/source/algorithms/CreateDummyCalFile-v1.rst b/docs/source/algorithms/CreateDummyCalFile-v1.rst index c1b8fb909dce..b5a59e37ad8c 100644 --- a/docs/source/algorithms/CreateDummyCalFile-v1.rst +++ b/docs/source/algorithms/CreateDummyCalFile-v1.rst @@ -21,8 +21,8 @@ Offsets in the file are all sets to zero and all detectors are selected. Overwrites a calibration file that already exists at the location specified. -Detectors will be assigned to group one when using AlignDetector or -DiffractionFocussing algorithms. +Detectors will be assigned to group one when using the +DiffractionFocussing algorithm. Usage ----- diff --git a/docs/source/concepts/calibration/PowderDiffractionCalibration.rst b/docs/source/concepts/calibration/PowderDiffractionCalibration.rst index b68593451e9c..af8e31eecf6d 100644 --- a/docs/source/concepts/calibration/PowderDiffractionCalibration.rst +++ b/docs/source/concepts/calibration/PowderDiffractionCalibration.rst @@ -659,13 +659,13 @@ This can be done using the following code .. code:: - from mantid.simpleapi import (AlignDetectors, LoadDiffCal, LoadEventNexus, LoadInstrument, Rebin) + from mantid.simpleapi import (ApplyDiffCal, ConvertUnits, LoadEventNexus, LoadInstrument, Rebin) from Calibration.tofpd import diagnostics LoadEventNexus(Filename='VULCAN_192227.nxs.h5', OutputWorkspace='ws') Rebin(InputWorkspace='ws', OutputWorkspace='ws', Params=(5000,-.002,70000)) - LoadDiffCal(Filename='VULCAN_Calibration_CC_4runs_hybrid.h5', InputWorkspace='ws', WorkspaceName='VULCAN') - AlignDetectors(InputWorkspace='ws', OutputWorkspace='ws', CalibrationWorkspace='VULCAN_cal') + ApplyDiffCal(InputWorkspace='ws', CalibrationFile='VULCAN_Calibration_CC_4runs_hybrid.h5') + ConvertUnits(InputWorkspace='ws', Target="dSpacing") diagnostics.plot2d(mtd['ws'], horiz_markers=[8*512*20, 2*8*512*20], xmax=1.3) Here the expected peak positions are vertical lines, the horizontal lines are boundaries between banks. From 25a29f35a144621e44c4451251983f1f5e47c287 Mon Sep 17 00:00:00 2001 From: Richard Waite Date: Tue, 4 Feb 2025 13:53:27 +0000 Subject: [PATCH 26/27] Add calibration section to ConvertUnits Also clarify role of ConvertUnits and ApplyDiffCal in other places in docs --- docs/source/algorithms/ConvertUnits-v1.rst | 16 ++++++++++++++++ docs/source/algorithms/EnggFitPeaks-v1.rst | 4 ---- docs/source/algorithms/PDCalibration-v1.rst | 9 +++++---- docs/source/algorithms/SaveGDA-v1.rst | 2 +- .../calibration/PowderDiffractionCalibration.rst | 7 ++++--- 5 files changed, 26 insertions(+), 12 deletions(-) diff --git a/docs/source/algorithms/ConvertUnits-v1.rst b/docs/source/algorithms/ConvertUnits-v1.rst index 29c962a024cf..d23864bbed1f 100644 --- a/docs/source/algorithms/ConvertUnits-v1.rst +++ b/docs/source/algorithms/ConvertUnits-v1.rst @@ -35,6 +35,22 @@ If ConvertFromPointData is true, an input workspace contains Point data will be converted using :ref:`ConvertToHistogram ` and then the algorithm will be run on the converted workspace. +Applying instrument calibration +############################### + +Some workflows involve applying a calibration in the form of updated detector positions. In the case of +time-of-flight (TOF) diffraction it is also possible to provide detector offsets +(from :ref:`GetDetectorOffsets `) or diffractometer constants +(from :ref:`PDCalibration `) for the conversion between TOF and d-spacing. +For more details on diffractometer constants see :ref:`Unit Factory`, for the relation between offsets and diffractometer +constants see ref:`ConvertDiffCal `. + +:ref:`ApplyDiffCal ` is used to apply a detector calibration in the form of a ``CalibrationFile``, +``CalibrationWorkspace`` or ``OffsetsWorkspace``. Note this calibration will be used to do the conversion from d-spacing +to TOF unless the user calls :ref:`ApplyDiffCal ` again with ``ClearCalibration=True`` after the call +to :ref:`ConvertUnits ` (to reproduce the behaviour of the deprecated ``AlignDetectors`` algorithm). + + Restrictions on the input workspace ################################### diff --git a/docs/source/algorithms/EnggFitPeaks-v1.rst b/docs/source/algorithms/EnggFitPeaks-v1.rst index 7cedb464b3ea..0c614bf9f577 100644 --- a/docs/source/algorithms/EnggFitPeaks-v1.rst +++ b/docs/source/algorithms/EnggFitPeaks-v1.rst @@ -39,10 +39,6 @@ spectrum) and has a log entry named "difc", where the GSAS DIFC parameter is expected. Otherwise the conversion of units is done as in the Mantid :ref:`ConvertUnits `. - -Otherwise the conversion of units is done as in -the Mantid :ref:`ConvertUnits `. - .. seealso:: :ref:`EnggFitTOFFromPeaks `. This algorithm currently fits (single) peaks of type diff --git a/docs/source/algorithms/PDCalibration-v1.rst b/docs/source/algorithms/PDCalibration-v1.rst index cbf41e88f186..1bd07ef11af2 100644 --- a/docs/source/algorithms/PDCalibration-v1.rst +++ b/docs/source/algorithms/PDCalibration-v1.rst @@ -42,10 +42,11 @@ returned. This favors using less parameters. When not specified using the ``MaskWorkspace`` parameter, the default name for the mask workspace will be the ``OutputCalibrationTable`` parameter + ``_mask``. If the mask workspace already exists, its masked values will be combined with those from any uncalibrated pixels detected during the algorithm's execution. The resulting calibration table can be saved with -:ref:`algm-SaveDiffCal`, loaded with :ref:`algm-LoadDiffCal` and -applied to a workspace with :ref:`algm-ConvertUnits`. The calibration can also be used with :ref:`algm-ApplyDiffCal` which uses the calibration table -and updates the diffractometer constants in the ``UnitParams`` map of the workspace that is then used in :ref:`algm-ConvertUnits`. There are also -three workspaces placed in the ``DiagnosticWorkspace`` group. They are: +:ref:`algm-SaveDiffCal`, loaded with :ref:`algm-LoadDiffCal`. +The calibration can be applied to a workspace using :ref:`algm-ApplyDiffCal` which uses the calibration table +and updates the diffractometer constants in the ``UnitParams`` map of the workspace that is then used in :ref:`algm-ConvertUnits` to convert the x-axis of the data from TOF to e.g. d-spacing. + +There are also three workspaces placed in the ``DiagnosticWorkspace`` group. They are: * evaluated fit functions (``_fitted``) which is the ``OutputPeakParametersWorkspace`` from :ref:`FitPeaks ` * raw peak fit values (``_fitparam``) which is the ``FittedPeaksWorkspace`` from :ref:`FitPeaks ` diff --git a/docs/source/algorithms/SaveGDA-v1.rst b/docs/source/algorithms/SaveGDA-v1.rst index 8e53afbc06d6..7117da7c7499 100644 --- a/docs/source/algorithms/SaveGDA-v1.rst +++ b/docs/source/algorithms/SaveGDA-v1.rst @@ -56,7 +56,7 @@ D to TOF Conversion conversion factors for each bank. SaveGDA takes input in D-spacing, and applies the GSAS conversion -(explained at :ref:`EnggFitPeaks `), using +(explained in :ref:`Unit Factory`), using parameters from the calibration file, to convert back to time-of-flight. The caveat here is that, if the calibration file contains the wrong conversion factors, then the TOF values will not diff --git a/docs/source/concepts/calibration/PowderDiffractionCalibration.rst b/docs/source/concepts/calibration/PowderDiffractionCalibration.rst index af8e31eecf6d..244b189ff4b9 100644 --- a/docs/source/concepts/calibration/PowderDiffractionCalibration.rst +++ b/docs/source/concepts/calibration/PowderDiffractionCalibration.rst @@ -593,9 +593,10 @@ reasonable calibration constant for each of the spectra in your data. The easiest way to do this is to apply the calibration to your calibration data and check that the bragg peaks align as expected. -1. Load the calibration data using :ref:`Load ` -2. Run :ref:`ConvertUnits `, this will convert the data to d-spacing and apply the calibration. You can provide the calibration using the ``CalibrationFile``, the ``CalibrationWorkspace``, or ``OffsetsWorkspace``. -3. Plot the workspace as a Color Fill plot, in the spectrum view, or a few spectra in a line plot. +1. Load the instrument data using :ref:`Load ` +2. Apply the calibration to the workspace using :ref:`ApplyDiffCal ` (the calibration can be provided using the ``CalibrationFile``, the ``CalibrationWorkspace``, or ``OffsetsWorkspace``). +3. Run :ref:`ConvertUnits `, to convert the data to d-spacing using the calibration. +4. Plot the workspace as a Color Fill plot, in the spectrum view, or a few spectra in a line plot. Further insight can be gained by comparing the grouped (after aligning and focussing the data) spectra from a previous calibration or convert From 8303ffa7d0dfb138af2367c4e4fa335f2dc679b0 Mon Sep 17 00:00:00 2001 From: Sarah Foxley <55837273+sf1919@users.noreply.github.com> Date: Wed, 12 Feb 2025 09:01:39 +0000 Subject: [PATCH 27/27] Update docs/source/algorithms/ConvertUnits-v1.rst Co-authored-by: Caila Finn <47181718+cailafinn@users.noreply.github.com> --- docs/source/algorithms/ConvertUnits-v1.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/algorithms/ConvertUnits-v1.rst b/docs/source/algorithms/ConvertUnits-v1.rst index d23864bbed1f..2af35cc8f3ff 100644 --- a/docs/source/algorithms/ConvertUnits-v1.rst +++ b/docs/source/algorithms/ConvertUnits-v1.rst @@ -43,7 +43,7 @@ time-of-flight (TOF) diffraction it is also possible to provide detector offsets (from :ref:`GetDetectorOffsets `) or diffractometer constants (from :ref:`PDCalibration `) for the conversion between TOF and d-spacing. For more details on diffractometer constants see :ref:`Unit Factory`, for the relation between offsets and diffractometer -constants see ref:`ConvertDiffCal `. +constants see :ref:`algm-ConvertDiffCal`. :ref:`ApplyDiffCal ` is used to apply a detector calibration in the form of a ``CalibrationFile``, ``CalibrationWorkspace`` or ``OffsetsWorkspace``. Note this calibration will be used to do the conversion from d-spacing