added static method demeanWFData which simply returns the demeaned waveform stream object while the individual trace data are decreased by the average value of the waveform in a given window

This commit is contained in:
Sebastian Wehling-Benatelli 2015-06-29 16:19:17 +02:00
parent 9aa8a5bf13
commit 327a22818a

View File

@ -386,6 +386,30 @@ class PickDlg(QDialog):
wfdata = self.getWFData().select(component=component)
return wfdata
@staticmethod
def demeanWFData(data, t0, win, gap):
"""
returns the DATA where each trace is demean by the average value within
a desired time window WIN before T0 and a GAP
:param data: waveform stream object
:type data: `~obspy.core.stream.Stream`
:param t0: time before which the noise
:type t0: float
:param win: time window for average calculation
:type win: tuple
:param gap: gap window to avoid polluting the average
:type gap: float
:return: data
:rtype: `~obspy.core.stream.Stream`
"""
starttime = getGlobalTimes(data)[0]
for tr in data:
stime = tr.stats.starttime - starttime
t = prepTimeAxis(stime, tr)
inoise = getnoisewin(t, t0, win, gap)
tr.data -= tr.data[inoise].mean()
return data
def getPicks(self):
return self.picks
@ -424,14 +448,8 @@ class PickDlg(QDialog):
x_res = getResolutionWindow(snr)
# demean data before plotting
data = self.getWFData().copy()
starttime = getGlobalTimes(data)[0]
for tr in data:
stime = tr.stats.starttime - starttime
t = prepTimeAxis(stime, tr)
inoise = getnoisewin(t, ini_pick, noise_win, gap_win)
tr.data -= tr.data[inoise].mean()
data = self.demeanWFData(data=self.getWFData().copy(), t0=ini_pick,
win=noise_win, gap=gap_win)
self.setXLims([ini_pick - x_res, ini_pick + x_res])
self.setYLims(np.array([-noiselevel * 2.5, noiselevel * 2.5]) +