Skip to content

PH5 Web Services Shot Gather

Nick Falco edited this page Aug 10, 2017 · 31 revisions

For active (controlled) source experiments, users may wish to request data from PH5 Web Services as a Common Shot Order Gather. Below is an example of one way that this can be accomplished using the web services and ObsPy.

Common Shot Order Gather Example

from obspy.clients import fdsn
from obspy import UTCDateTime
from obspy.core.util import AttribDict
from obspy.geodetics.base import gps2dist_azimuth


# Use ph5ws-station to retrieve ZI (15-017) station metadata
STATION = 'http://service.iris.edu/ph5ws/station/1'
c = fdsn.client.Client(
                       service_mappings={
                           'station': STATION
                       },
                       debug=True
                      )
inventory = c.get_stations(network='ZI', station='*', 
                    location='--', channel='DPZ',
                    level='response',
                    starttime=UTCDateTime('2015-06-29T01:00:00.0'),
                    endtime=UTCDateTime('2015-06-29T09:00:00.0'))

# Use ph5ws-event to retrieve ZI (15-017) event metadata
EVENT = 'http://service.iris.edu/ph5ws/event/1'
c = fdsn.client.Client(
                       service_mappings={
                           'event': EVENT
                       },
                       debug=True
                      )
events = c.get_events(catalog='ZI',
                    starttime=UTCDateTime('2015-06-29T01:00:00.0'),
                    endtime=UTCDateTime('2015-06-29T09:00:00.0'))

# Use ph5ws-dataselect to retrieve ZI (15-017) waveform data
DATASELECT = 'http://service.iris.edu/ph5ws/dataselect/1'
c = fdsn.client.Client(
               service_mappings={
                   'dataselect': DATASELECT
               },
               debug=True
              )
# Request the first 60 seconds of data immediately following 
# the shot. The "by shot" ph5ws-dataselect request type 
# option can be used as an alternative to manual windowing.
stream = c.get_waveforms(network='ZI', station='*', 
                        location='--', channel='DPZ',
                        starttime=events[0].origins[0].time,
                        endtime=events[0].origins[0].time+60)
stream.attach_response(inventory)

# Compute the distance from the source for each channel
for trace in stream:
    for station in inventory[0]:
        for channel in station:
            if trace.stats.station == station.code and \
               trace.stats.location == channel.location_code and \
               trace.stats.channel == channel.code:
                trace.stats.coordinates = AttribDict(
                                            {'latitude': channel.latitude, 
                                             'longitude': channel.longitude})
                trace.stats.distance = gps2dist_azimuth(
                                            events[0].origins[0].latitude, 
                                            events[0].origins[0].longitude, 
                                            channel.latitude, 
                                            channel.longitude)[0]

# Order the traces by distance from the source 
stream.traces.sort(key=lambda x: x.stats.distance)
# Plot the traces
stream.plot(type='section',
            ev_coord=(events[0].origins[0].latitude, 
                      events[0].origins[0].longitude),
            dist_degree=True,
            size=(800, 1024))

Running this code produces the following plot:

Shot Gather for Event 5011