def extract_from_stream(stream, detections, pad=<NUM_LIT>, length=<NUM_LIT>):
streams = []<EOL>for detection in detections:<EOL><INDENT>cut_stream = Stream()<EOL>for pick in detection.event.picks:<EOL><INDENT>tr = stream.select(station=pick.waveform_id.station_code,<EOL>channel=pick.waveform_id.channel_code)<EOL>if len(tr) == <NUM_LIT:0>:<EOL><INDENT>print('<STR_LIT>')<EOL>print(pick)<EOL>continue<EOL><DEDENT>cut_stream += tr.slice(<EOL>starttime=pick.time - pad,<EOL>endtime=pick.time - pad + length).copy()<EOL><DEDENT>streams.append(cut_stream)<EOL><DEDENT>return streams<EOL>
Extract waveforms for a list of detections from a stream.

:type stream: obspy.core.stream.Stream
:param stream: Stream containing the detections.
:type detections: list
:param detections: list of eqcorrscan.core.match_filter.detection
:type pad: float
:param pad: Pre-detection extract time in seconds.
:type length: float
:param length: Total extracted length in seconds.

:returns:
    list of :class:`obspy.core.stream.Stream`, one for each detection.
:type: list