def sactoevent(st, debug=<NUM_LIT:0>):
<EOL>_version_check()<EOL>float_nan = -<NUM_LIT><EOL>if not isinstance(st, Stream):<EOL><INDENT>msg = ('<STR_LIT>' +<EOL>'<STR_LIT>' +<EOL>'<STR_LIT>')<EOL>raise ValueError(msg)<EOL><DEDENT>for tr in st:<EOL><INDENT>if not tr.stats._format == '<STR_LIT>':<EOL><INDENT>msg = ('<STR_LIT>' % (tr.stats.station,<EOL>tr.stats.channel))<EOL>raise ValueError(msg)<EOL><DEDENT><DEDENT>event = Event()<EOL>event.origins.append(Origin())<EOL>event.origins[<NUM_LIT:0>].time = UTCDateTime(year=st[<NUM_LIT:0>].stats.sac.nzyear,<EOL>julday=st[<NUM_LIT:0>].stats.sac.nzjday,<EOL>hour=st[<NUM_LIT:0>].stats.sac.nzhour,<EOL>minute=st[<NUM_LIT:0>].stats.sac.nzmin,<EOL>second=st[<NUM_LIT:0>].stats.sac.nzsec,<EOL>microsecond=st[<NUM_LIT:0>].stats.<EOL>sac.nzmsec * <NUM_LIT:1000>)<EOL>try:<EOL><INDENT>event.origins[<NUM_LIT:0>].latitude = st[<NUM_LIT:0>].stats.sac.evla<EOL>event.origins[<NUM_LIT:0>].longitude = st[<NUM_LIT:0>].stats.sac.evlo<EOL>event.origins[<NUM_LIT:0>].depth = st[<NUM_LIT:0>].stats.sac.evdp<EOL>if event.origins[<NUM_LIT:0>].latitude == float_nan:<EOL><INDENT>event.origins[<NUM_LIT:0>].latitude = None<EOL><DEDENT>if event.origins[<NUM_LIT:0>].longitude == float_nan:<EOL><INDENT>event.origins[<NUM_LIT:0>].longitude = None<EOL><DEDENT>if event.origins[<NUM_LIT:0>].depth == float_nan:<EOL><INDENT>event.origins[<NUM_LIT:0>].depth = None<EOL><DEDENT><DEDENT>except KeyError:<EOL><INDENT>event.origins[<NUM_LIT:0>].latitude = None<EOL>event.origins[<NUM_LIT:0>].longitude = None<EOL>event.origins[<NUM_LIT:0>].depth = None<EOL><DEDENT>except AttributeError:<EOL><INDENT>event.origins[<NUM_LIT:0>].latitude = None<EOL>event.origins[<NUM_LIT:0>].longitude = None<EOL>event.origins[<NUM_LIT:0>].depth = None<EOL><DEDENT>for tr in st:<EOL><INDENT>reference_time = UTCDateTime(year=tr.stats.sac.nzyear,<EOL>julday=tr.stats.sac.nzjday,<EOL>hour=tr.stats.sac.nzhour,<EOL>minute=tr.stats.sac.nzmin,<EOL>second=tr.stats.sac.nzsec,<EOL>microsecond=tr.stats.sac.nzmsec * <NUM_LIT:1000>)<EOL>for pick_number in range(<NUM_LIT:10>):<EOL><INDENT>pick_key = '<STR_LIT:t>' + str(pick_number)<EOL>phase_key = '<STR_LIT>' + str(pick_number)<EOL>try:<EOL><INDENT>if tr.stats.sac[pick_key] == float_nan:<EOL><INDENT>if debug > <NUM_LIT:1>:<EOL><INDENT>msg = '<STR_LIT>' + pick_key +'<STR_LIT>' + tr.stats.station + '<STR_LIT:.>' +tr.stats.channel<EOL>warnings.warn(msg)<EOL><DEDENT>continue<EOL><DEDENT>pick_time = reference_time + tr.stats.sac[pick_key]<EOL>phase_hint = tr.stats.sac[phase_key].split()[<NUM_LIT:0>]<EOL><DEDENT>except KeyError:<EOL><INDENT>if debug > <NUM_LIT:1>:<EOL><INDENT>msg = '<STR_LIT>' + pick_key + '<STR_LIT>' +tr.stats.station + '<STR_LIT:.>' + tr.stats.channel<EOL>warnings.warn(msg)<EOL><DEDENT>continue<EOL><DEDENT>if debug > <NUM_LIT:0>:<EOL><INDENT>msg = '<STR_LIT>' + pick_key + '<STR_LIT>' +tr.stats.station + '<STR_LIT:.>' + tr.stats.channel<EOL>print(msg)<EOL><DEDENT>waveform_id = WaveformStreamID(station_code=tr.stats.station,<EOL>network_code=tr.stats.network,<EOL>channel_code=tr.stats.channel)<EOL>pick = Pick(waveform_id=waveform_id,<EOL>phase_hint=phase_hint,<EOL>time=pick_time)<EOL>event.picks.append(pick)<EOL><DEDENT>try:<EOL><INDENT>if tr.stats.sac['<STR_LIT:a>'] == float_nan:<EOL><INDENT>if debug > <NUM_LIT:1>:<EOL><INDENT>msg = '<STR_LIT>' + pick_key +'<STR_LIT>' + tr.stats.station + '<STR_LIT:.>' +tr.stats.channel<EOL>warnings.warn(msg)<EOL><DEDENT>continue<EOL><DEDENT>pick_time = reference_time + tr.stats.sac['<STR_LIT:a>']<EOL>phase_hint = tr.stats.sac['<STR_LIT>'].split()[<NUM_LIT:0>]<EOL><DEDENT>except KeyError:<EOL><INDENT>if debug > <NUM_LIT:1>:<EOL><INDENT>msg = '<STR_LIT>' + pick_key + '<STR_LIT>' +tr.stats.station + '<STR_LIT:.>' + tr.stats.channel<EOL>warnings.warn(msg)<EOL><DEDENT>continue<EOL><DEDENT>if debug > <NUM_LIT:0>:<EOL><INDENT>msg = '<STR_LIT>' +tr.stats.station + '<STR_LIT:.>' + tr.stats.channel<EOL>print(msg)<EOL><DEDENT>waveform_id = WaveformStreamID(station_code=tr.stats.station,<EOL>network_code=tr.stats.network,<EOL>channel_code=tr.stats.channel)<EOL>pick = Pick(waveform_id=waveform_id,<EOL>phase_hint=phase_hint,<EOL>time=pick_time)<EOL>event.picks.append(pick)<EOL><DEDENT>return event<EOL>
Convert SAC headers (picks only) to obspy event class.

Picks are taken from header values a, t[0-9].

:type st: obspy.core.stream.Stream
:param st: Stream of waveforms including SAC headers.
:type debug: int
:param debug: Debug level, larger number = more output.

:returns: Event with picks taken from SAC headers.
:rtype: :class:`obspy.core.event.event.Event`

.. note::
    This functionality is not supported for obspy versions below 1.0.0 as
    reference times are not read in by SACIO, which are needed for defining
    pick times.

.. note::
    Takes the event origin information from the first trace in the
    stream - to ensure this works as you expect, please populate the
    evla, evlo, evdp and nzyear, nzjday, nzhour, nzmin, nzsec, nzmsec
    for all traces with the same values.

>>> from obspy import read
>>> # Get the path to the test data
>>> import eqcorrscan
>>> import os
>>> TEST_PATH = os.path.dirname(eqcorrscan.__file__) + '/tests/test_data'
>>> st = read(TEST_PATH + '/SAC/2014p611252/*')
>>> event = sactoevent(st)
>>> print(event.origins[0].time)
2014-08-15T03:55:21.057000Z
>>> print(event.picks[0].phase_hint)
S