-
Notifications
You must be signed in to change notification settings - Fork 128
Remove AlignDetectors algorithm #37799
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@RichardWaiteSTFC can you examine the commits c3b9e0d and b25ac52 please? I'm not sure if I've made quite the right adjustments in the documentation on these. |
: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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this info should actually live in unit factory docs
https://docs.mantidproject.org/nightly/concepts/UnitFactory.html#unit-factory
or in the ConvertUnits
docs.
This algorithm is no longer used (it pre-dates my work on engineering GUI) - also the name suggest something engineering specific whereas this relates to TOF powder diffraction.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does ConvertUnits actually use DIFC
? I can't see an obvious place to put it in the documentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does yes, it uses the UnitParams
map in the conversions - I think the logic is in Unit.cpp - by default DIFA=TZERO=0 and DIFC is calculated using L1+L2 and sin(theta)
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should also mention ApplyDiffCal
- which actually uses the calibration table and updates the diffractometer constants in the UnitParams
map of the workspace which is then used in ConvertUnits
Currently blocked by #37859 |
3eaf334
to
34d3769
Compare
I'm moving this to 6.12 as there are some issues that I think need to be fixed separately before this one can continue. I'll write up the relevant issues. |
👋 Hi, @sf1919, Conflicts have been detected against the base branch. Please rebase your branch against the base branch. |
- Remove head and main files - Remove references from CMake
- Remove test and reference from CMake
- Removed the User documentation of the algorithm - Removed links from previous release notes - Removed references to the AlignDetectors Algorithm as an example in documentation
- Where possible remove or convert reference to AlignDetectors to ConvertUnits
- 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.
- 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.
- Remove references to AlignDetectors from CalFile and PowderDiffractionCalibration. - Replace references where necessary with suitable alternatives
- 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
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.
) | ||
rebinned_tof = mantid.ConvertUnits(InputWorkspace=rebinned, Target="TOF") | ||
aligned = mantid.AlignDetectors(InputWorkspace=rebinned_tof, CalibrationFile=offset_file) | ||
mantid.ApplyDiffCal(InstrumentWorkspace="rebinned_tof", CalibrationFile=offset_file) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would actually be better to use the offsets workspace (OffsetsWorkspace=offset_ws_name
here). The act of writing to a fixed width column can truncate a number, which in this case can lead to quite large deviations in the data (certainly the y-value in a given bin) relative to typical absolute tolerances used in system tests because the y-values are large and the peak is quite sharp.
Even though the d-spacing of the workspaces calibrated using the file and the offsets workspace differ only by ~1e-8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have kept the use of the offsets file so as to 'fix' the test and preserve the behaviour - in practice this difference in offset used will never be noticed in the refinement, it is only noticeable in system tests. I think the tests interpret the bin edges as matching within tolerance (certainly Minus
works even though the edges differ by ~1e-8)?
|
||
1. Load the calibration data using :ref:`Load <algm-Load>` | ||
2. Run :ref:`AlignDetectors <algm-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 <algm-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``. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this true? I thought ConvertUnits just converted it to d-spacing and the calibration would have to be applied with ApplyDiffCal
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree I think there's a missing step to call ApplyDiffCal
which updates the parameter map on the workspace (i.e. the information used to convert between TOF -> d-spacing) then ConvertUnits
will use this calibration. Previously AlignDetectors
would apply the calibration and then perform the conversion from TOF -> d-spacing but there would be no update of the parameters on the workspace, such that the inverse conversion (from d-spacing -> TOF) would use the un-calibrated DIFC parameter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would also be nice to have that clarified in the docs (docs/source/algorithms/ConvertUnits-v1.rst
) because I don't think it currently mentions anything about calibration
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure how the review functionality works so whether this needs to be separate, but if we could maybe get these changes (#37799 (comment)) to docs/source/concepts/calibration/PowderDiffractionCalibration.rst
and docs/source/algorithms/ConvertUnits-v1.rst
Thanks @andy-bridger for the review, I've added the section you requested in Just a note when reviewing, anywhere in the code where |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No second call of ApplyDiffCal
to ClearCalibration
here, but I'm guessing that is fine because it is just a test and there is no further processing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep I think that's OK because it's checking the focussing produces a workspace with a single histogram - technically the DIFC of the focussed spectrum will be different but that's not part of what is being tested there
Also clarify role of ConvertUnits and ApplyDiffCal in other places in docs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
again I assume it is intentional to the example on L83 that ApplyDiffCal
is not called with ClearCalibration
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep I think that's OK as well because the data are not converted back to TOF in that usage example
f002f3f
to
25a29f3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All looks good now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes looking good, just a couple of quick Q's about the documentation around them:
It doesn't look like we've heard back about VULCAN so I've asked @peterfpeterson for help |
mantid/Framework/DataHandling/src/ApplyDiffCal.cpp Lines 150 to 154 in d1e96c3
mantid/Framework/DataHandling/src/ApplyDiffCal.cpp Lines 122 to 123 in d1e96c3
The only thing that might be an issue is that the calibration is not cleared subsequently, however it looks like there are no future conversions back to TOF in the file so this doesn't matter. On second thought we might as well do it! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm happy if this is merged. I didn't approve so as to not step on toes.
Co-authored-by: Caila Finn <47181718+cailafinn@users.noreply.github.com>
* Remove AlignDetectors algorithm - Remove head and main files - Remove references from CMake * Remove aligndetectorstest - Remove test and reference from CMake * 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 * Remove references for AlignDetectors in algorithm documentation - Where possible remove or convert reference to AlignDetectors to ConvertUnits * 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. * 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. * Add mention of ApplyDiffCal algorithm in PDCalibration documentation * Update calibration concept documentation - Remove references to AlignDetectors from CalFile and PowderDiffractionCalibration. - Replace references where necessary with suitable alternatives * 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 * 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, * Remove see also references Remove links from other algorithms for AlignDetectors under the 'see also' section * Update the gem_routines/gem_calibration_algs script - Remove AlignDetectors and replace with ApplyDiffCal and COnvertUnits algorithms * Remove AlignDetectors from WishAnalysis System test - Replaced with ApplyDiffCal and ConvertUnits algorithms * Use correct parameters for ApplyDiffCal - ApplyDiffCal does not take an InputWorkspace. Instead it takes an InstrumentWorkspace. * More documentation cleaning - Removed link to alignDetectors from See Also in SaveGDA - Removed reference from explanation of OffsetsWorkspace * Fix problems with WishAnalysis test * Fix failing system tests * Add release note * Upate imports in WishAnalyis.py test * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Move release note * 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) * 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. * Fix doc test still using AlignDetectors * Remove references to AlignDetectors in docs and comments etc. * Add calibration section to ConvertUnits Also clarify role of ConvertUnits and ApplyDiffCal in other places in docs * Update docs/source/algorithms/ConvertUnits-v1.rst Co-authored-by: Caila Finn <47181718+cailafinn@users.noreply.github.com> --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Richard Waite <richard.waite@stfc.ac.uk> Co-authored-by: Caila Finn <47181718+cailafinn@users.noreply.github.com>
* Remove AlignDetectors algorithm - Remove head and main files - Remove references from CMake * Remove aligndetectorstest - Remove test and reference from CMake * 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 * Remove references for AlignDetectors in algorithm documentation - Where possible remove or convert reference to AlignDetectors to ConvertUnits * 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. * 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. * Add mention of ApplyDiffCal algorithm in PDCalibration documentation * Update calibration concept documentation - Remove references to AlignDetectors from CalFile and PowderDiffractionCalibration. - Replace references where necessary with suitable alternatives * 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 * 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, * Remove see also references Remove links from other algorithms for AlignDetectors under the 'see also' section * Update the gem_routines/gem_calibration_algs script - Remove AlignDetectors and replace with ApplyDiffCal and COnvertUnits algorithms * Remove AlignDetectors from WishAnalysis System test - Replaced with ApplyDiffCal and ConvertUnits algorithms * Use correct parameters for ApplyDiffCal - ApplyDiffCal does not take an InputWorkspace. Instead it takes an InstrumentWorkspace. * More documentation cleaning - Removed link to alignDetectors from See Also in SaveGDA - Removed reference from explanation of OffsetsWorkspace * Fix problems with WishAnalysis test * Fix failing system tests * Add release note * Upate imports in WishAnalyis.py test * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Move release note * 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) * 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. * Fix doc test still using AlignDetectors * Remove references to AlignDetectors in docs and comments etc. * Add calibration section to ConvertUnits Also clarify role of ConvertUnits and ApplyDiffCal in other places in docs * Update docs/source/algorithms/ConvertUnits-v1.rst Co-authored-by: Caila Finn <47181718+cailafinn@users.noreply.github.com> --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Richard Waite <richard.waite@stfc.ac.uk> Co-authored-by: Caila Finn <47181718+cailafinn@users.noreply.github.com>
* Remove AlignDetectors algorithm - Remove head and main files - Remove references from CMake * Remove aligndetectorstest - Remove test and reference from CMake * 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 * Remove references for AlignDetectors in algorithm documentation - Where possible remove or convert reference to AlignDetectors to ConvertUnits * 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. * 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. * Add mention of ApplyDiffCal algorithm in PDCalibration documentation * Update calibration concept documentation - Remove references to AlignDetectors from CalFile and PowderDiffractionCalibration. - Replace references where necessary with suitable alternatives * 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 * 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, * Remove see also references Remove links from other algorithms for AlignDetectors under the 'see also' section * Update the gem_routines/gem_calibration_algs script - Remove AlignDetectors and replace with ApplyDiffCal and COnvertUnits algorithms * Remove AlignDetectors from WishAnalysis System test - Replaced with ApplyDiffCal and ConvertUnits algorithms * Use correct parameters for ApplyDiffCal - ApplyDiffCal does not take an InputWorkspace. Instead it takes an InstrumentWorkspace. * More documentation cleaning - Removed link to alignDetectors from See Also in SaveGDA - Removed reference from explanation of OffsetsWorkspace * Fix problems with WishAnalysis test * Fix failing system tests * Add release note * Upate imports in WishAnalyis.py test * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Move release note * 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) * 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. * Fix doc test still using AlignDetectors * Remove references to AlignDetectors in docs and comments etc. * Add calibration section to ConvertUnits Also clarify role of ConvertUnits and ApplyDiffCal in other places in docs * Update docs/source/algorithms/ConvertUnits-v1.rst Co-authored-by: Caila Finn <47181718+cailafinn@users.noreply.github.com> --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Richard Waite <richard.waite@stfc.ac.uk> Co-authored-by: Caila Finn <47181718+cailafinn@users.noreply.github.com>
Description of work
Removal of AlignDetectors Algorithm as this has been replaced with ConvertUnits.
Summary of work
Part of #31258
Further detail of work
Deprecated in 2021 - see #30163
To test:
Reviewer
Please comment on the points listed below (full description).
Your comments will be used as part of the gatekeeper process, so please comment clearly on what you have checked during your review. If changes are made to the PR during the review process then your final comment will be the most important for gatekeepers. In this comment you should make it clear why any earlier review is still valid, or confirm that all requested changes have been addressed.
Code Review
Functional Tests
Does everything look good? Mark the review as Approve. A member of
@mantidproject/gatekeepers
will take care of it.Gatekeeper
If you need to request changes to a PR then please add a comment and set the review status to "Request changes". This will stop the PR from showing up in the list for other gatekeepers.