PickTimes export to Obspy
I want to export to ObsPy the catalog created with QuakeMigrate locations. So far, so good. The problem is the picks on the exported file. When PickTime is unavailable (filled with -1 in picks files), it's filled with the ModelledTime. I need only PickTime
To export the catalog, I use the following code:
from quakemigrate.export import to_obspy
catalogo = to_obspy.read_quakemigrate("/Volumes/SEISMIC/quakemigrate/8H_QNET/outputs/runs/run_name/", units="km", local_mag_ph="S")
catalogo.write('detections.xml', 'QUAKEML')
The following lines are an excerpt of the picks file for a given earthquake:
Station,Phase,ModelledTime,PickTime,PickError,SNR
PPJ,S,2020-01-01T01:45:51.071473Z,2020-01-01T01:45:52.204215Z,0.0805,14
QB03,P,2020-01-01T01:45:45.681704Z,2020-01-01T01:45:44.461308Z,0.0783,7.64
And the following lines are the output in XML format to the same event as the previous lines:
<time>
<value>2020-01-01T01:45:52.204215Z</value>
<uncertainty>0.0805</uncertainty>
</time>
<waveformID networkCode="" stationCode="PPJ"></waveformID>
<methodID>smi:local/autopick</methodID>
<phaseHint>S</phaseHint>
<ns0:snr>14.0</ns0:snr>
</pick>
<pick publicID="smi:local/d95eb323-4139-4072-b409-e4f270e85ff8">
<time>
<value>2020-01-01T01:45:45.681704Z</value>
</time>
<waveformID networkCode="" stationCode="QB03"></waveformID>
<methodID>smi:local/modelled</methodID>
<phaseHint>P</phaseHint>
</pick>
I tried to avoid this problem, I removed lines 228 and 229 of module to_obspy.py nonetheless, the problem (bug?) remains.
Hey,
So you want your final catalog to have each event + the associated picks made by the picker, and nothing else?
In the example you've provided, I don't see an issue - is there not another pick associated with the P pick made on QB03?
If you just don't want any modelled phase arrival estimates ("picks") in the final catalog, you could replace lines 217-232 with something like:
pick = Pick()
pick.extra = AttribDict()
pick.waveform_id = wid
pick.method_id = "autopick"
pick.phase_hint = phase
if str(pickline["PickTime"]) != "-1":
pick.time = UTCDateTime(pickline["PickTime"])
pick.time_errors.uncertainty = float(pickline["PickError"])
pick.extra.snr = {"value": float(pickline["SNR"]),
"namespace": ns}
else:
continue
event.picks.append(pick)
The reference indentation (i.e. that of pick = Pick()) should be the same as line 215.
@hemmelig thanks for your fast reply,
Removing lines 228 and 229 doesn't fix the problem. The output still containing autopick and modelled time picks.
To the same example I sent before:
Station,Phase,ModelledTime,PickTime,PickError,SNR
PPJ,P,2020-01-01T01:45:46.934829Z,-1,-1,-1
PPJ,S,2020-01-01T01:45:51.071473Z,2020-01-01T01:45:52.204215Z,0.0805,14
QB03,P,2020-01-01T01:45:45.681704Z,2020-01-01T01:45:44.461308Z,0.0783,7.64
QB03,S,2020-01-01T01:45:49.115079Z,-1,-1,-1
quakeml is the next one:
<pick publicID="smi:local/cd499310-296c-47df-b699-9c6b6f15dc41">
<time>
<value>2020-01-01T01:45:46.934829Z</value>
</time>
<waveformID networkCode="" stationCode="PPJ"></waveformID>
<methodID>smi:local/modelled</methodID>
<phaseHint>P</phaseHint>
</pick>
<pick publicID="smi:local/b6d177e9-ee9f-40e0-a0fe-8139d5c76dde">
<time>
<value>2020-01-01T01:45:51.071473Z</value>
</time>
<waveformID networkCode="" stationCode="PPJ"></waveformID>
<methodID>smi:local/modelled</methodID>
<phaseHint>S</phaseHint>
</pick>
<pick publicID="smi:local/30be6260-5b20-4f06-87bf-9418fd72e64e">
<time>
<value>2020-01-01T01:45:52.204215Z</value>
<uncertainty>0.0805</uncertainty>
</time>
<waveformID networkCode="" stationCode="PPJ"></waveformID>
<methodID>smi:local/autopick</methodID>
<phaseHint>S</phaseHint>
<ns0:snr>14.0</ns0:snr>
</pick>
<pick publicID="smi:local/34f58a31-fe1a-41e4-941f-dc8b0e45f901">
<time>
<value>2020-01-01T01:45:45.681704Z</value>
</time>
<waveformID networkCode="" stationCode="QB03"></waveformID>
<methodID>smi:local/modelled</methodID>
<phaseHint>P</phaseHint>
</pick>
<pick publicID="smi:local/76a6a6ca-38b9-4ffe-8434-28ffb0d053da">
<time>
<value>2020-01-01T01:45:44.461308Z</value>
<uncertainty>0.0783</uncertainty>
</time>
<waveformID networkCode="" stationCode="QB03"></waveformID>
<methodID>smi:local/autopick</methodID>
<phaseHint>P</phaseHint>
<ns0:snr>7.64</ns0:snr>
</pick>
<pick publicID="smi:local/020b355b-391e-480c-948c-ea1b5def2647">
<time>
<value>2020-01-01T01:45:49.115079Z</value>
</time>
<waveformID networkCode="" stationCode="QB03"></waveformID>
<methodID>smi:local/modelled</methodID>
<phaseHint>S</phaseHint>
</pick>
As you see the modelled pick times still on the outputs.
Hi @fontiela. As you've observed, the current code always outputs both autopick times (when they are available) and modelled times. Adding the option to output only one or the other is a good suggested improvement! At the moment the only way to filter them out is to remove/ignore
pick times which do not have an uncertainty and SNR associated with them - you could do if not pick.time.uncertainty: ... or something similar, I think.
Removing lines 228 and 229 should stop modelled times being written, but you need to re-install to make these changes take effect (I.e. re-run python setup.py install). If you've already done this (or installed with python setup.py develop) then something weird is happening. Maybe @hemmelig can check this as I'm not at my computer for the next few days!
Hi @TomWinder, I will re-install and let you know if the changes work or not.
Hi @fontiela - sorry, I should have made my code snippet a little more clear - it is a bit more than just removing 228-229. As @TomWinder says, you'll need to reinstall the code between any edits. I recommend running pip install . from the QuakeMigrate directory (the one that contains setup.py) instead of python setup.py install, as this will ensure any previously installed versions are removed from your active environment. Any further issues, let me know!
Hi @TomWinder and @hemmelig
The changes work fine after reinstall QuakeMigrate. My output are exactly what I was looking for.
To let you know that reinstall was a bit hard, because file _int8_t.h (from GCC) wasn't found. I fixed the problem with the update of CLANG from version 12.0 to 14.0. Sometimes Apple is finicky.
That's interesting to hear, but I you're right - that is a C issue outside of our immediate control. We ought to have an operating system agnostic solution to installing QuakeMigrate in place very soon that will allow us to identify and fix any issues like this as and when they arise!
As this seems to be resolved, I'll close this Issue for now. I've made a note to revisit expanding the export function to give the user more control over which picks etc get included!