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

Add read support for HypoDD pha files #2378

Merged
merged 23 commits into from Apr 12, 2019
Merged

Add read support for HypoDD pha files #2378

merged 23 commits into from Apr 12, 2019

Conversation

trichter
Copy link
Member

PR Checklist

  • Correct base branch selected? master for new features, maintenance_... for bug fixes
  • This PR is not directly related to an existing issue (which has no PR yet).
  • If the PR is making changes to documentation, docs pages can be built automatically.
    Just remove the space in the following string after the + sign: + DOCS
  • All tests still pass.
  • Any new features or fixed regressions are be covered via new tests.
  • Any new or changed features have are fully documented.
  • Significant changes have been added to CHANGELOG.txt .

@trichter
Copy link
Member Author

+DOCS

Copy link
Member

@krischer krischer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this! Some comments in-line.

temp = f.readline()
except Exception:
return False
return temp.startswith(b'#') and len(temp.split()) == 15
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That seems like a pretty weak test to me and we have a couple of other text/csv like formats and the danger of false positives in the wild is IMHO pretty big. How about also checking if the first couple of entries also make up a valid date time object?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also consider putting weak detection routines at the very end of the autodetection chain.

obspy/io/hypodd/pha.py Outdated Show resolved Hide resolved
for net in inventory:
for sta in net:
if len(sta) == 0:
temp = id_map.get(sta.code, id_default)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit confused here - if the station is already in the id_map the users have given some mapping explicitly (they might want to for example map the station to a different network code). I'd rather just continue here as user specified things should not be overwritten. But I might also just be missing something here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you are right. I will change this. I wanted to also support inventories with only network and station information, but that does not make much sense.

I think I will also add a warning when the construction of the id_map would not be unique (e.g. BH and HH channels in inventory) and move these functions to some util module, because they are also used by evt plugin. Is it OK if I add a new file obspy/io/util.py?

obspy/io/hypodd/pha.py Show resolved Hide resolved
obspy/io/hypodd/tests/test_pha.py Show resolved Hide resolved
@@ -95,6 +95,7 @@ categories.*
obspy.io.css
obspy.io.gcf
obspy.io.gse2
obspy.io.hypodd
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's the waveform plugin section. Please add it to the event plugin section.

obspy/io/hypodd/pha.py Outdated Show resolved Hide resolved
obspy/io/hypodd/pha.py Outdated Show resolved Hide resolved
obspy/io/hypodd/pha.py Show resolved Hide resolved
obspy/io/hypodd/pha.py Outdated Show resolved Hide resolved
krischer and others added 8 commits April 11, 2019 23:22
Co-Authored-By: trichter <tom.eulenfeld@uni-jena.de>
Co-Authored-By: trichter <tom.eulenfeld@uni-jena.de>
Co-Authored-By: trichter <tom.eulenfeld@uni-jena.de>
Co-Authored-By: trichter <tom.eulenfeld@uni-jena.de>
@megies
Copy link
Member

megies commented Apr 12, 2019

CircleCI: obspy/io/hypodd/pha.py:61:27: E999 SyntaxError: invalid syntax

@trichter
Copy link
Member Author

CircleCI: obspy/io/hypodd/pha.py:61:27: E999 SyntaxError: invalid syntax

Yeah, I already saw this. Committing inside the browser is a bit error prone.

@trichter
Copy link
Member Author

trichter commented Apr 12, 2019

@krischer thanks for the review. I think the PR is ready.

obspy/core/util/misc.py Outdated Show resolved Hide resolved
>>> print(cat)
2 Event(s) in Catalog:
2025-05-14T14:35:35.510000Z | +40.225, +10.450 | 3.5 None
2025-05-14T15:43:05.280000Z | +40.223, +10.450 | 1.8 None
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here they say you can't predict earthquakes! 😎

setup.py Outdated Show resolved Hide resolved
@megies megies added this to the 1.2.0 milestone Apr 12, 2019
@megies megies added .io issues generally related to our read/write plugins enhancement feature request labels Apr 12, 2019
Copy link
Member

@megies megies left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty much ready to go

@@ -34,7 +34,8 @@
PROJ4_VERSION)
from obspy.core.util.misc import (BAND_CODE, CatchOutput, complexify_string,
guess_delta, loadtxt, score_at_percentile,
to_int_or_zero, SuppressOutput)
to_int_or_zero, SuppressOutput,
_seed_id_map)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason to put this here? It could just be directly imported from misc.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmh, it has a leading underscore, so its private, but I thought it might even be of use outside obspy. And even inside obspy its easier to import from core.util instead of core.util.misc. What do you think?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our current policy is that everything with a leading underscore is internal only and we are free to change the API of those functions and even remove them so I'd advise against using it outside of ObsPy.

And these "import aliases" just make it harder to find where things originate from and the convenience improvement from not having to write .misc is IMHO not worth the trade-off. But that is just my opinion and feel free to choose.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our current policy is that everything with a leading underscore is internal only and we are free to change the API of those functions and even remove them so I'd advise against using it outside of ObsPy.

On the other hand, if you do want to use it, you can rename it and remove the leading underscore. But then we need proper tests for it as well (I didnt check if there already are tests for this, maybe there are already).

Copy link
Member

@krischer krischer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only a minor nitpick from me this time around. Feel free to merge once you think its ready!

@trichter
Copy link
Member Author

OK, I addressed it. However, I am not authorized to merge.

@krischer
Copy link
Member

OK, I addressed it. However, I am not authorized to merge.

Yea this is not good. I opened #2384 to discuss it.

@krischer krischer merged commit e97fe91 into master Apr 12, 2019
@krischer krischer deleted the hypodd branch April 12, 2019 20:28
@megies
Copy link
Member

megies commented Apr 15, 2019

🎉 thanks for the PR @trichter

@megies megies added this to Done in Release 1.2.0 May 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement feature request .io issues generally related to our read/write plugins
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

4 participants