Ticket #9549 (closed: fixed)
Stitch1D investigation
Reported by: | Owen Arnold | Owned by: | Owen Arnold |
---|---|---|---|
Priority: | major | Milestone: | Release 3.2 |
Component: | Reflectometry | Keywords: | |
Cc: | Blocked By: | ||
Blocking: | Tester: |
Description
Mentioned in #9440 (see description). There may be a difference in scale factor between Mantid's Stitch1D, and the equivalent algorithm generated by genie. I strongly doubt that Stitch1DMany is the cause of this because it's simply a wrapper of Stitch1D.
Stitch1D is well used by the reflectometry group, and is based on their previous combineMulti script, so I doubt that there are really serious issues here. We should investigate anyway, but this is not critical.
I will need user help testing this.
Change History
comment:2 Changed 6 years ago by Samuel Jackson
I've been trying to write a usage example for this algorithm and came across the following problem. If I create two workspaces with the same function, but with different x ranges and attempt to stitch them together I get a function that looks reasonable, but the scale appears to be doubled.
The following script generates two workspaces with a sine with over a upper and lower range and tries to stitch them together. The result is good, but the scale is double what I would expect for the result:
import numpy as np def createSineWorkspace(name,start,end): dataX = np.arange(start,end,0.1) dataY = np.sin(dataX) ws = CreateWorkspace(dataX, dataY, OutputWorkspace=name) ws = ConvertToHistogram(ws, OutputWorkspace=name) return ws #create some histograms to test the algorithm with ws1 = createSineWorkspace('left', 0, 10) ws2 = createSineWorkspace('right', 9, 20) #stitch the two workspaces together ws3, sf = Stitch1D(ws1, ws2) #check against reference workspace ref = createSineWorkspace('reference',0,20) plotSpectrum(['left', 'right', 'ws3'], 0) print sf
comment:5 Changed 6 years ago by Samuel Jackson
Another interesting point:
import numpy as np def gaussian(x, mu, sigma): return (1/ sigma * np.sqrt(2 * np.pi)) * np.exp( - (x-mu)**2 / (2*sigma**2)) x1 = np.arange(-1, 1, 0.02) x2 = np.arange(0.4, 1.6, 0.02) ws1 = CreateWorkspace(UnitX="1/q", DataX=x1, DataY=gaussian(x1[:-1], 0, 0.1)) ws2 = CreateWorkspace(UnitX="1/q", DataX=x2, DataY=gaussian(x2[:-1], 1, 0.05)) stitched, scale = Stitch1D(LHSWorkspace=ws1, RHSWorkspace=ws2, Params=0.02) print scale
The script above produces two peaks and attempts to stitch them together. Because the overlap is in a range where all values are 0, the second peak does not appear in the final stitched workspace. Adding +1 to every y value produces a result more like what I would expect.
comment:6 Changed 6 years ago by Owen Arnold
refs #9549. Regression test demonstrates failure.
Changeset: 9aa1a3994f3e51737e2ed2faae8459e31858849d
comment:7 Changed 6 years ago by Owen Arnold
refs #9549. Regression test fixed.
Changeset: 45cc409d47a5a5a65a1c37bce59c86f7e251b9f2
comment:8 Changed 6 years ago by Owen Arnold
refs #9549. Regression test demonstrates failure.
Changeset: 9aa1a3994f3e51737e2ed2faae8459e31858849d
comment:9 Changed 6 years ago by Owen Arnold
refs #9549. Regression test fixed.
Changeset: 45cc409d47a5a5a65a1c37bce59c86f7e251b9f2
comment:10 Changed 6 years ago by Owen Arnold
refs #9549. Extend solution to scaling RHSWS
Changeset: 443ef2d14369917a905306db65832cd901f00b08
comment:11 Changed 6 years ago by Owen Arnold
refs #9549. Extend tests for multithreaded zero search
Changeset: 83a9faed401bdf4df5e8a3a7e31dcbddbabef745
comment:12 Changed 6 years ago by Owen Arnold
refs #9549. Protect against bad scale factors.
Changeset: a197ebc34f025f141852233e797347adc84a860d
comment:13 Changed 6 years ago by Owen Arnold
refs #9549. Change warning conditions
Changeset: cfcb678c2bb4d7c73e0707ac32f8f158a43af435
comment:14 Changed 6 years ago by Owen Arnold
refs #9549. Unused var removed.
Changeset: 25ad45f4e4df54e0be36c9cfabda63c94325b20e
comment:16 Changed 6 years ago by Owen Arnold
- Status changed from assigned to verify
- Resolution set to fixed
comment:17 Changed 6 years ago by Martyn Gigg
Fix input scalefactor value for case when manual value is not used.
The algorithm now requires the scalefactor to be greater than zero so even if it is not used the value must still satisfy the validator. Refs #9549
Changeset: 1a0da074ca3d64b16b234aae8066e3f822b02854
comment:18 Changed 6 years ago by Samuel Jackson
- Status changed from verify to closed
Merge remote-tracking branch 'origin/feature/9549_stitch1d_defects'
Full changeset: 0b43f3970e59d7253502392c99e07a9e38e78405
comment:19 Changed 6 years ago by Samuel Jackson
Changes appear to have fixed the issue. Also tried with using a manual scale factor on scaling left and right hand workspaces. The results were also both fine. Code review looks good too.
comment:20 Changed 5 years ago by Stuart Campbell
This ticket has been transferred to github issue 10392
One thought, the way that the reported scale factor is calculated is to take the ratio of only one corresponding y bin. i.e. y1[0]/y2[0] (see Stitch1D) this is a possible source of the difference.