New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Response removal prevented unneccessarily for response list type response in some cases #2988
Conversation
I agree. I'd suggest to just extrapolate the amplitude and phase values constantly beyond the smallest and largest frequencies in the reponse list and raise a warning as you suggest. I guess, the real amplitude of the response at undefined frequencies is lower than the amplitudes given at the lowest/highest frequency in most cases. Therefore, after response removal, amplitudes will be lower than real amplitudes for the frequencies outside of the defined range and no distortions are expected. As you said with using pre-filt you are even more on the safe side. |
Yes, that's pretty much what is done currently if you just comment out that block that raises the exception, the spline interpolation just extrapolates outside of the given range, like shown in the response plot above (that is with the "raise" statement commented out) |
response list stages can be confined to quite narrow frequency bands, e.g. when coming from industry standard calibration protocols. in real world cases response calculation for deconvolution on time series will for technical reasons likely have to resort on extrapolation outside of the frequency range defined by the response list stage. while this is problematic it is easy to counter by appropriate `pre_filt` in response removal, which essentially zeros out unwanted parts of the signal spectrum anyway. currently it is not possible to do this as we forcefully raise an exception. this commit changes that and converts it into a warning message that gives back control to the user.
for the warning message just warn about the actual first/last frequency defined and don't tamper with these boundaries for the warning
not raising an exception on extrapolation anymore but showing a warning. only saw there already was a test case after implementing the new one, still deleting the old test as the new one is slightly faster, not going through read_inventory() but setting up a response list stage from scratch
that warning probably wasnt shown before because of that obscure calculation for how much extrapolation was deemed acceptable without raising an exception
Changed raising an exception into showing a warning. |
In the case of Responses containing (or well, sometimes solely built of) a Response list type stage (Frequency-Amplitude-Phase tuples), we are forcefully raising an exception if an extrapolation would have to occur, i.e. the given response list stage does not span the full range of frequencies needed for response removal.
obspy/obspy/core/inventory/response.py
Lines 1387 to 1394 in 38d86b1
When this was implemented this was probably chosen just as the easiest and safest route possible, however it prevents response removal in some very valid scenarios. Even if the response list stage does not cover all frequencies technically needed, it may well cover the frequency range of interest (a lot of times a bandpass is applied later on anyway) and in any case it is very easy to ensure there are no problems by using
pre_filt
(orwater_level
) to suppress out-of-range frequencies.I think we should change this exception into a warning. If we want, we could even make the warning conditional and check in the high level routines (probably just need it in
Trace.remove_response
) ifwater_level
/pre_filt
seem sufficient to prevent problems.This is a (simplified) example response to illustrate the issue, green box with red borders is the frequency range defined in the response list stage:
When interested in e.g. 1-20 Hz, there really isn't a problem why the response shouldn't be usable, a simple
pre_filt=(0.1, 0.3, 50, 80)
can make sure there are no problems in the deconvolution.PR Checklist
master
for new features,maintenance_...
for bug fixesJust add the "build_docs" tag to this PR.
clients.fdsn
) should be tested for the PR,just add the "test_network" tag to this PR.
CHANGELOG.txt
.CONTRIBUTORS.txt
.from all the CI builds look correct. Add the "upload_plots" tag so that plotting
outputs are attached as artifacts.