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
Conversation
+DOCS |
There was a problem hiding this 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.
obspy/io/hypodd/pha.py
Outdated
temp = f.readline() | ||
except Exception: | ||
return False | ||
return temp.startswith(b'#') and len(temp.split()) == 15 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
for net in inventory: | ||
for sta in net: | ||
if len(sta) == 0: | ||
temp = id_map.get(sta.code, id_default) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
misc/docs/source/packages/index.rst
Outdated
@@ -95,6 +95,7 @@ categories.* | |||
obspy.io.css | |||
obspy.io.gcf | |||
obspy.io.gse2 | |||
obspy.io.hypodd |
There was a problem hiding this comment.
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.
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>
CircleCI: |
Yeah, I already saw this. Committing inside the browser is a bit error prone. |
@krischer thanks for the review. I think the PR is ready. |
>>> 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 |
There was a problem hiding this comment.
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! 😎
There was a problem hiding this 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
obspy/core/util/__init__.py
Outdated
@@ -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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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).
There was a problem hiding this 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!
OK, I addressed it. However, I am not authorized to merge. |
Yea this is not good. I opened #2384 to discuss it. |
🎉 thanks for the PR @trichter |
PR Checklist
master
for new features,maintenance_...
for bug fixesJust remove the space in the following string after the + sign: + DOCS
CHANGELOG.txt
.