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
sc3ml to Inventory #1182
sc3ml to Inventory #1182
Conversation
I have a stylesheet to convert seiscomp3 xml to QuakeML: https://github.com/barsch/seishub.plugins.seismology/blob/master/seishub/plugins/seismology/xslt/seiscomp2quakeml.xslt That would be an option, with lxml it's only a few lines of code to transform to QuakeML string we can read: from lxml import etree
doc = etree.parse("gof2014ckob.last.xml")
doc_xslt = etree.parse("seiscomp2quakeml.xslt")
xslt = etree.XSLT(doc_xslt)
result = xslt(doc)
xml = etree.tostring(result, encoding="UTF-8", method="xml", xml_declaration=True, pretty_print=False)
cat = read_events(xml, "QUAKEML") I just tried it and the result had a couple of schema breaches.. strange. But it should be pretty easy to correct/figure out. Would certainly not hurt ot have a seiscomp xml reader in obspy.. probably a corrected version of the xslt would be the simplest option.. |
Hi Megies, what you linked seems not to deal with station metadata and response information (e.g. stages, paz, FIR coefficients). I intend on parsing sc3ml station metadata (similar to stationXML) to an Inventory. Here's an example from the GFZ fdsnws webservice of the data I want to put in an Inventory: |
Oh, sorry, didn't read properly and was thinking event metadata immediately.. In any case, I'd ask the seiscomp guys if they have a conversion routine in python (or C) before doing anything else. |
Seiscomp has internal functionality to load stationXML and print sc3ml, however this is not a standalone routine and requires SC to be installed. I will work on a separate branch to try and include a way to load sc3ml to ObsPy Inventories. Edit: branch can be found here https://github.com/Jollyfant/obspy/tree/io.sc3ml |
The branch has been updated with a working prototype* including unit tests. Currently, only reading from sc3ml to Inventory is implemented, might work on writing in the future. Usage is The unit tests load a full response stationXML and sc3ml for a network (EB) and writes the input back to XML using In most cases there will be slight difference in the output. For example, the station town tag may be missing for stationXML, while it is included for sc3ml. On the other hand, sensor type may be missing for sc3ml while included in stationXML. This should be easy to see using a https://github.com/Jollyfant/obspy/tree/io.sc3ml/obspy/io/sc3ml *At least I think it is working 👍 |
@@ -28,6 +28,7 @@ class StationXMLTestCase(unittest.TestCase): | |||
""" | |||
""" | |||
def setUp(self): | |||
print("WOW") |
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.
remove..
Made this into a PR from the branch you mentioned.. |
Ok, I'm going to do some more assert checks and remove that little print statement. |
That's part of the |
@QuLogic, that is right. It's just that sc3ml seems to be a little more verbose when it comes to site meta-data: |
Sorry for this taking so long. I polished it a bit and sent a PR with small changes to your branch. Once you merge it we can finally merge this PR! Thanks a lot for this! |
Polishing io.sc3ml a bit
Without having actually tried it, this looks good indeed. I have a few minor remarks:
|
Updated the comments so that should be passing soon. I guess we can merge it in to a separate io seiscomp module down the line if more stuff is rolled out but for now this seems to be OK if you ask me. |
If you plan on renaming this module later down the road, please rename it now. It is always a huge hassle to rename things if people are already using it. |
Ok, let's do it then 👍 |
Thanks, and sorry about the hassle, but we really need to get things right with the first shot, otherwise we end up with more deprecation/reroute pain later.. ;-) And I think this hierarchy makes sense even if it turns out that nothing gets added later in addition.. |
Uh, something went wrong with the Travis build. Looks like a timeout or something? Is it possible for someone to retry the build without pushing a new commit or pull request. |
Yes that's possible for us, and I guess somebody already restarted the build in the meantime.. |
Great! Thanks for this :-) |
👍 nicely done! |
Hi,
I've started writing a routine that can directly import Seiscomp3 sc3ml (in addition to stationXML) to an Inventory class. Before spending more time, I would like to discuss if there currently exists an easy way to import sc3ml format to Obspy? And would the option to import sc3ml to Inventory be a valuable addition to ObsPy?
Like to hear your thoughts on this!