Skip to content
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

Proof of concept: Using scipy instead evalresp #1718

Closed
wants to merge 5 commits into from
Closed

Conversation

krischer
Copy link
Member

Based on the discussion in #1493 it came to me that it would be almost trivial to replace evalresp completely with scipy. I don't know why I did not think of this before. Much simpler than our current wrapping of evalresp.

This PR does this for the PAZ, decimation, and coefficient response stages which are the most common and it also handles the final assembly and sensitivity calculations so it can already do quite a lot of responses. The rest is quite easy to add.

Of course this needs a lot more testing so I'd personally not include this in the upcoming 1.1 but rather wait a release.

The amplitude response matches the evalresp one to a relative error of 1E-10 - the sensitivity scaling makes this a bit different but I think what's done in this PR is correct. The phase differs a bit more for the FIR stage mainly after nyquist but also a tiny bit before. Again I think here scipy does the correct thing as it for example has no Gibb's artifacts which evalresp has.

@megies megies added .signal issues related to our signal processing functionalities .core issues affecting our functionality at the very core .core.inventory issues related to our Inventory functionality labels Mar 13, 2017
@megies megies added this to the 1.2.0 milestone Mar 13, 2017
@megies megies modified the milestones: 1.2.0, 1.3.0 Apr 19, 2018
@megies megies modified the milestones: 1.3.0, 2.0.0 Feb 15, 2019
@jkmacc-LANL
Copy link
Contributor

+1 !

@amkearns-usgs
Copy link

I would like to confirm that this pull request is ready / awaiting review.

@megies
Copy link
Member

megies commented Jul 11, 2020

I would like to confirm that this pull request is ready / awaiting review.

uhm.. it handles all different types of response stages out there already??

@amkearns-usgs
Copy link

amkearns-usgs commented Jul 13, 2020

I would like to confirm that this pull request is ready / awaiting review.

uhm.. it handles all different types of response stages out there already??

I believe so. I tested it rather thoroughly with @aringler-usgs in order to make sure it did. (There was a lot of back-and-forth about how to handle digital vs. analog filter stages.)

@krischer
Copy link
Member Author

Removing the response is such an integral part of ObsPy that we absolutely have to make sure that we can explain every difference to the way evalresp does it. When we initially implemented the StationXML response removal and being able to read SEED files we did by comparing the output of raw evalresp to almost every response file in existance: https://github.com/obspy/sandbox/tree/master/the_great_response_test

I think something similar would be needed here in addition to all the testing you already did. I can take care of setting up a basic version - should not take too long.

That is the most up-to-date branch here, correct? https://github.com/amkearns-usgs/obspy/tree/evalresp_update

@amkearns-usgs
Copy link

Yes. We haven't been rebasing it to any updates on the main branch at all -- I don't think we've touched this since like April or so, but that's where all the updates would happen.

@aringler-usgs
Copy link
Member

@krischer thanks for setting up an additional location for tests. I am sure there will be a few oddities that come out of this. I will work with @amkearns-usgs to deal with the various issues in the tests. Thanks!

@krischer
Copy link
Member Author

Great job @amkearns-usgs & @aringler-usgs !! This already works really really well and given how much time I spent on this problem in the past I personally really appreciate this. So thanks a lot already.

I pushed a first version of the aforementioned test here: https://github.com/obspy/sandbox/tree/master/the_great_response_test_scipy

I hope it is easy enough to understand. The main idea is to run this against a significant portion of the data out there and see if the results are identical between evalresp and the new scipy implementation. I'd be fine with some differences as long as they are documented and rational.

@krischer
Copy link
Member Author

I realize that this might be a decent amount of work. But given that response removal is one of the absolute core features of ObsPy we cannot afford to go wrong here. I'm happy to take some of the work.

Given that you know the code better than me I think it would be most useful if you try to deal with the initial broader issues and I'll jump it at any time when you need a break.

@krischer
Copy link
Member Author

I also pushed a tiny commit here: https://github.com/amkearns-usgs/obspy/tree/evalresp_update

@krischer
Copy link
Member Author

Let's continue the discussion in #2592 - more useful when the code is directly there.

@krischer krischer closed this Jul 13, 2020
flixha pushed a commit to flixha/obspy that referenced this pull request Mar 22, 2021
flixha pushed a commit to flixha/obspy that referenced this pull request Jan 6, 2022
amkearns-usgs added a commit to amkearns-usgs/obspy that referenced this pull request Jan 6, 2022
flixha pushed a commit to flixha/obspy that referenced this pull request Feb 22, 2022
flixha pushed a commit to flixha/obspy that referenced this pull request Nov 15, 2022
flixha pushed a commit to flixha/obspy that referenced this pull request Nov 15, 2022
@megies megies deleted the scipy-response branch January 23, 2023 10:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
.core.inventory issues related to our Inventory functionality .core issues affecting our functionality at the very core .signal issues related to our signal processing functionalities
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants