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

Polarization Analysis issues #2365

Closed
sjohnson5 opened this issue Mar 22, 2019 · 8 comments · Fixed by #2403
Closed

Polarization Analysis issues #2365

sjohnson5 opened this issue Mar 22, 2019 · 8 comments · Fixed by #2403
Assignees
Labels
bug confirmed bug .signal issues related to our signal processing functionalities
Milestone

Comments

@sjohnson5
Copy link

I've found a couple problems with obspy.signal.polarization.polarization_analysis

  1. polarization_analysis requires parameter frqlow and frqhigh (regardless of method), however looking in the source code those parameters are only used if method="vidale". Reading the documentation I expected these to filter the stream I pass the function. (Also I feel like these parameters should be named freqmin and freqmax in order to match the names parameters that would be passed to a bandpass filter, for example)
  2. On lines 508-513 of the source code (obspy/signal/polarization.py):
            if "Z" in tr.stats.channel:
                z = dat.copy()
            if "N" in tr.stats.channel:
                n = dat.copy()
            if "E" in tr.stats.channel:
                e = dat.copy()

I've got a channel named "ENZ", this channel will get all mixed up because all of the above instances are true (other channels like "ELZ" or "HNE" would also get mixed up). I would recommend replacing this with:

            if tr.stats.channel[-1] == "Z":
                z = dat.copy()
            elif tr.stats.channel[-1] == "N":
                n = dat.copy()
            elif tr.stats.channel[-1] == "E":
                e = dat.copy()
            else:
                raise NameError

Version info:

  • ObsPy 1.1.0 (installed from anaconda)
  • Python 3.6.6
  • Ubuntu 18.04.2

Thanks for all you guys do!

@d-chambers d-chambers added the .signal issues related to our signal processing functionalities label Mar 22, 2019
@d-chambers d-chambers added this to the 2.0.0 milestone Mar 22, 2019
@krischer
Copy link
Member

@jwassermann this one is for you!

@krischer krischer added the bug confirmed bug label Apr 11, 2019
@megies
Copy link
Member

megies commented May 22, 2019

polarization_analysis requires parameter frqlow and frqhigh (regardless of method), however looking in the source code those parameters are only used if method="vidale". Reading the documentation I expected these to filter the stream I pass the function. (Also I feel like these parameters should be named freqmin and freqmax in order to match the names parameters that would be passed to a bandpass filter, for example)

Yes, documentation should be clear that these are not even used with 2/3 methods, not even the default one. It's really unfortunate that these were made positional arguments, they should rather be kwargs but we can't change this without major backwards compatibility workarounds now..

I've got a channel named "ENZ", this channel will get all mixed up because all of the above instances are true (other channels like "ELZ" or "HNE" would also get mixed up). I would recommend replacing this with:

I agree, this definitly needs to be changed like proposed, but the error raised should be a ValueError.

@megies
Copy link
Member

megies commented May 22, 2019

Also the _get_s_point function should be removed and instead reuse Stream._trim_common_channels and these routines could use some cleaning up but that's likely major refactoring and I'm not gonna touch more than necessary right now.

@megies megies mentioned this issue May 22, 2019
9 tasks
@megies
Copy link
Member

megies commented May 22, 2019

@sjohnson5 please check out #2403

@megies megies modified the milestones: 2.0.0, 1.2.0 May 22, 2019
@sjohnson5
Copy link
Author

Looks great! It's a bummer that frqlow and frqhigh can't be made kwargs, but I understand why.

@megies
Copy link
Member

megies commented May 24, 2019

Looks great!

"Looks great!" as in "code comparison looks cool with all the green/red lines" or as in "tried it and works"? ;-)

@megies
Copy link
Member

megies commented May 24, 2019

Waiting for final OP feedback

@megies megies reopened this May 24, 2019
@megies
Copy link
Member

megies commented Nov 29, 2019

Well closing I guess

@megies megies closed this as completed Nov 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug confirmed bug .signal issues related to our signal processing functionalities
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants