def PWS_stack(streams, weight=<NUM_LIT:2>, normalize=True):
<EOL>Linstack = linstack(streams)<EOL>instaphases = []<EOL>print("<STR_LIT>")<EOL>for stream in streams:<EOL><INDENT>instaphase = stream.copy()<EOL>for tr in instaphase:<EOL><INDENT>analytic = hilbert(tr.data)<EOL>envelope = np.sqrt(np.sum((np.square(analytic),<EOL>np.square(tr.data)), axis=<NUM_LIT:0>))<EOL>tr.data = analytic / envelope<EOL><DEDENT>instaphases.append(instaphase)<EOL><DEDENT>print("<STR_LIT>")<EOL>Phasestack = linstack(instaphases, normalize=normalize)<EOL>for tr in Phasestack:<EOL><INDENT>tr.data = Linstack.select(station=tr.stats.station)[<NUM_LIT:0>].data *np.abs(tr.data ** weight)<EOL><DEDENT>return Phasestack<EOL>
Compute the phase weighted stack of a series of streams.

.. note:: It is recommended to align the traces before stacking.

:type streams: list
:param streams: List of :class:`obspy.core.stream.Stream` to stack.
:type weight: float
:param weight: Exponent to the phase stack used for weighting.
:type normalize: bool
:param normalize: Normalize traces before stacking.

:return: Stacked stream.
:rtype: :class:`obspy.core.stream.Stream`