Ticket #9171 (closed: fixed)

Opened 7 years ago

Last modified 5 years ago

Stitch1D Overlap Issue

Reported by: Owen Arnold Owned by: Owen Arnold
Priority: critical Milestone: Release 3.2
Component: Reflectometry Keywords:
Cc: Blocked By:
Blocking: #9470 Tester: Peter Parker

Description

Quote from user:

Stitch1D fails if the statoverlap is smaller than the lowest bin in the second workspace. This is of course to be expected, but I think it should default to the lowest bin entry (and throw a warning) if an erroneous value is entered. Sam of course for the endoverlap value.

Change History

comment:1 Changed 7 years ago by Owen Arnold

  • Status changed from new to assigned

comment:2 Changed 6 years ago by Owen Arnold

This has been partially handled by http://trac.mantidproject.org/mantid/ticket/8888, but yes, we do not handle the case that the user HAS provided overlap ranges and those overlap ranges are outside of range. We should:

  • Detect that StartOverlap OR EndOverlap are out of range
  • Emit a warning if either of the above is true
  • Force the StartOvelap and EndOverlap to take the ranges at the end/start of the workspace (as is currently done if these inputs are not provided) and continue.

comment:3 Changed 6 years ago by Owen Arnold

import numpy
from mantid.simpleapi import *
from isis_reflectometry import quick
from isis_reflectometry import combineMulti

class ReflectometryQuickCombineMulti(object):

    __stitchedWorkspaceName = "stitched_13460_13462"
    
    def doQuickOnRun(self, runNumber, transmissionNumbers, instrument, incidentAngle):
        defaultInstKey = 'default.instrument'
        defaultInstrument = config[defaultInstKey]
        try:
            config[defaultInstKey] = instrument
            LoadISISNexus(Filename=str(runNumber), OutputWorkspace=str(runNumber))
            for transmissionNumber in transmissionNumbers:
                LoadISISNexus(Filename=str(transmissionNumber), OutputWorkspace=str(transmissionNumber))
            
            transmissionRuns = ",".join(map(str, transmissionNumbers))
            # Run quick
            quick.quick(str(runNumber), trans=transmissionRuns, theta=incidentAngle) 
        finally:
            config[defaultInstKey] = defaultInstrument
        return mtd[str(runNumber) + '_IvsQ']
    
    def createBinningParam(self, low, step, high):
        return "%f,%f,%f" %(low, step, high)
    
    def runTest(self):
        step = 0.040
        run1QLow = 0.010
        run1QHigh = 0.06
        run2QLow = 0.035
        run2QHigh = 0.300
        
        # Create IvsQ workspaces
        IvsQ1 = self.doQuickOnRun(runNumber=13460, transmissionNumbers=[13463,13464], instrument='INTER', incidentAngle=0.7)
        IvsQ1Binned = Rebin(InputWorkspace=IvsQ1, Params=self.createBinningParam(run1QLow, -step, run1QHigh))
        
        # Create IvsQ workspaces
        IvsQ2 = self.doQuickOnRun(runNumber=13462, transmissionNumbers=[13463,13464], instrument='INTER', incidentAngle=2.3)
        IvsQ2Binned = Rebin(InputWorkspace=IvsQ2, Params=self.createBinningParam(run2QLow, -step, run2QHigh))
        
        # Peform the stitching the old way --- specifying everything
        stitchedMany1, scaleFactor = Stitch1D(LHSWorkspace=IvsQ1Binned, RHSWorkspace=IvsQ2Binned, StartOverlap=run2QLow+0.001, EndOverlap=run1QHigh-0.001, Params=[run1QLow, -step,run2QHigh])
        # Peform the stitching the new way --- where overlaps and limits can be calculated for you
        stitchedMany2, scaleFactor = Stitch1D(LHSWorkspace=IvsQ1Binned, RHSWorkspace=IvsQ2Binned,  Params=[-step])
        # Peform the stitching with invalid StartOveralp entry. This will automatically be corrected
        stitchedMany3, scaleFactor = Stitch1D(LHSWorkspace=IvsQ1Binned, RHSWorkspace=IvsQ2Binned,  Params=[-step], StartOverlap=run2QLow - 0.01)
        # Peform the stitching with invalid EndOveralp entry. This will automatically be corrected
        stitchedMany4, scaleFactor = Stitch1D(LHSWorkspace=IvsQ1Binned, RHSWorkspace=IvsQ2Binned, Params=[-step], EndOverlap=run1QHigh+ 0.01)
        # Results should be essentially the same
        plotSpectrum([stitchedMany1, stitchedMany2, stitchedMany3, stitchedMany4], 0)
        
test = ReflectometryQuickCombineMulti()
test.runTest()
Last edited 6 years ago by Owen Arnold (previous) (diff)

comment:4 Changed 6 years ago by Owen Arnold

  • Status changed from assigned to inprogress

refs #9171. Fix Stitch1D limits.

Stitch1D now looks at the min and max possible. If StartOverlap or EndOverlap are outside the min-max range, then they are forced reassigned StartOverlap=min, EndOverlap=max within the algorithm.

Changeset: 366892708140497f13c054edc5379d04599d7d52

comment:5 Changed 6 years ago by Owen Arnold

Tester: Run the code above the last two calls to Stitch1D are using invalid StartOverlap and EndOvelap values respectively, but we expect the algorithm to internally correct the values and print a warning to that effect. So, as a result of running the above, you should see that all curves in the plot overlap, and that you get two warnings generated that look like:

StartOverlap is outside range at 0.0250, Min is 0.0350, Max is 0.0600 . Forced to be: 0.0350
EndOverlap is outside range at 0.0700, Min is 0.0350, Max is 0.0600. Forced to be: 0.0600

comment:6 Changed 6 years ago by Owen Arnold

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

comment:7 Changed 6 years ago by Peter Parker

  • Status changed from verify to verifying
  • Tester set to Peter Parker

comment:8 Changed 6 years ago by Peter Parker

  • Status changed from verifying to closed

Merge remote-tracking branch 'origin/feature/9171_stitch1d_limit'

Full changeset: 330205e3f5d9e3a8e5a395fd4cd61aacc29ba752

comment:9 Changed 6 years ago by Peter Parker

The script provided did indeed show that using all four of the permutations gave the same result. Unit tests cover the new functionality.

comment:10 Changed 6 years ago by Owen Arnold

  • Blocking 9470 added

comment:11 Changed 5 years ago by Stuart Campbell

This ticket has been transferred to github issue 10013

Note: See TracTickets for help on using tickets.