diff --git a/TM/waveformops.py b/TM/waveformops.py index 3fa949879dbfdb99de381d286e58a9ea7b9ef124..6d46480edf4434a2babf53033d3e8ab433c81c44 100644 --- a/TM/waveformops.py +++ b/TM/waveformops.py @@ -532,22 +532,33 @@ def _waveform_processing_trace(trace, resampling, procType='bandpass', freqMax=N # We filter first, and then re/downsample; # This costs more performance (more to filter), but the data will be represented "better" - trace.filter("bandpass", freqmin=config.filtConf[0], - freqmax=config.filtConf[1], corners=config.filtConf[2]) if procType == 'bandpass' and config.FFT_filt is False: + corners = config.filtConf[2] + zerophase = False + if zerophase: + corners = corners//2 + + trace.filter("bandpass", freqmin=config.filtConf[0], freqmax=config.filtConf[1], + corners=corners, zerophase=zerophase) + elif procType == 'highpass': - trace.filter("highpass", freq=1.0) - # If maximum freq specified, apply also a low-pass filter - # (to remove too-high frequencies that disturb the amplitude comparison) - if freqMax: + + if not freqMax: + + trace.filter("highpass", freq=1.0) # 4th order + + else: + # If maximum freq specified, apply a bandpass filter + # (to remove too-high frequencies that disturb the amplitude comparison) + # Determine lowest senseful frequency # (at max, only up to Nyquist of original signal, or # if signal will be resampled below/equal Nyquist freq, take the new sampling rate) freqmax = min(resampling if resampling else float('Inf'), # New sampling freq - trace.stats.sampling_rate//2, # Nyguist freq + trace.stats.sampling_rate//2, # Nyguist freq freqMax) # Specified max. freq - trace.filter("lowpass", freq=freqmax) + trace.filter("bandpass", freqmin=1.0, freqmax=freqmax) # 4th order # Apply 50Hz bandSTOP filter if configured if config.stop50Hz and config.FFT_filt is False: