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

Provide clear error message when delta_r is not provided in scripted reduction #38509

Open
rbauststfc opened this issue Dec 13, 2024 · 0 comments
Labels
ISIS Team: LSS Issue and pull requests managed by the LSS subteam at ISIS Reported By User Issues that were found or highlighted by a user/scientist SANS Issues and pull requests related to SANS

Comments

@rbauststfc
Copy link
Contributor

rbauststfc commented Dec 13, 2024

Original reporter: Rob Dalgliesh in the ISIS SANS Group

Describe the bug

If the delta_r value in the q_resolution section of a SANS TOML user file is commented out then the SANS GUI recognises this and inserts a value of 0.0.

However, if you run the reduction through a script an error is thrown because the value of delta_r is left undefined as None. The error is long and difficult to interpret.

Example of TOML file q_resolution section:

[q_resolution]
  enabled = true
  moderator_file="ModeratorFWHM_SANS_NimrodRed_8cm_Moderator_16May2024.txt"
  # do not comment delta_r out. 
  #It will cause an error with a scripted reduction but is set to 0.0 by the GUI
  delta_r = 0.008
  h1=0.020
  w1=0.020
  h2=0.006
  w2=0.006

To Reproduce

To reproduce the error from the following script you will need access to the ISIS archive. Do the following:

  1. Change the instrument to SANS2D and add NDXSANS2D/User/Masks/ to your Data Search Directories (via the Manage User Directories dialog).
  2. Take a copy of the following user file and store it somewhere on your local machine (it's very important not to change the original):
    NDXSANS2D/User/Masks/USER_SANS2D_233O_4m_2p4_M3_8mm_Gentile_Rheometer_merged.TOML
  3. Open the local copy of the user file in a text editor and under the [q_resolution] section comment out the delta_r setting by adding a # to the start of that line (i.e. #delta_r = ....).
  4. Run the following script, substituting path_to_file with the path to your local copy of the user file:
from sans.command_interface.ISISCommandInterface import *

MaskFile('path_to_file')

AssignSample("82904.nxs")
TransmissionSample("82905.nxs", "82886.nxs")
AssignCan("82889.nxs")
TransmissionCan("82890.nxs", "82886.nxs")

WavRangeReduction(1.75, 16.5, DefaultTrans)

You should see the following error:

Error in execution of algorithm SANSReductionCore:unsupported operand type(s) for *=: 'NoneType' and 'float' at line 130 in '/opt/mantidworkbenchnightly/plugins/python/algorithms/WorkflowAlgorithms/SANS/SANSReductionCore.py' caused by line 314 in '/opt/mantidworkbenchnightly/plugins/python/algorithms/WorkflowAlgorithms/SANS/SANSReductionCoreBase.py' caused by line 39 in '/opt/mantidworkbenchnightly/scripts/SANS/sans/algorithm_detail/convert_to_q.py' caused by line 67 in '/opt/mantidworkbenchnightly/scripts/SANS/sans/algorithm_detail/convert_to_q.py' caused by line 213 in '/opt/mantidworkbenchnightly/scripts/SANS/sans/algorithm_detail/convert_to_q.py'

Expected behavior

Request from our scientists:

Can the user file interpreter/parser have an extra error check added so that if delta_r is not defined then a sensible error message is thrown and the data reduction terminates appropriately. We could substitute a value of 0.0 in all cases but this is probably not desirable. It shouldn’t really work through the GUI either but there is no need to fix this.

Note on the final point that fixing it for the command interface is likely to fix the problem in the GUI too, as both ways of performing the reduction use a lot of shared code. We should test the GUI as part of making this change to ensure that the fix for the scripted reduction doesn't have any unintended effects on the GUI reduction.

@rbauststfc rbauststfc added SANS Issues and pull requests related to SANS ISIS Team: LSS Issue and pull requests managed by the LSS subteam at ISIS Reported By User Issues that were found or highlighted by a user/scientist labels Dec 13, 2024
@rbauststfc rbauststfc moved this from New to Icebox in ISIS LSS Sprint Planning Dec 13, 2024
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 Reported By User Issues that were found or highlighted by a user/scientist SANS Issues and pull requests related to SANS
Projects
Status: Icebox
Development

No branches or pull requests

1 participant