def svd(stream_list, full=False):
<EOL>stachans = list(set([(tr.stats.station, tr.stats.channel)<EOL>for st in stream_list for tr in st]))<EOL>stachans.sort()<EOL>svalues = []<EOL>svectors = []<EOL>uvectors = []<EOL>for stachan in stachans:<EOL><INDENT>lengths = []<EOL>for st in stream_list:<EOL><INDENT>tr = st.select(station=stachan[<NUM_LIT:0>],<EOL>channel=stachan[<NUM_LIT:1>])<EOL>if len(tr) > <NUM_LIT:0>:<EOL><INDENT>tr = tr[<NUM_LIT:0>]<EOL><DEDENT>else:<EOL><INDENT>warnings.warn('<STR_LIT>'<EOL>% '<STR_LIT:.>'.join(list(stachan)))<EOL>continue<EOL><DEDENT>lengths.append(len(tr.data))<EOL><DEDENT>min_length = min(lengths)<EOL>for stream in stream_list:<EOL><INDENT>chan = stream.select(station=stachan[<NUM_LIT:0>],<EOL>channel=stachan[<NUM_LIT:1>])<EOL>if chan:<EOL><INDENT>if len(chan[<NUM_LIT:0>].data) > min_length:<EOL><INDENT>if abs(len(chan[<NUM_LIT:0>].data) - min_length) > <NUM_LIT:0.1> *chan[<NUM_LIT:0>].stats.sampling_rate:<EOL><INDENT>raise IndexError('<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>warnings.warn('<STR_LIT>')<EOL>chan[<NUM_LIT:0>].data = chan[<NUM_LIT:0>].data[<NUM_LIT:0>:min_length]<EOL><DEDENT>if '<STR_LIT>' not in locals():<EOL><INDENT>chan_mat = chan[<NUM_LIT:0>].data<EOL><DEDENT>else:<EOL><INDENT>chan_mat = np.vstack((chan_mat, chan[<NUM_LIT:0>].data))<EOL><DEDENT><DEDENT><DEDENT>if not len(chan_mat.shape) > <NUM_LIT:1>:<EOL><INDENT>warnings.warn('<STR_LIT>'<EOL>% '<STR_LIT:.>'.join(list(stachan)))<EOL>continue<EOL><DEDENT>chan_mat = np.asarray(chan_mat)<EOL>u, s, v = np.linalg.svd(chan_mat.T, full_matrices=full)<EOL>svalues.append(s)<EOL>svectors.append(v)<EOL>uvectors.append(u)<EOL>del (chan_mat)<EOL><DEDENT>return uvectors, svalues, svectors, stachans<EOL>
Compute the SVD of a number of templates.

Returns the singular vectors and singular values of the templates.

:type stream_list: List of :class: obspy.Stream
:param stream_list: List of the templates to be analysed
:type full: bool
:param full: Whether to compute the full input vector matrix or not.

:return: SValues(list) for each channel, SVectors(list of ndarray),  \
    UVectors(list of ndarray) for each channel, \
    stachans, List of String (station.channel)

.. note:: We recommend that you align the data before computing the \
    SVD, e.g., the P-arrival on all templates for the same channel \
    should appear at the same time in the trace.  See the \
    stacking.align_traces function for a way to do this.

.. note:: Uses the numpy.linalg.svd function, their U, s and V are mapped \
    to UVectors, SValues and SVectors respectively.  Their V (and ours) \
    corresponds to V.H.