Ticket #9634 (closed: fixed)

Opened 6 years ago

Last modified 5 years ago

Allow Setting of Sample Geom and Provide Sensible Defaults in Reduction

Reported by: Peter Parker Owned by: Peter Parker
Priority: critical Milestone: Release 3.2
Component: SANS Keywords:
Cc: robert.dalgliesh@… Blocked By:
Blocking: Tester: Samuel Jackson

Description

LARMOR is currently producing data files that do not have have sample thickness values set. He is having to use the NeXuS API to manually go in to the files and set them himself.

We need to do the following:

  • Expose setThickness (and other related methods) of the MutableSample class to Python, so that he make make the necessary changes via a script.
  • Have the reducer do something sensible when it is not provided with sample geom values (or values of 0.0). The way the GUI and reduction pass values back and forth to each other is quite convoluted, so I need to be careful about where exactly these defaults should be set.

Change History

comment:1 Changed 6 years ago by Peter Parker

  • Cc robert.dalgliesh@… added

comment:2 Changed 6 years ago by Nick Draper

  • Status changed from new to assigned

comment:3 Changed 6 years ago by Peter Parker

  • Status changed from assigned to inprogress

Refs #9634 - Expose sample geom methods and guard against 0.0.

Changeset: 4c975cb7ddc47558a8deab258aaff48f5b17b949

comment:4 Changed 6 years ago by Peter Parker

To test:

Run the following script to test that the exposed geom sample "setters" have the desired effect when used:

import os

# Found in \\isis\inst$\Instruments$\NDXLARMOR\Instrument\data\cycle_14_1:
ws = Load("LARMOR00000217.nxs")

print "On loading the file, the sample geom values are all 0.0:"
print ws.sample().getThickness()
print ws.sample().getWidth()
print ws.sample().getHeight()

ws.sample().setThickness(2.0)
ws.sample().setWidth(3.0)
ws.sample().setHeight(4.0)

print "The values have now been changed:"
print ws.sample().getThickness()
print ws.sample().getWidth()
print ws.sample().getHeight()

file_path = os.path.join(config["defaultsave.directory"],
                         "changed_sample_geom.nxs")
SaveNexus(ws, file_path)
roundtrip_ws = Load(file_path)

print "The values survive being saved out and then loaded again:"
print roundtrip_ws.sample().getThickness()
print roundtrip_ws.sample().getWidth()
print roundtrip_ws.sample().getHeight()

os.remove(file_path)

Then run this script, to show that the reduction stops and clearly presents an error to a user when any of the sample geom values are 0.0:

import os
import ISISCommandInterface as ici

# LARMOR files wont go through the reducer yet, so let's read in a 
# SANS2D run from the system tests folder that we know will go
# through, and then modify its sample geom values to be 0.0.
ws = LoadNexus("SANS2D00022048.nxs")

ws.sample().setThickness(0.0)
ws.sample().setWidth(0.0)
ws.sample().setHeight(0.0)

file_path = os.path.join(config["defaultsave.directory"], "modified.nxs")
SaveNexus(ws, file_path)

# Set up the reducer.
ici.SANS2D()
ici.MaskFile('MaskSANS2DReductionGUI.txt')
ici.AssignSample(file_path)

# Now run the reduction.  Previously this would have given us A LOT of
# "Division by zero: the RHS is a single-valued vector with value zero."
# warnings and the reducer would carry on regardless.  Now it should raise
# a RuntimeError and stop completely, making it obvious what went wrong.
reduced = ici.WavRangeReduction()

Now test the GUI:

  • Open the ISIS SANS interface and select "SANS2D" in the instrument dropdown box.
  • Load the "MaskSANS2DReductionGUI.txt" User File from the "/Data/SANS2D/" folder of the system tests repo.
  • In the Scattering/Sample MWRunFiles widget, browse to the "modified.nxs" data file that was saved to your default save directory by the script above.
  • Clicking "Load Data" should now show three warnings in the Results Log.
  • Go to "Reduction Settings" tab and ensure that a default value of 1 has been put in thickness, width and height sample geometry text fields.
  • Go back to the first tab, and click "1D Reduce". The reduction should complete without any errors.

comment:5 Changed 6 years ago by Peter Parker

  • Status changed from inprogress to verify
  • Resolution set to fixed

comment:6 Changed 6 years ago by Samuel Jackson

  • Status changed from verify to verifying
  • Tester set to Samuel Jackson

comment:7 Changed 6 years ago by Samuel Jackson

  • Status changed from verifying to closed

Merge remote-tracking branch 'origin/feature/9634_sample_geom_isis_sans'

Full changeset: 2c21b7ff7702d7af74516d9808ace5b83c147242

comment:8 Changed 5 years ago by Stuart Campbell

This ticket has been transferred to github issue 10477

Note: See TracTickets for help on using tickets.