def line_spectra(fk,Xk,mode,sides=<NUM_LIT:2>,linetype='<STR_LIT:b>',lwidth=<NUM_LIT:2>,floor_dB=-<NUM_LIT:100>,fsize=(<NUM_LIT:6>,<NUM_LIT:4>)):
plt.figure(figsize=fsize)<EOL>idx = np.nonzero(Xk)[<NUM_LIT:0>]<EOL>Xk = Xk[idx]<EOL>fk = fk[idx]<EOL>if mode == '<STR_LIT>':<EOL><INDENT>for k in range(len(fk)):<EOL><INDENT>if fk[k] == <NUM_LIT:0> and sides == <NUM_LIT:2>:<EOL><INDENT>plt.plot([fk[k], fk[k]],[<NUM_LIT:0>, np.abs(Xk[k])],linetype, linewidth=lwidth)<EOL><DEDENT>elif fk[k] == <NUM_LIT:0> and sides == <NUM_LIT:1>:<EOL><INDENT>plt.plot([fk[k], fk[k]],[<NUM_LIT:0>, np.abs(Xk[k])],linetype, linewidth=<NUM_LIT:2>*lwidth)            <EOL><DEDENT>elif fk[k] > <NUM_LIT:0> and sides == <NUM_LIT:2>:<EOL><INDENT>plt.plot([fk[k], fk[k]],[<NUM_LIT:0>, np.abs(Xk[k])],linetype, linewidth=lwidth)<EOL>plt.plot([-fk[k], -fk[k]],[<NUM_LIT:0>, np.abs(Xk[k])],linetype, linewidth=lwidth)<EOL><DEDENT>elif fk[k] > <NUM_LIT:0> and sides == <NUM_LIT:1>:<EOL><INDENT>plt.plot([fk[k], fk[k]],[<NUM_LIT:0>, <NUM_LIT>*np.abs(Xk[k])],linetype, linewidth=lwidth)<EOL><DEDENT>else:<EOL><INDENT>print('<STR_LIT>')<EOL><DEDENT><DEDENT>plt.grid()<EOL>if sides == <NUM_LIT:2>:<EOL><INDENT>plt.axis([-<NUM_LIT>*max(fk), <NUM_LIT>*max(fk), <NUM_LIT:0>, <NUM_LIT>*max(abs(Xk))])        <EOL><DEDENT>elif sides == <NUM_LIT:1>:<EOL><INDENT>plt.axis([<NUM_LIT:0>, <NUM_LIT>*max(fk), <NUM_LIT:0>, <NUM_LIT>*<NUM_LIT:2>*max(abs(Xk))])<EOL><DEDENT>else:<EOL><INDENT>print('<STR_LIT>')<EOL><DEDENT>plt.ylabel('<STR_LIT>')<EOL>plt.xlabel('<STR_LIT>')<EOL><DEDENT>elif mode == '<STR_LIT>':<EOL><INDENT>Xk_dB = <NUM_LIT:20>*np.log10(np.abs(Xk))<EOL>for k in range(len(fk)):<EOL><INDENT>if fk[k] == <NUM_LIT:0> and sides == <NUM_LIT:2>:<EOL><INDENT>plt.plot([fk[k], fk[k]],[floor_dB, Xk_dB[k]],linetype, linewidth=lwidth)<EOL><DEDENT>elif fk[k] == <NUM_LIT:0> and sides == <NUM_LIT:1>:<EOL><INDENT>plt.plot([fk[k], fk[k]],[floor_dB, Xk_dB[k]],linetype, linewidth=<NUM_LIT:2>*lwidth)            <EOL><DEDENT>elif fk[k] > <NUM_LIT:0> and sides == <NUM_LIT:2>:<EOL><INDENT>plt.plot([fk[k], fk[k]],[floor_dB, Xk_dB[k]],linetype, linewidth=lwidth)<EOL>plt.plot([-fk[k], -fk[k]],[floor_dB, Xk_dB[k]],linetype, linewidth=lwidth)<EOL><DEDENT>elif fk[k] > <NUM_LIT:0> and sides == <NUM_LIT:1>:<EOL><INDENT>plt.plot([fk[k], fk[k]],[floor_dB, Xk_dB[k]+<NUM_LIT>],linetype, linewidth=lwidth)<EOL><DEDENT>else:<EOL><INDENT>print('<STR_LIT>')<EOL><DEDENT><DEDENT>plt.grid()<EOL>max_dB = np.ceil(max(Xk_dB/<NUM_LIT>))*<NUM_LIT:10><EOL>min_dB = max(floor_dB,np.floor(min(Xk_dB/<NUM_LIT>))*<NUM_LIT:10>)<EOL>if sides == <NUM_LIT:2>:<EOL><INDENT>plt.axis([-<NUM_LIT>*max(fk), <NUM_LIT>*max(fk), min_dB, max_dB])        <EOL><DEDENT>elif sides == <NUM_LIT:1>:<EOL><INDENT>plt.axis([<NUM_LIT:0>, <NUM_LIT>*max(fk), min_dB, max_dB])<EOL><DEDENT>else:<EOL><INDENT>print('<STR_LIT>')<EOL><DEDENT>plt.ylabel('<STR_LIT>')<EOL>plt.xlabel('<STR_LIT>')<EOL><DEDENT>elif mode == '<STR_LIT>':<EOL><INDENT>Xk_dB = <NUM_LIT:20>*np.log10(np.abs(Xk)/max(np.abs(Xk)))<EOL>for k in range(len(fk)):<EOL><INDENT>if fk[k] == <NUM_LIT:0> and sides == <NUM_LIT:2>:<EOL><INDENT>plt.plot([fk[k], fk[k]],[floor_dB, Xk_dB[k]],linetype, linewidth=lwidth)<EOL><DEDENT>elif fk[k] == <NUM_LIT:0> and sides == <NUM_LIT:1>:<EOL><INDENT>plt.plot([fk[k], fk[k]],[floor_dB, Xk_dB[k]],linetype, linewidth=<NUM_LIT:2>*lwidth)            <EOL><DEDENT>elif fk[k] > <NUM_LIT:0> and sides == <NUM_LIT:2>:<EOL><INDENT>plt.plot([fk[k], fk[k]],[floor_dB, Xk_dB[k]],linetype, linewidth=lwidth)<EOL>plt.plot([-fk[k], -fk[k]],[floor_dB, Xk_dB[k]],linetype, linewidth=lwidth)<EOL><DEDENT>elif fk[k] > <NUM_LIT:0> and sides == <NUM_LIT:1>:<EOL><INDENT>plt.plot([fk[k], fk[k]],[floor_dB, Xk_dB[k]+<NUM_LIT>],linetype, linewidth=lwidth)<EOL><DEDENT>else:<EOL><INDENT>print('<STR_LIT>')<EOL><DEDENT><DEDENT>plt.grid()<EOL>max_dB = np.ceil(max(Xk_dB/<NUM_LIT>))*<NUM_LIT:10><EOL>min_dB = max(floor_dB,np.floor(min(Xk_dB/<NUM_LIT>))*<NUM_LIT:10>)<EOL>if sides == <NUM_LIT:2>:<EOL><INDENT>plt.axis([-<NUM_LIT>*max(fk), <NUM_LIT>*max(fk), min_dB, max_dB])        <EOL><DEDENT>elif sides == <NUM_LIT:1>:<EOL><INDENT>plt.axis([<NUM_LIT:0>, <NUM_LIT>*max(fk), min_dB, max_dB])<EOL><DEDENT>else:<EOL><INDENT>print('<STR_LIT>')<EOL><DEDENT>plt.ylabel('<STR_LIT>')<EOL>plt.xlabel('<STR_LIT>')    <EOL><DEDENT>elif mode == '<STR_LIT>':<EOL><INDENT>for k in range(len(fk)):<EOL><INDENT>if fk[k] == <NUM_LIT:0> and sides == <NUM_LIT:2>:<EOL><INDENT>plt.plot([fk[k], fk[k]],[<NUM_LIT:0>, np.angle(Xk[k])],linetype, linewidth=lwidth)<EOL><DEDENT>elif fk[k] == <NUM_LIT:0> and sides == <NUM_LIT:1>:<EOL><INDENT>plt.plot([fk[k], fk[k]],[<NUM_LIT:0>, np.angle(Xk[k])],linetype, linewidth=<NUM_LIT:2>*lwidth)<EOL><DEDENT>elif fk[k] > <NUM_LIT:0> and sides == <NUM_LIT:2>:<EOL><INDENT>plt.plot([fk[k], fk[k]],[<NUM_LIT:0>, np.angle(Xk[k])],linetype, linewidth=lwidth)<EOL>plt.plot([-fk[k], -fk[k]],[<NUM_LIT:0>, -np.angle(Xk[k])],linetype, linewidth=lwidth)<EOL><DEDENT>elif fk[k] > <NUM_LIT:0> and sides == <NUM_LIT:1>:<EOL><INDENT>plt.plot([fk[k], fk[k]],[<NUM_LIT:0>, np.angle(Xk[k])],linetype, linewidth=lwidth)<EOL><DEDENT>else:<EOL><INDENT>print('<STR_LIT>')<EOL><DEDENT><DEDENT>plt.grid()<EOL>if sides == <NUM_LIT:2>:<EOL><INDENT>plt.plot([-<NUM_LIT>*max(fk), <NUM_LIT>*max(fk)], [<NUM_LIT:0>, <NUM_LIT:0>],'<STR_LIT:k>')<EOL>plt.axis([-<NUM_LIT>*max(fk), <NUM_LIT>*max(fk), -<NUM_LIT>*max(np.abs(np.angle(Xk))), <NUM_LIT>*max(np.abs(np.angle(Xk)))])<EOL><DEDENT>elif sides == <NUM_LIT:1>:<EOL><INDENT>plt.plot([<NUM_LIT:0>, <NUM_LIT>*max(fk)], [<NUM_LIT:0>, <NUM_LIT:0>],'<STR_LIT:k>')<EOL>plt.axis([<NUM_LIT:0>, <NUM_LIT>*max(fk), -<NUM_LIT>*max(np.abs(np.angle(Xk))), <NUM_LIT>*max(np.abs(np.angle(Xk)))])<EOL><DEDENT>else:<EOL><INDENT>print('<STR_LIT>')<EOL><DEDENT>plt.ylabel('<STR_LIT>')<EOL>plt.xlabel('<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>print('<STR_LIT>')<EOL><DEDENT>
Plot the Fouier series line spectral given the coefficients.

This function plots two-sided and one-sided line spectra of a periodic
signal given the complex exponential Fourier series coefficients and
the corresponding harmonic frequencies.

Parameters
----------
fk : vector of real sinusoid frequencies
Xk : magnitude and phase at each positive frequency in fk
mode : 'mag' => magnitude plot, 'magdB' => magnitude in dB plot,
mode cont : 'magdBn' => magnitude in dB normalized, 'phase' => a phase plot in radians 
sides : 2; 2-sided or 1-sided
linetype : line type per Matplotlib definitions, e.g., 'b';
lwidth : 2; linewidth in points
fsize : optional figure size in inches, default = (6,4) inches 

Returns
-------
Nothing : A plot window opens containing the line spectrum plot

Notes
-----
Since real signals are assumed the frequencies of fk are 0 and/or positive
numbers. The supplied Fourier coefficients correspond.

Examples
--------
>>> import matplotlib.pyplot as plt
>>> import numpy as np
>>> from sk_dsp_comm.sigsys import line_spectra
>>> n = np.arange(0,25)
>>> # a pulse train with 10 Hz fundamental and 20% duty cycle
>>> fk = n*10
>>> Xk = np.sinc(n*10*.02)*np.exp(-1j*2*np.pi*n*10*.01) # 1j = sqrt(-1)

>>> line_spectra(fk,Xk,'mag')
>>> plt.show()

>>> line_spectra(fk,Xk,'phase')