adjtomo / pysep

Seismogram Extraction and Processing: Seismic data retrieval and record sections
https://pysep.readthedocs.io
MIT License
28 stars 15 forks source link

allow PySEP to use causal/acausal prefilter during instrument response removal #108

Open bch0w opened 1 year ago

bch0w commented 1 year ago

Currently PySEP applies filtering during the instrument response removal (https://docs.obspy.org/packages/autogen/obspy.core.trace.Trace.remove_response.html), which does not have the typical ObsPy zerophase option for choosing causal or acausal filter.

https://github.com/adjtomo/pysep/blob/3f5d7ab12aee663abe907036ca6eb757879d3722/pysep/pysep.py#L1084-L1092

Instead remove response applies the 4-corner prefilter in the frequency domain using a cosine taper (https://docs.obspy.org/packages/autogen/obspy.signal.invsim.cosine_sac_taper.html). To my understanding this is an acausal filter (?).

To allow Users more flexibility (i.e., to use a causal filter on pre-filtering), we can stop using the ObsPy prefilt option and instead perform prefiltering within PySEP, prior to instrument response removal. This is how it was done in 'old Pysep'

https://github.com/adjtomo/pysep/blob/d5f594b603c265f9186725263fe2b3ac5fb5c7f4/util_write_cap.py#L1202-L1223

This would give us the option to apply zerophase or not and control the causality of the filter. Particularly useful in cases where you want a causal filter.

Motivated by an email from @liamtoney, and discussion with @carltape

aakash10gupta commented 1 year ago

I think the zerophase option would also be useful with the PySEP record section plotter.

liamtoney commented 7 months ago

Instead remove response applies the 4-corner prefilter in the frequency domain using a cosine taper (https://docs.obspy.org/packages/autogen/obspy.signal.invsim.cosine_sac_taper.html). To my understanding this is an acausal filter (?).

According to my postdoc supervisor, the cosine taper in the frequency domain is indeed an acausal filter.