Skip to content

Instantly share code, notes, and snippets.

@emolch
Created February 8, 2017 10:40
Show Gist options
  • Save emolch/a661ce69a53800bbc9f13ed2778858c9 to your computer and use it in GitHub Desktop.
Save emolch/a661ce69a53800bbc9f13ed2778858c9 to your computer and use it in GitHub Desktop.
import sys
from pyrocko.fdsn import station as fs
# Example on how to manipulate StationXML with Pyrocko (pyrocko.fdsn.station)
#
# Reads StationXML file and replaces sensor orientation and input unit
# information
sx = fs.load_xml(filename=sys.argv[1])
comp_to_azi_dip = {
'X': (0., 0.),
'Y': (90., 0.),
'Z': (0., -90.),
}
for network in sx.network_list:
for station in network.station_list:
for channel in station.channel_list:
azi, dip = comp_to_azi_dip[channel.code]
channel.azimuth.value = azi
channel.dip.value = dip
channel.response.instrument_sensitivity.input_units.name = 'M'
print sx.dump_xml()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment