#NEWLINE# def plotSpectrum( X , fin , fmt = '-' , **xargs ) : #NEWLINE# #INDENT# "Plot a smoothed spectrum on a LOG x-axis.\n\n    **Parameters:**\n\n    X : 1D ndarray\n        The FFT to be smoothed and plotted, *dual sided*.\n\n    fin : int\n        The bin corresponding to the input sine wave.\n\n    fmt : string, optional\n        Formatting to be passed to matplotlib's ``semilogx()``.\n\n    **xargs : dict, optional\n        Extra arguments to be passed to matplotlib's ``semilogx()``.\n\n    Plotting is performed on the current figure.\n\n    .. seealso::\n\n         * :func:`logsmooth` for more information on the smoothing algorithm\n\n         * :func:`circ_smooth` for a smoothing algorithm suitable for linear x-axes.\n\n    .. plot::\n\n        import numpy as np\n        from deltasigma import *\n        from numpy.fft import fft\n        f0 = 0\n        osr = 32\n        quadrature = False\n        Hinf = 1.5\n        order = 3\n        ntf = synthesizeNTF(order, osr, 0, Hinf, f0)\n        f1, f2 = ds_f1f2(osr, f0, quadrature)\n        delta = 2\n        Amp = undbv(-3)\n        f = 0.3\n        N = 2**12\n        f1_bin = np.round(f1*N)\n        f2_bin = np.round(f2*N)\n        fin = np.round(((1 - f)/2*f1 + (f + 1)/2*f2) * N)\n        t = np.arange(0, N)\n        u = Amp*np.cos((2*np.pi/N)*fin*t)\n        v, xn, xmax, y = simulateDSM(u, ntf, 2)\n        window = ds_hann(N)\n        NBW = 1.5/N\n        spec0 = fft(v * window)/(N/4)\n        freq = np.linspace(0, 0.5, N/2 + 1)\n        plt.plot(freq, dbv(spec0[:N/2 + 1]), 'c', linewidth=1, label='$S$')\n        plt.hold(True)\n        plotSpectrum(spec0, fin, 'b', linewidth=2.5, label='$\\\\mathrm{plotSpectrum}(S)$')\n        Snn = np.abs(evalTF(ntf, np.exp(2j*np.pi*freq)))**2 * 2/12*(delta)**2\n        plt.plot(freq, dbp(Snn*NBW), 'm', linewidth=1.5, label='$\\\\mathrm{from\\\\ NTF}$')\n        snr = calculateSNR(spec0[f1_bin:f2_bin + 1], fin - f1_bin)\n        msg = 'SQNR  =  %.1fdB\\n @ A = %.1fdBFS & osr = %.0f\\n' % \\\n              (snr, dbv(spec0[fin]), osr)\n        plt.text(f0 + .45/osr, -20, msg, horizontalalignment='left',\n                 verticalalignment='center')\n        plt.text(0.5, -3, 'NBW = %.1e ' % NBW, horizontalalignment='right',\n                 verticalalignment='top')\n        figureMagic((1e-3, 0.5), None, None, (-140, 0), 20, None)\n        plt.ylabel('Spectrum [dB]')\n        ax = plt.gca()\n        ax.set_title('Third order modulator')\n        plt.xlabel('Normalized frequency ($f_s \\\\rightarrow 1$)')\n        plt.legend(loc=4)\n\n    " #NEWLINE# ( f , p ) = logsmooth ( X , fin ) #NEWLINE# plt . semilogx ( f , p , fmt , ** xargs )