Closed t-b closed 3 years ago
A simpler and much faster way would be:
variable offset = wv[0]
wv -= offset
It also does not have the side effect of Differentiate dropping points.
@timjarsky What do you think about changing ZeroWave
as @MichaelHuth pointed out? This would also be much faster.
@t-b Is that method more sensitive to errors/variability in the value of the first point?
@timjarsky From a theoretical point no. But of course numerical differentiation and integration work a bit different than math.
Function/WAVE GetData()
Make/FREE wv = {100, -100, 1000, -1000}
return wv
End
Function ZeroOld(WAVE wv)
Differentiate/DIM=0/EP=1 wv
Integrate/DIM=0 wv
End
Function ZeroNew(WAVE wv)
variable offset = wv[0]
wv[] = wv[p] - offset
End
Function Dostuff()
WAVE wv = GetData()
ZeroOld(wv)
print wv
WAVE wv = GetData()
ZeroNew(wv)
print wv
End
gives
•dostuff()
'_free_'[0]= {450,0}
'_free_'[0]= {0,-200,900,-1100}
First line is the existing algo, second just subtracting the first value. So even the new algo does not do any averaging or similiar it is not way wrong compared to the old method.
Switch to new method.
@MichaelHuth provided test data in #704
Originally posted by @MichaelHuth in https://github.com/AllenInstitute/MIES/pull/704#issuecomment-721425207