def seis_sim(sp, amp_ratio=<NUM_LIT>, flength=False, phaseout='<STR_LIT:all>'):
if flength and <NUM_LIT> * sp < flength and <NUM_LIT:100> < flength:<EOL><INDENT>additional_length = flength<EOL><DEDENT>elif <NUM_LIT> * sp < <NUM_LIT>:<EOL><INDENT>additional_length = <NUM_LIT:100><EOL><DEDENT>else:<EOL><INDENT>additional_length = <NUM_LIT> * sp<EOL><DEDENT>synth = np.zeros(int(sp + <NUM_LIT:10> + additional_length))<EOL>synth[<NUM_LIT:10>] = <NUM_LIT:1.0>  <EOL>S_length = <NUM_LIT:10> + int(sp // <NUM_LIT:3>)<EOL>S_spikes = np.arange(amp_ratio, <NUM_LIT:0>, -(amp_ratio / S_length))<EOL>for i in range(len(S_spikes)):<EOL><INDENT>if i in np.arange(<NUM_LIT:1>, len(S_spikes), <NUM_LIT:2>):<EOL><INDENT>S_spikes[i] = <NUM_LIT:0><EOL><DEDENT>if i in np.arange(<NUM_LIT:2>, len(S_spikes), <NUM_LIT:4>):<EOL><INDENT>S_spikes[i] *= -<NUM_LIT:1><EOL><DEDENT><DEDENT>synth[<NUM_LIT:10> + sp:<NUM_LIT:10> + sp + len(S_spikes)] = S_spikes<EOL>sine_x = np.arange(<NUM_LIT:0>, <NUM_LIT>, <NUM_LIT:0.5>)<EOL>damped_sine = np.exp(-sine_x) * np.sin(<NUM_LIT:2> * np.pi * sine_x)<EOL>synth = np.convolve(synth, damped_sine)<EOL>synth = synth / np.max(np.abs(synth))<EOL>if not flength:<EOL><INDENT>return synth<EOL><DEDENT>else:<EOL><INDENT>if phaseout in ['<STR_LIT:all>', '<STR_LIT:P>']:<EOL><INDENT>synth = synth[<NUM_LIT:0>:flength]<EOL><DEDENT>elif phaseout == '<STR_LIT:S>':<EOL><INDENT>synth = synth[sp:]<EOL>if len(synth) < flength:<EOL><INDENT>synth = np.append(synth, np.zeros(flength - len(synth)))<EOL><DEDENT>else:<EOL><INDENT>synth = synth[<NUM_LIT:0>:flength]<EOL><DEDENT><DEDENT>return synth<EOL><DEDENT>
Generate a simulated seismogram from a given S-P time.

Will generate spikes separated by a given S-P time, which are then
convolved with a decaying sine function.  The P-phase is simulated by a
positive spike of value 1, the S-arrival is simulated by a decaying
boxcar of maximum amplitude 1.5.  These amplitude ratios can be altered by
changing the amp_ratio, which is the ratio S amplitude:P amplitude.

.. note::
    In testing this can achieve 0.3 or greater cross-correlations with
    data.

:type sp: int
:param sp: S-P time in samples
:type amp_ratio: float
:param amp_ratio: S:P amplitude ratio
:type flength: int
:param flength: Fixed length in samples, defaults to False
:type phaseout: str
:param phaseout:
    Either 'P', 'S' or 'all', controls which phases to cut around, defaults
    to 'all'. Can only be used with 'P' or 'S' options if flength
    is set.

:returns: Simulated data.
:rtype: :class:`numpy.ndarray`