def align_design(design_set, shift_len, reject, multiplex, no_missed=True,<EOL>plot=False):
trace_lengths = [tr.stats.endtime - tr.stats.starttime for st in design_set<EOL>for tr in st]<EOL>clip_len = min(trace_lengths) - (<NUM_LIT:2> * shift_len)<EOL>stachans = list(set([(tr.stats.station, tr.stats.channel)<EOL>for st in design_set for tr in st]))<EOL>remove_set = []<EOL>for stachan in stachans:<EOL><INDENT>trace_list = []<EOL>trace_ids = []<EOL>for i, st in enumerate(design_set):<EOL><INDENT>tr = st.select(station=stachan[<NUM_LIT:0>], channel=stachan[<NUM_LIT:1>])<EOL>if len(tr) > <NUM_LIT:0>:<EOL><INDENT>trace_list.append(tr[<NUM_LIT:0>])<EOL>trace_ids.append(i)<EOL><DEDENT>if len(tr) > <NUM_LIT:1>:<EOL><INDENT>warnings.warn('<STR_LIT>' % (stachan[<NUM_LIT:0>],<EOL>stachan[<NUM_LIT:1>]))<EOL><DEDENT><DEDENT>shift_len_samples = int(shift_len * trace_list[<NUM_LIT:0>].stats.sampling_rate)<EOL>shifts, cccs = stacking.align_traces(<EOL>trace_list=trace_list, shift_len=shift_len_samples, positive=True)<EOL>for i, shift in enumerate(shifts):<EOL><INDENT>st = design_set[trace_ids[i]]<EOL>start_t = st.select(<EOL>station=stachan[<NUM_LIT:0>], channel=stachan[<NUM_LIT:1>])[<NUM_LIT:0>].stats.starttime<EOL>start_t += shift_len<EOL>start_t -= shift<EOL>st.select(<EOL>station=stachan[<NUM_LIT:0>], channel=stachan[<NUM_LIT:1>])[<NUM_LIT:0>].trim(<EOL>start_t, start_t + clip_len)<EOL>if cccs[i] < reject:<EOL><INDENT>if multiplex and not no_missed:<EOL><INDENT>st.select(station=stachan[<NUM_LIT:0>],<EOL>channel=stachan[<NUM_LIT:1>])[<NUM_LIT:0>].data = np.zeros(<EOL>int(clip_len * (st.select(<EOL>station=stachan[<NUM_LIT:0>],<EOL>channel=stachan[<NUM_LIT:1>])[<NUM_LIT:0>].stats.sampling_rate) + <NUM_LIT:1>))<EOL>warnings.warn('<STR_LIT>' +<EOL>'<STR_LIT>' + stachan[<NUM_LIT:0>] + '<STR_LIT:.>' + stachan[<NUM_LIT:1>])<EOL>print('<STR_LIT>')<EOL><DEDENT>elif multiplex and no_missed:<EOL><INDENT>remove_set.append(st)<EOL>warnings.warn('<STR_LIT>')<EOL>continue<EOL><DEDENT>else:<EOL><INDENT>st.remove(st.select(station=stachan[<NUM_LIT:0>],<EOL>channel=stachan[<NUM_LIT:1>])[<NUM_LIT:0>])<EOL>print('<STR_LIT>' % cccs[i])<EOL>continue<EOL><DEDENT><DEDENT><DEDENT><DEDENT>if no_missed:<EOL><INDENT>for st in remove_set:<EOL><INDENT>if st in design_set:<EOL><INDENT>design_set.remove(st)<EOL><DEDENT><DEDENT><DEDENT>if plot:<EOL><INDENT>for stachan in stachans:<EOL><INDENT>trace_list = []<EOL>for st in design_set:<EOL><INDENT>tr = st.select(station=stachan[<NUM_LIT:0>], channel=stachan[<NUM_LIT:1>])<EOL>if len(tr) > <NUM_LIT:0>:<EOL><INDENT>trace_list.append(tr[<NUM_LIT:0>])<EOL><DEDENT><DEDENT>if len(trace_list) > <NUM_LIT:1>:<EOL><INDENT>plotting.multi_trace_plot(traces=trace_list, corr=True,<EOL>stack=None, title='<STR_LIT:.>'.join(stachan))<EOL><DEDENT>else:<EOL><INDENT>print('<STR_LIT>')<EOL><DEDENT><DEDENT><DEDENT>return design_set<EOL>
Align individual traces within streams of the design set.

Perform before Detector.construct to align traces before computing the \
singular value decomposition.

:type design_set: list
:param design_set: List of obspy.core.stream.Stream to be aligned
:type shift_len: float
:param shift_len: Maximum shift (plus/minus) in seconds.
:type reject: float
:param reject: Minimum correlation for traces, only used if align=True.
:type multiplex: bool
:param multiplex: If you are going to multiplex the data, then there has \
    to be data for all channels, so we will pad with zeros, otherwise \
    there is no need.
:type no_missed: bool
:param: no_missed: Reject streams with missed traces, defaults to True. \
    A missing trace from lots of events will reduce the quality of the \
    subspace detector if multiplexed.  Only used when multi is set to True.
:type plot: bool
:param plot: Whether to plot the aligned traces as we go or not.

:rtype: list
:return: List of obspy.core.stream.Stream of aligned streams

.. Note:: Assumes only one trace for each channel for each stream in the \
    design_set. If more are present will only use the first one.

.. Note:: Will cut all traces to be the same length as required for the \
    svd, this length will be the shortest trace length - 2 * shift_len