Skip to content
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

Stop ReflectometryReductionOneLiveData from re-writing the spectra map on instrument load #38256

Conversation

rbauststfc
Copy link
Contributor

@rbauststfc rbauststfc commented Oct 21, 2024

Description of work

Summary of work

Changes the step in ReflectometryReductionOneLiveData that loads the instrument so that it doesn't re-write the spectra map, as this can result in spectra being associated with the wrong detectors.

Fixes #38202.

Further detail of work

The live data workspace already has the instrument loaded, but we need to re-load it because many of the Reflectometry IDFs position their pixels based on the theta value in the log. We add this theta value as part of setting up the workspace in ReflectometryReductionOneLiveData, so we then re-load the instrument to apply the changes. Re-writing the spectra map under these circumstances can lead to spectra being associated with the wrong detector pixels. This PR fixes that issue.

There were a few updates/additions required for the unit tests, and I've also refactored the tests in a couple of places to avoid code duplication.

To test:

  1. To prevent the algorithm attempting to look up information from the instrument, edit the code in method _live_value_list, to provide values for _theta_name, _s1vg_name and _s2vg_name:
self._theta_name(): LiveValue(2.3, "deg", self._alternative_theta_name(), LiveValue.LOG_TYPE_NUM_SERIES),
self._s1vg_name(): LiveValue(1.0, "m", self._alternative_s1vg_name(), LiveValue.LOG_TYPE_NUM_SERIES),
self._s2vg_name(): LiveValue(3.0, "m", self._alternative_s2vg_name(), LiveValue.LOG_TYPE_NUM_SERIES),
  1. Run the following script:
in_ws = LoadNexus("SURF138942")
out_ws = ReflectometryReductionOneLiveData(InputWorkspace=in_ws, Instrument="SURF")

It should complete successfully. If you check the detector table on in_ws (i.e. using Show Detector from the right click menu) then you should see detectors 20001, 20002, 30001 listed.


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

  • Is the code of an acceptable quality?
  • Does the code conform to the coding standards?
  • Are the unit tests small and test the class in isolation?
  • If there is GUI work does it follow the GUI standards?
  • If there are changes in the release notes then do they describe the changes appropriately?
  • Do the release notes conform to the release notes guide?

Functional Tests

  • Do changes function as described? Add comments below that describe the tests performed?
  • Do the changes handle unexpected situations, e.g. bad input?
  • Has the relevant (user and developer) documentation been added/updated?

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.

@rbauststfc rbauststfc added Reflectometry Issues and pull requests related to reflectometry ISIS Team: LSS Issue and pull requests managed by the LSS subteam at ISIS labels Oct 21, 2024
@rbauststfc rbauststfc added this to the Release 6.12 milestone Oct 21, 2024
@rbauststfc rbauststfc marked this pull request as ready for review October 22, 2024 09:03
@yusufjimoh yusufjimoh self-assigned this Oct 30, 2024
@adriazalvarez adriazalvarez self-assigned this Nov 1, 2024
@github-actions github-actions bot added the Has Conflicts Used by the bot to label pull requests that have conflicts label Nov 7, 2024
Copy link

github-actions bot commented Nov 7, 2024

👋 Hi, @rbauststfc,

Conflicts have been detected against the base branch. Please rebase your branch against the base branch.

Copy link
Contributor

@adriazalvarez adriazalvarez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested it off cycle. It doesn't throw any error and expected detectors look correct.
Thanks for improving the tests.
Needs to resolve a conflict as ruff checks have been added recently. I'll wait until it is rebased to approve.

@rbauststfc rbauststfc force-pushed the 38202_fix_live_data_spectra_rewrite branch from e4da96c to b2bd5c5 Compare November 11, 2024 08:30
@rbauststfc rbauststfc removed the Has Conflicts Used by the bot to label pull requests that have conflicts label Nov 11, 2024
@rbauststfc rbauststfc force-pushed the 38202_fix_live_data_spectra_rewrite branch from c69be10 to 7d505d1 Compare November 11, 2024 08:48
Rewriting the spectra map means that we can end up with spectra
associated with the wrong detector. The input live data workspace should
already have been created with the correct spectra map, so we shouldn't change this.
@rbauststfc rbauststfc force-pushed the 38202_fix_live_data_spectra_rewrite branch from 7d505d1 to c3c4fd9 Compare November 11, 2024 09:33
Copy link
Contributor

@adriazalvarez adriazalvarez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for rebasing it.

@thomashampson thomashampson self-assigned this Nov 12, 2024
@thomashampson thomashampson merged commit 1a6902a into mantidproject:main Nov 12, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ISIS Team: LSS Issue and pull requests managed by the LSS subteam at ISIS Reflectometry Issues and pull requests related to reflectometry
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ReflectometryReductionOneLiveData rewrites input workspace spectra
4 participants