-
Notifications
You must be signed in to change notification settings - Fork 12
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
V2 asdf #56
V2 asdf #56
Conversation
Hi Kris, I just force-pushed some commits. Here's what I did:
More commits to come... |
Claudio, Concerning the use of waveform tags in ASDF files, we should either define a configuration parameter for this or else set the default value of 'tag' in Finally, I noticed that you hardcoded the tag "raw" in |
This is in the next commit to come 😉
I'm thinking about a more robust way to detect the file, not based on the extension...
Ok, I'm changing the default to
Oops, that's an error made by Copilot in the refactoring process 😆 |
Force-pushed to fix these two points. Is it ok now? |
Sorry, there was a small error. Force-pushed again |
Claudio, it works. |
9dcffb8
to
1038ba2
Compare
Hi Kris, from sourcespec2.setup import config
config.options.asdf_file = ASDF_FILE_PATH
config.options.asdf_tag = 'raw'
from sourcespec2.input import read_event_and_picks
event, picks = read_event_and_picks()
from sourcespec2.input import read_station_metadata
inventory = read_station_metadata()
from sourcespec2.input import read_traces
st = read_traces() Note that no other options need to be specified to Please let me know if you're satisfied with this workflow. I'm making some further adjustments to include in the same workflow the possibility of reading event and station metadata from the SAC header. |
Choose between parse_asdf_inventory and read_inventory depending on extension in read_station_metadata function.
Choose between obspy.read and parse_asdf_traces in _read_trace_files function depending on file extension.
Note: the option will allow also reading traces and metadata from the ASDF file (to be implemented in the next commits). Also, renamed asdf.py to asdf_event.py
The function was previously named parse_qml_file()
…ath` is None Also, add `config.options.asdf_file` to the list of files to symlink.
I have a question concerning the function Its current signature is: def parse_asdf_traces(asdf_file, tag=None, read_headers=False):
... Is there any practical case in which |
Yes, the 2 options are independent. All waveform data within an ASDF file are stored under a particular tag. The corresponding trace headers are stored in the auxiliary data with the same tag. The |
Ok, so nothing to change then 😉 . We will have to add documentation for all the changes and the new features (tracking this in #58). |
Claudio, Just tested, and I confirm it works. |
Great!
I admit, I'm lost. But I think that Anyway, |
We can maybe merge this PR now? |
Can I still try adding support for wildcards in ASDF tags? I will look into it now. |
Sure! |
…ards. Added 'header_key' argument to _parse_asdf_headers function, and allowed 'tag' argument to be list. Improved error catching when trying to deserialize header values in _parse_asdf_headers function.
I added support for wildcards ('?' or '*') in ASDF tags.
to read 3 traces (including trace headers), even though they are stored with different tags. |
Great! Saw that! The only thing missing, from my point of view, is command line support for multiple tags (i.e., |
Wait! This is not even supported from your code: the So, the use cases are:
If that is fine with you, there is nothing to change! Alternatively, we could allow the latter by splitting tag by comma, e.g.: config.options.asdf_tag = 'aaaa,bbbb,cccc' What do you think? |
Claudio, sorry I wasn't paying attention.
|
Is this a plausible use case? Thanks! |
Not very likely, but possible. I will implement it in |
Done. I have no test case but at least the case with 1 tag still works... |
Great, thanks! I'll make my test, then some cosmetic changes (if necessary), then merge! |
Most important change is log message when no ASDF tag is specified.
Ok, I pushed some small changes. Should |
Actually I am able to test this with my multiple ASDF files case, with a list containing the same tag for each file. It works! |
Do you mean in |
Yes, but also in |
OK, I see. |
So we keep it to |
Yes, but maybe update the docstring to "trace tag(s) in ASDF file"? |
Done! Let me know if you're happy with that and I'll merge! Bon appetit! |
Looks good to me! |
Time to hit that "Merge" button! Thanks for this good work! 🙏 |
I will not have time to further work on SourceSpec today. |
Thank you too, Claudio. |
I'll try to create the |
In this branch, I add further support to read traces and station inventories from ASDF files:
parse_asdf_inventory()
function ininput.station_metadata.py
parse_asdf_traces()
function ininput.traces.py
These functions can be used interactively as follows:
In addition, I also modified
input.event_parsers.quakeml.parse_qml_file()
,input.station_metadata.read_station_metadata()
andinput.traces._read_trace_files()
to choose between the ASDF/non-ASDF parsers depending on file extension (.asdf
or.h5
for ASDF format). This should allow using ASDF file(s) in the CLI as well, as shown here interactively:However, as ASDF files may contain different waveform data labeled with tags, we might consider 1 or 2 additional configuration options:
asdf_tag
to specify the tag (the current default is 'raw') and perhaps alsoasdf_read_headers
to specify whether or not to try reading trace headers (current default False). The latter is not specifically defined in the ASDF standard, but I implemented the way this is done in ESM as well as my own way (which is more logical).