Beispiel #1
0
def plot_spectral_estimate(f, sdf, sdf_ests, limits=None, elabels=()):
    """
    Plot an estimate of a spectral transform against the ground truth.

    Utility file used in building the documentation
    """
    fig = plt.figure()
    ax = fig.add_subplot(1, 1, 1)
    ax_limits = (sdf.min() - 2*np.abs(sdf.min()),
                 sdf.max() + 1.25*np.abs(sdf.max()))
    ax.plot(f, sdf, 'c', label='True S(f)')

    if not elabels:
        elabels = ('',) * len(sdf_ests)
    colors = 'bgkmy'
    for e, l, c in zip(sdf_ests, elabels, colors):
        ax.plot(f, e, color=c, linewidth=2, label=l)

    if limits is not None:
        ax.fill_between(f, limits[0], y2=limits[1], color=(1, 0, 0, .3),
                        alpha=0.5)

    ax.set_ylim(ax_limits)
    ax.legend()
    return fig
Beispiel #2
0
def plot_spectral_estimate(f, sdf, sdf_ests, limits=None, elabels=()):
    """
    Plot an estimate of a spectral transform against the ground truth.

    Utility file used in building the documentation
    """
    fig = plt.figure()
    ax = fig.add_subplot(1, 1, 1)
    ax_limits = (sdf.min() - 2 * np.abs(sdf.min()),
                 sdf.max() + 1.25 * np.abs(sdf.max()))
    ax.plot(f, sdf, 'c', label='True S(f)')

    if not elabels:
        elabels = ('', ) * len(sdf_ests)
    colors = 'bgkmy'
    for e, l, c in zip(sdf_ests, elabels, colors):
        ax.plot(f, e, color=c, linewidth=2, label=l)

    if limits is not None:
        ax.fill_between(f,
                        limits[0],
                        y2=limits[1],
                        color=(1, 0, 0, .3),
                        alpha=0.5)

    ax.set_ylim(ax_limits)
    ax.legend()
    return fig
pl.legend(loc = 'best')
pl.text(75,-0.053,r'Total $\delta F( \omega_0 = 4.2) = %.2f$' % sum_dF_042, color='b')
pl.text(75,-0.056,r'Total $\delta F( \omega_0 = 6.2) = %.2f$' % sum_dF_062, color='g')
pl.text(75,-0.059,r'Total $\delta F( \omega_0 = 8.2) = %.2f$' % sum_dF_082, color='r')
pl.text(75,-0.062,r'Total $\delta F(\omega_0 = 10.2) = %.2f$' % sum_dF_102, color='c')
pl.text(75,-0.065,r'Total $\delta F(\omega_0 = 13.2) = %.2f$' % sum_dF_132, color='m')
pl.text(75,-0.068,r'Total $\delta F(\omega_0 = 18.2) = %.2f$' % sum_dF_182, color='y')

pp.savefig()
pl.show()

fig = pl.figure()
ax = fig.add_axes([0.1,0.1,0.8,0.8])
ax.plot(x_peak,  y_peak,   color = 'g',label = r'Synthesized')# $\epsilon$"($\omega$)', linestyle='-')
ax.plot(x_nopeak,y_nopeak, color = 'b',label = r'Ab initio')# $\epsilon$"($\omega$)',   linestyle='-')
ax.legend(loc = 'best')
#pl.title(r'$\epsilon$"($\omega$)  Ab Initio and Synthisized')
pl.xlabel(r'$\omega$', size = 'x-large')
pl.ylabel(r'$\epsilon$"($\omega$)', size = 'x-large')

ax_inset = fig.add_axes([0.55,0.42,0.3,0.3])
ax_inset.plot(x_nopeak,diff_eps,color='r',label=r'$\epsilon$"($\omega)_{synthesized}$-$\epsilon$"($\omega)_{ab\,initio}$')
#ax_inset.plot(x_nopeak*1e-16,diff_eps,color='r',label=r'$\epsilon$"($\omega)_{synthesized}$-$\epsilon$"($\omega)_{ab\,initio}$')
#ax_inset.plot(x_nopeak*1e-16,listofzeros,color = 'k', label=r'$\delta$$\epsilon$"($\omega$) = 0')
ax_inset.plot(x_nopeak,listofzeros,color = 'k', label=r'$\delta$$\epsilon$"($\omega$) = 0')
#pl.title(r'Difference $\epsilon$"($\omega$)', size = 'small')
pl.tick_params(labelsize = 'small')
pl.xlabel(r'$\omega$', size = 'small')
pl.ylabel(r'$\delta$$\epsilon$"($\omega$)', size = 'small')
pp.savefig()
pl.show()
diff_F = -F_3 + F_3_p
divide = dF / diff_F

## calc difference eps2 and eiz for with and without peak
# -----------------------------------------------------------
diff_eps = y_peak - y_nopeak
diff_eiz = eiz_peak - eiz_nopeak
listofzeros = numpy.zeros(len(x_nopeak))  # plot line for y = 0

## PLOTS
# -------------------------------------------------------------
fig = pl.figure()
ax = fig.add_axes([0.1, 0.1, 0.8, 0.8])
ax.plot(x_peak, y_peak, color="g", label=r"Synthesized")  # $\epsilon$"($\omega$)', linestyle='-')
ax.plot(x_nopeak, y_nopeak, color="b", label=r"Ab initio")  # $\epsilon$"($\omega$)',   linestyle='-')
ax.legend(loc="best")
# pl.title(r'$\epsilon$"($\omega$)  Ab Initio and Synthisized')
pl.xlabel(r"$\omega$", size="large")
pl.ylabel(r'$\epsilon$"($\omega$)')

ax_inset = fig.add_axes([0.55, 0.42, 0.3, 0.3])
ax_inset.plot(
    x_nopeak * 1e-16,
    diff_eps,
    color="r",
    label=r'$\epsilon$"($\omega)_{synthesized}$-$\epsilon$"($\omega)_{ab\,initio}$',
)
ax_inset.plot(x_nopeak * 1e-16, listofzeros, color="k", label=r'$\delta$$\epsilon$"($\omega$) = 0')
# pl.title(r'Difference $\epsilon$"($\omega$)', size = 'small')
pl.tick_params(labelsize="small")
pl.xlabel(r"$\omega$", size="small")