[obspy-users] Reading IRIS xmlns attributes from StationXML using Obspy

Nick Falco nick at iris.washington.edu
Fri Oct 7 23:43:48 CEST 2016


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 <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.

Thanks,

Nick 

> On Oct 6, 2016, at 3:08 AM, Peter Schmidt <peter.schmidt at geo.uu.se> wrote:
> 
> 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.
> 
> 
> \p
> 
> 
> 
> On 06/10/16 10:48, Tobias Megies wrote:
>> 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
>> problems.
>> 
>> cheers,
>> T
>> 
>> 
>> On 10/06/2016 12:45 AM, Lion Krischer wrote:
>>> Hi Nick,
>>> 
>>> 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:
>>> 
>>> http://docs.obspy.org/master/tutorial/code_snippets/quakeml_custom_tags.html
>>> 
>>> 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.
>>> 
>>> Cheers!
>>> 
>>> Lion
>>> 
>>> 
>>> 
>>> 
>>> On 06/10/16 00:30, Nick Falco wrote:
>>>> StationXML produced by the IRIS Station
>>>> <https://service.iris.edu/fdsnws/station/1/> 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
>>>> <http://docs.obspy.org/packages/obspy.core.inventory.html> object?
>>>> 
>>>> Thanks,
>>>> 
>>>> Nick Falco
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>>> _______________________________________________
>>>> obspy-users mailing list
>>>> obspy-users at lists.swapbytes.de
>>>> http://lists.swapbytes.de/mailman/listinfo/obspy-users
>>>> 
>>> _______________________________________________
>>> obspy-users mailing list
>>> obspy-users at lists.swapbytes.de
>>> http://lists.swapbytes.de/mailman/listinfo/obspy-users
>>> 
> 
> -- 
> ********************************************************************************
> Peter Schmidt                                      Tel: +46-18-4712259
> Swedish National Seismic Network (SNSN)         Mobile: +46-73-3190975
> Dept. of Earth Sciences:geophysics              e-mail: peter.schmidt at geo.uu.se <mailto:peter.schmidt at geo.uu.se>
> Uppsala University
> Villavagen 16
> SE-75236 Uppsala
> ********************************************************************************
> 
> _______________________________________________
> obspy-users mailing list
> obspy-users at lists.swapbytes.de <mailto:obspy-users at lists.swapbytes.de>
> http://lists.swapbytes.de/mailman/listinfo/obspy-users <http://lists.swapbytes.de/mailman/listinfo/obspy-users>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.swapbytes.de/pipermail/obspy-users/attachments/20161007/c23d5973/attachment-0001.html>


More information about the obspy-users mailing list