problems about generating station.xml file

Dear obspy users,

I am trying to test a simple obspy-python script in order to generate a station.xml file ("test_manual_STATS.xml"). The scripts runs smoothly except the last line of it where it tries to write the variable "manu_stat_xml" into a file named test_manual_STATS.xml.

I pasted the error message below. Has there anyone experienced such problem before for those stations that do not belong to IRIS/ORFEUS database.
I appreciate any tip in fixing this problem. Note that the simple script I use is in the attachment.

bests

Gizem

Here is the error message:

seismo_anatolia %python test.py
Traceback (most recent call last):
   File "test.py", line 21, in <module>
     manu_stat_xml.write('eken_manual_STATS.xml',format='STATIONXML')
   File "/home/anatolia/UTILS/anaconda2/lib/python2.7/site-packages/obspy/core/inventory/inventory.py", line 257, in write
     return write_format(self, path_or_file_object, **kwargs)
   File "/home/anatolia/UTILS/anaconda2/lib/python2.7/site-packages/obspy/io/stationxml/core.py", line 776, in _write_stationxml
     etree.SubElement(root, "Source").text = inventory.source
   File "src/lxml/lxml.etree.pyx", line 1031, in lxml.etree._Element.text.__set__ (src/lxml/lxml.etree.c:51697)
   File "src/lxml/apihelpers.pxi", line 711, in lxml.etree._setNodeText (src/lxml/lxml.etree.c:23071)
   File "src/lxml/apihelpers.pxi", line 699, in lxml.etree._createTextNode (src/lxml/lxml.etree.c:22931)
   File "src/lxml/apihelpers.pxi", line 1437, in lxml.etree._utf8 (src/lxml/lxml.etree.c:30194)
TypeError: Argument must be bytes or unicode, got 'list'

test.py (932 Bytes)

Hi Gizem,

I’ve made a few edits to your script to get it to work (Attached). I added the “site” and “creation_date” attributes for the station, as well as the “source” attribute to the inventory.

Regards,
Andrew

test_patch.py (1.04 KB)

1 Like

Alinti Andrew Reynen <andrew.m.g.reynen@gmail.com>