Ticket #7709 (closed: fixed)

Opened 7 years ago

Last modified 5 years ago

Make Stitch1D easier to use and more robust

Reported by: Nick Draper Owned by: Owen Arnold
Priority: major Milestone: Release 3.0
Component: Reflectometry Keywords:
Cc: Blocked By:
Blocking: Tester: Peter Parker

Description

  1. I'd like to see this move so it can perform a sensible default rebinning across both if they are not binned in advance
  2. If the region of overlap is not defined we should guess based on the (pre-rebinning) overlap of the x axes.
  3. The handling of zero errors needs to be improved.
#Creating a couple of fake workspaces for this test
CreateWorkspace(OutputWorkspace='bob',DataX='10,20,30',DataY='10,20,30',UnitX='Counts')
CreateWorkspace(OutputWorkspace='bob2',DataX='25,35,45,55,65',DataY='20,30,40,50,60',DataE='5,10,15,20,25',UnitX='Counts')
#You need to rebin both to a common X axis
Rebin(InputWorkspace='bob',OutputWorkspace='rbob1',Params='0,10,100',PreserveEvents='0')
Rebin(InputWorkspace='bob2',OutputWorkspace='rbob2',Params='0,10,100',PreserveEvents='0')
#Then stitch will do its job
Stitch1D(LHSWorkspace='rbob1',RHSWorkspace='rbob2',OutputWorkspace='result',StartOverlap='0.2',EndOverlap='0.4')

Change History

comment:1 Changed 7 years ago by Owen Arnold

I'm going to use combineMulti.py as a basis for how to do the processing here, and gut the existing Stitch1D to implement these changes. I can then eventually replace processing of combineMulti to use Stitch1D. The stages I'm going to follow are:

  • Gut Stitch1D, decouple it from Stitch1DMD.
  • Create a test dataset that works with combineMulti, and use that as a benchmark
  • Implement Stitch1D so that it meets the criteria determined by the benchmark

comment:2 Changed 7 years ago by Owen Arnold

  • Status changed from new to inprogress

refs #7709. Gut Stitch1D and change API slightly.

This should bring the API to be more in line with combine2 from combineMulti. These changes will break the unit tests.

Changeset: c3ebc452dee2fdb7aab8b78abb28fc30e9c40eac

comment:3 Changed 7 years ago by Owen Arnold

refs #7709. Stitching seems to be working ok.

Changeset: 9ef471367613700f8f5ff56a94f5a627caf3e9b5

comment:4 Changed 7 years ago by Owen Arnold

refs #7709. Sort out masking ranges.

This is stitching very nicely now with the test data. The most important change here is that I've limited the zero-masking range for the rhs and lhs rebinned workspace, so that the boundaries can be handled properly.

Changeset: 4eed2761616411a39660a4eed2a2e5e2fb5ddd06

comment:5 Changed 7 years ago by Owen Arnold

refs #7709. Update tests, and fix algorithm.

Tests updated. Minor changes required to algorithm as a result of problems found during testing. More tests to come.

Changeset: 81b2ac77b7ff8afefb1bfad4a58a259be82a1a93

comment:6 Changed 7 years ago by Owen Arnold

refs #7709. Tests and fixes for manual scaling.

Get manual scaling factor aspects of the algorithm working.

Changeset: 6eab90d14fa302929fa3d565784942a84b4bc921

comment:7 Changed 7 years ago by Owen Arnold

refs #7709 sanity check inputs.

Unit tests have been added for this too.

Changeset: 7ff02b26c1e1051dc9aff451b8300b3f4461a2a1

comment:8 Changed 7 years ago by Owen Arnold

Tester: Obtain the zip file from #7982. Then run the following script. Stitch1D should produce the same results as combine multi, except that the outstanding bug in #7982 (the saw-tooth behaviour) requires aspects of this fix. Otherwise the two generated plots should line-up quite nicely. Also see new unit tests.

from isis_reflgui import combineMulti

import os

DataDir= os.path.expanduser('~/Desktop/Tims')
print os.path.join(DataDir, 'polref8481.dat')
r8481 = Load(Filename= os.path.join(DataDir, 'polref8481.dat'),Unit='MomentumTransfer') 
r8482 = Load(Filename= os.path.join(DataDir, 'polref8482.dat'),Unit='MomentumTransfer')
r8483 = Load(Filename= os.path.join(DataDir, 'polref8483.dat'),Unit='MomentumTransfer')
r8481 = SortXAxis(r8481)
r8482 = SortXAxis(r8482)
r8483 = SortXAxis(r8483)

Rebin(InputWorkspace='r8481',OutputWorkspace='r8481',Params='0.009,-0.02,0.034',PreserveEvents='0') 
Rebin(InputWorkspace='r8482',OutputWorkspace='r8482',Params='0.017,-0.02,0.06',PreserveEvents='0')
Rebin(InputWorkspace='r8483',OutputWorkspace='r8483',Params='0.027,-0.02,0.100',PreserveEvents='0')

ConvertToHistogram(InputWorkspace='r8481',OutputWorkspace='r8481h')
ConvertToHistogram(InputWorkspace='r8482',OutputWorkspace='r8482h')
ConvertToHistogram(InputWorkspace='r8483',OutputWorkspace='r8483h')

wcomb = combineMulti.combineDataMulti(['r8481h' , 'r8482h'],'viaCombineMulti',[0.009, 0.018],[0.03, 0.046],0.009,0.1,binning=-0.02,keep=1)
viaStitch1D = Stitch1D(LHSWorkspace='r8481h', RHSWorkspace='r8482h', StartOverlap=0.02, EndOverlap=0.03, Params='0.009, -0.02, 0.1')
plotSpectrum(['viaCombineMulti', 'viaStitch1D'], 0)

comment:9 Changed 7 years ago by Owen Arnold

refs #7709. count_nonzero not portable.

Changeset: 0f41b2732f2cba50b70a85079b1e74e261aab964

comment:10 Changed 7 years ago by Owen Arnold

refs #7709. Remove non-portable zero count from stitch1d.

Changeset: 847cf8b6e4b615ebf716cb115a73ee5dca1b092a

comment:11 Changed 7 years ago by Owen Arnold

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

comment:12 Changed 7 years ago by Peter Parker

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

comment:13 Changed 7 years ago by Peter Parker

  • Status changed from verifying to closed

Merge remote-tracking branch 'origin/feature/7709_stitch1D_improvements'

comment:14 Changed 7 years ago by Peter Parker

Passing.

The given script does indeed show the combineMulti approach and the new Stitch1D approach lining up nicely, except of course for the saw-tooth behaviour.

The algorithm looks good to me. The code seems to do what I would expect. The arguments passed to it are validated, and it cleans up after itself. The Wiki could do with updating to show the Params property, though I imagine you've just not gotten around to that.

The unit tests seem to offer good coverage, and run on my machine fine.

comment:15 Changed 5 years ago by Stuart Campbell

This ticket has been transferred to github issue 8554

Note: See TracTickets for help on using tickets.