Before adding this to obspy, I decided put it here for discussion, maybe there is some problem I did not anticipate:
For now, detrending is done using the first and last and last value of the trace in obspy.signal.invsim.detrend. This fails with a lot of noise or when the time window of the trace contains only part of the signal. Wouldn't it be better to fit a linear function to the trace and remove that from the data? E.g. like this:
{{{ for tr in st: dt = tr.stats.delta t = np.linspace(0., (tr.stats.npts - 1) * dt, tr.stats.npts)
A = np.vstack([t, np.ones(len(t))]).T
m, c = np.linalg.lstsq(A, tr.data)[0]
tr.data = tr.data - m*t - c
}}}
Works fine for me.
Cheers, Martin
该提问来源于开源项目:obspy/obspy