StationXML produced by the IRIS Station web service stores virtual network codes under the iris:alternateNetworkCodes attribute. This attribute is defined under the iris xml namespace. For example, the first line of a Station tag could read:
<Station code=“ANMO” startDate=“1995-07-14T00:00:00” endDate=“2000-10-19T16:00:00” restrictedStatus=“open” iris:alternateNetworkCodes="_FDSN,_GSN-BROADBAND,.CEUSN-CONTRIB,_FDSN-ALL,_REALTIME,.UNRESTRICTED,_GSN,.TEST">
We would like to read these codes using ObsPy. Does anyone know how, or if, you can access this information using a ObsPy Inventory object?
this is currently not possible as ObsPy does not preserve this
additional information in it internal data model. But it would be
reasonably simple to add and we already do it for QuakeML files:
So something similar would be conceivable for StationXML files but so
far it has never been necessary enough for someone to implement it.
If you (or someone else) would like to add this to ObsPy please open an
issue on github and we will guide you through the process.
Actually, I worked on it last year after somebody else brought it up.
You can have a look here: https://github.com/obspy/obspy/pull/1024
I think it's mostly ready, but since there was no feedback anymore it
kinda got left behind. You can try it out by installing obspy from that
branch. If you do so, you should be able to access those custom
attributes. Feel free to leave a comment in that ticket if you're having
Yeah, sorry for the missing feedback, the project I needed it for got put on ice (and still is) so I never got around to test it. But, my impression was also that the work were more or less done and should fit your needs.
Thanks for sharing your code Tobias. Your code worked great for reading in the custom namespace attributes.
I went ahead and wrote some code for writing the custom namespace attributes out to StationXML from obj.extra. You can see a forked version of your “stationxml_custom_tags” branch with my changes at https://github.com/nick-iris/obspy/commit/66c8593faaaf0bf5689245b3538584e414826ca5.
This approach for writing the custom namespace attributes to StationXML seems to work, except for a few issues:
1.) The Element Tree includes the custom namespace declaration everywhere it is used. I presume this is still valid StationXML, but it would look cleaner if the namespace was only declared one time.
2.) The code fails to write custom namespace attributes that are above or equal to the Network level of the StationXML.
Let me know what you think. I’m open to suggestions.