Ticket #9566 (closed: fixed)

Opened 6 years ago

Last modified 5 years ago

Replace calls to quick() in old reflectometry gui

Reported by: Owen Arnold Owned by: Keith Brown
Priority: critical Milestone: Release 3.2
Component: Reflectometry Keywords:
Cc: Blocked By:
Blocking: Tester: Samuel Jackson

Description

Max wants us to use ReflectometryReductionAuto in the reflectometry gui rather than quick.

As a guide. He has said that the following works for him

wq,wlam,th=ReflectometryReductionOne(InputWorkspace=loadedRun,I0MonitorIndex='2',ProcessingInstructions='3',WavelengthMin='1.5',WavelengthMax='15',WavelengthStep='0.01',MonitorBackgroundWavelengthMin='15',MonitorBackgroundWavelengthMax='17',MonitorIntegrationWavelengthMin='4',MonitorIntegrationWavelengthMax='10',OutputWorkspace=runno+'_IvsQ',OutputWorkspaceWavelength=runno+'IvsLam',FirstTransmissionRun=transrun,Params='1.5,0.01,15',StartOverlap='10',EndOverlap='12')

But we should absolutely minimise the number of hard-coded values. ReflectometryReductionOneAuto will automatically pick many of these up. I think of the above, only StartOverlap and EndOverlap would need to be hardcoded.

  • Add an option in the old gui, called 'Use Reflectometry Algorithm'. Default this to False.
  • Use the option as part of a conditional statement. If False, run the old style Quick. If True run ReflectometryReductionOneAuto.

The reason for defaulting to the old reduction is that the Polarisation Correction routines have not yet been added to ReflectometryReductionOne.

Change History

comment:1 Changed 6 years ago by Keith Brown

Refs #9566 Option to switch between c++ alg and quick.py added

An option has been added to the options dialog to switch between quick.py (false/unchecked) and ReflectometryReductionOneAuto (true/checked). Defaults to false.

The options dialog has had a bug fixed where the doublespinbox wasn't returning a value and an exception was raised.

ConvertToWavelength has been given another use: creating a list of workspaces from a supplied string. It already did this, but the access functions have now been added.

Changeset: 6091475901ac426412fd67851e69b8b9dea2fe24

comment:2 Changed 6 years ago by Keith Brown

Refs #9566 Remove debug statement

I'd forgotten to remove a print type() line. It has now gone.

Changeset: cac6f7d45fb7550556f5292625c5add4e0f0ad78

comment:3 Changed 6 years ago by Keith Brown

To Tester

Grab the ISIS Sample Data and add INTER00013460.nxs, INTER00013462.nxs, INTER00013463.nxs and INTER00013464.nxs to a managed user directory.

Launch the ISIS Reflectometry GUI (details how to do this and more here)

Go Options -> Refl Gui Options... and verify that the option to "Use ReflectometryReductionOneAuto Algorithm" is there. It should be unchecked by default. Check it and hit OK. Go back into the options and verify that it is still checked.

Load INTER_NR_test2.tbl and process the top row only. The log should show that ReflectometryReductionOneAuto and ReflectometryReductionOne are being used.

Clone 13460_IvsQ and 13462_IvsQ calling them 13460_IvsQ_c and 13462_IvsQ_c respectively

Go back into the Refl Gui Options and uncheck "Use ReflectometryReductionOneAuto Algorithm" then hit OK. Go back into the options and verify that it is still unchecked.

Process the top row again. The log shouldn't show any use of ReflectometryReductionOneAuto or ReflectometryReductionOne. This will overwrite 13460_IvsQ and 13462_IvsQ from the first processing run.

We now have four workspaces we're interested in: 13460_IvsQ_c & 13462_IvsQ_c (from the c++ algorithm run) and 13460_IvsQ & 13462_IvsQ (from the quick.py run)

Run this script, it will rebin and plot those workspaces in a separate window for each pair. Verify that the output is identical to the naked eye.

from mantid.simpleapi import *

#based heavily on the plotting functionality implemented in the GUI, with some hard-coded values to save more calculation

def getWorkspace(wksp):
    if isinstance(wksp, Workspace):
        return wksp
    elif isinstance(wksp, str):
        if isinstance(mtd[wksp], WorkspaceGroup):
            wout = mtd[wksp][0]
        else:
            wout = mtd[wksp]
        return wout
    else:
        logger.error( "Unable to get workspace: " + str(wksp))
        return 0

overlapLow = [0.01, 0.035]
overlapHigh = [0.06, 0.3]
runno = ["13460","13462"]
wksp = ["13460_IvsQ","13462_IvsQ"]
wksp1 = ["13460_IvsQ_c","13462_IvsQ_c"]
g = ['g1', 'g2', 'g3']
for i in range(len(runno)):
	ws_name_binned = wksp[i] + '_binned'
	ws = getWorkspace(wksp[i])
	Qmin = mtd[wksp[0]].readX(0)[0]
	Qmax = max(mtd[wksp[1]].readX(0))
	Rebin(InputWorkspace=str(wksp[i]), Params=str(overlapLow[i]) + ',' + str(-0.04) + ',' + str(overlapHigh[i]), OutputWorkspace=ws_name_binned)
	wsb = getWorkspace(ws_name_binned)
	Imin = min(wsb.readY(0))
	Imax = max(wsb.readY(0))
	g[i] = plotSpectrum(ws_name_binned, 0, True)
	if (i > 0):
	    mergePlots(g[0], g[i])
	g[0].activeLayer().setAxisScale(Layer.Left, Imin * 0.1, Imax * 10, Layer.Log10)
	g[0].activeLayer().setAxisScale(Layer.Bottom, Qmin * 0.9, Qmax * 1.1, Layer.Log10)
	g[0].activeLayer().setAutoScale()
h = ['h1', 'h2', 'h3']
for i in range(len(runno)):
	ws_name_binned = wksp1[i] + '_binned'
	ws = getWorkspace(wksp1[i])
	Qmin = mtd[wksp1[0]].readX(0)[0]
	Qmax = max(mtd[wksp1[1]].readX(0))
	Rebin(InputWorkspace=str(wksp1[i]), Params=str(overlapLow[i]) + ',' + str(-0.04) + ',' + str(overlapHigh[i]), OutputWorkspace=ws_name_binned)
	wsb = getWorkspace(ws_name_binned)
	Imin = min(wsb.readY(0))
	Imax = max(wsb.readY(0))
	h[i] = plotSpectrum(ws_name_binned, 0, True)
	if (i > 0):
	    mergePlots(h[0], h[i])
	h[0].activeLayer().setAxisScale(Layer.Left, Imin * 0.1, Imax * 10, Layer.Log10)
	h[0].activeLayer().setAxisScale(Layer.Bottom, Qmin * 0.9, Qmax * 1.1, Layer.Log10)
	h[0].activeLayer().setAutoScale()

comment:4 Changed 6 years ago by Owen Arnold

  • Status changed from new to assigned

comment:5 Changed 6 years ago by Keith Brown

  • Status changed from assigned 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/9566_ReflReductionAuto_replaces_Quick_in_gui'

Full changeset: 916d33d847927a1893b1d4012072ebeaa39bf00a

comment:8 Changed 5 years ago by Stuart Campbell

This ticket has been transferred to github issue 10409

Note: See TracTickets for help on using tickets.