trace: fix envelope method

gf3d
Sebastian Heimann 2 years ago committed by Gogs
parent 0fef96f1a0
commit 404713c20d

@ -29,7 +29,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- New example on how to create QuakeML files from scratch.
### Fixed
*empty*
- Fixed `Trace.envelope`.
### Changed
- Renamed Snuffling "Block RMS" to "RMS".

@ -112,7 +112,7 @@ def get_seismogram_array(
for tr in traces:
tr.extend(tmin, tmax, fillmethod='repeat')
if envelope:
tr.abshilbert()
tr.envelope()
data = num.array([tr.get_ydata() for tr in traces])
data -= data.mean()

@ -941,10 +941,6 @@ class Trace(Object):
self.drop_growbuffer()
self.ydata = signal.lfilter(b, a, data)
def abshilbert(self):
self.drop_growbuffer()
self.ydata = num.abs(hilbert(self.ydata))
def envelope(self, inplace=True):
'''
Calculate the envelope of the trace.
@ -960,12 +956,14 @@ class Trace(Object):
where H is the Hilbert-Transform of the signal Y.
'''
y = self.ydata.astype(float)
env = num.abs(hilbert(y))
if inplace:
self.drop_growbuffer()
self.ydata = num.sqrt(self.ydata**2 + hilbert(self.ydata)**2)
self.ydata = env
else:
tr = self.copy(data=False)
tr.ydata = num.sqrt(self.ydata**2 + hilbert(self.ydata)**2)
tr.ydata = env
return tr
def taper(self, taperer, inplace=True, chop=False):
@ -3379,6 +3377,7 @@ def hilbert(x, N=None):
if num.iscomplexobj(x):
logger.warning('imaginary part of x ignored.')
x = num.real(x)
Xf = num.fft.fft(x, N, axis=0)
h = num.zeros(N)
if N % 2 == 0:

Loading…
Cancel
Save