Fix stationxml extras - #3588
Conversation
…'s parent) Hopefully fixes #3574
|
@nick-falco you were the one coding that extra thing ? 😇 |
…k population of nmsmap if None for _write_stationxml (taken from inventory._namespaces)
|
on my machine all tests pass, including doctests. So I suppose it's again a change on the way doctests prints are compared? https://tests.obspy.org/144878/ The shapefile-related issues are linked to #3599 (pyshp version 3.0 just rolled out). |
|
In brief: should be 💚 light to review & merge. @WayneCrawford |
Hey @ThomasLecocq. I've been pretty out of the loop with this for several years now, as I no longer work at IRIS. I would need to be brought up to speed with what you're trying to accomplish. |
|
@nick-falco hehe no worries. I checked the "git blame" of the lines added to support the extra namespace + fields and found yours :) I think this PR covers all cases now, but I don't have a complete test with namespaced' items for each item, would you know where to find that ? |
|
@crotwell @chad-earthscope @jschaeff do you have a stationXML with ALL possible cases populated? It'd be good to add to our test data - so we could verify this PR solves namespace issues? -- or if you really really want, you can take over this PR :-) |
|
I assume you are aware of the examples in the StationXML repo, Beyond that, I don't have anything beyond what you can get from queries to the FDSN Station webservices. If you do find a comprehensive example, it might be nice to have it in the stationxml repo for furture testing purposes. |
I do not. they are, by their nature I think, ad hoc and institution/domain specific. |
|
thanks for your inputs. I'm really not knowledgeable on xml and their xsd, but would it be possible to "create" a dummy XML file that has "every" elements (even optional ones) based on the xsd ? For this PR, I'll wait for the input from @WayneCrawford too. |
|
FWIW tried to AI (warning!!!) a full example stationXML based on the published FDSN 1.2 xsd.. had to fix a few items but looks pretty good, or at least decent a starting point. (Currently doing similar work trying to map QuakeML to a pandas dataframe but that's another issue- edit I see this is already done yay) example_fdsnstation1.2.fdsnxml.txt and now with all possible custom namespaces filled in |
Hey @filefolder, unrelated to this PR, but for what is worth ObsPlus does this, although perhaps not perfectly. Here are some examples. |
looks good, but lacks the optional namespace attributes (namespace declared at the top of the file, then Elements are namespace:Type where possible (Equipment, etc) |
Ah right.. the whole point of this. I chucked in an addition version "for research purposes only". It is supposed to have xyz namespace elements in all the places the XSD allows.. but of course buyer be very aware |
What does this PR do?
Solved.
TODO:
It was possible to pass
nsmap={key:address}to thewrite()method (kwarg was passed to_write_stationxml) but it's not obvious why that couldn't be automatically populated when the inventory was read with a ns in it. The implementation now stores the namespace dictionnary into theInventory._namespacesand if thewritemethod is called without nsmap, it'll first try to get it from the inventory, then fall back to an empty dict if not available.Why was it initiated? Any relevant Issues?
Ref: Issue #3574
Tested on the provided file, which is also now included in the
io/stationxml/tests/dataPR Checklist
masterfor new features,maintenance_...for bug fixesno_cilabel can be added to skip CI buildsCHANGELOG.txt.ready for reviewlabel when you are ready for the PR to be reviewed.