Exemple #1
0
 def finalize(self):
     subplot = plt.subplot(self.options.rows, self.options.columns,
                           self.subnumber)
     plt.legend()
     if self.title != None:
         plt.title(self.title, fontsize=self.title_fontsize)
         pass
     subplot.set_xlabel(self.xlabel, fontsize=self.xlabel_fontsize)
     subplot.set_ylabel(self.ylabel, fontsize=self.ylabel_fontsize)
     for tick in subplot.xaxis.get_major_ticks():
         tick.label.set_fontsize(self.xaxis_fontsize)
         pass
     for tick in subplot.yaxis.get_major_ticks():
         tick.label.set_fontsize(self.yaxis_fontsize)
         pass
     try:
         for tick in subplot.zaxis.get_major_ticks():
             tick.label.set_fontsize(self.zaxis_fontsize)
             pass
         pass
     except AttributeError:
         pass
     subplot.xaxis.set_major_formatter(FormatStrFormatter(
         self.xaxis_format))
     subplot.yaxis.set_major_formatter(FormatStrFormatter(
         self.yaxis_format))
     try:
         subplot.zaxis.set_major_formatter(
             FormatStrFormatter(self.zaxis_format))
         pass
     except AttributeError:
         pass
     plt.xticks(
         np.linspace(float(self.xticks_min),
                     float(self.xticks_max),
                     num=int(self.xticks)))
     plt.yticks(
         np.linspace(float(self.yticks_min),
                     float(self.yticks_max),
                     num=int(self.yticks)))
     try:
         plt.linspace(
             np.arange(float(self.zticks_min),
                       float(self.zticks_max),
                       num=int(self.zticks)))
         pass
     except AttributeError:
         pass
     subplot.set_xlim([float(self.xmin), float(self.xmax)])
     subplot.set_ylim([float(self.ymin), float(self.ymax)])
     try:
         subplot.set_zlabel(self.zlabel, fontsize=self.zlabel_fontsize)
         pass
     except AttributeError:
         pass
     pass
Exemple #2
0
def demo():
    """
    Show the available interface functions and the corresponding probability
    density functions.
    """

    # Plot the cdf and pdf
    import matplotlib.pyplot as plt
    w = 10
    perf = Erf(w)
    ptanh = Tanh(w)
    plinear = Linear(2.35 * w)

    #arrowprops=dict(arrowstyle='wedge', connectionstyle='arc3', fc='0.6')
    #bbox=dict(boxstyle='round', fc='0.8')

    z = plt.linspace(-3 * w, 3 * w, 800)
    plt.subplot(211)
    plt.plot(z, perf.cdf(z))
    plt.plot(z, ptanh.cdf(z))
    plt.plot(z, plinear.cdf(z))
    plt.axvline(w, linewidth=2)
    plt.annotate('1-sigma', xy=(w * 1.1, 0.2))
    plt.legend(['erf', 'tanh'])
    plt.grid(True)
    plt.subplot(212)
    plt.plot(z, perf.pdf(z))
    plt.plot(z, ptanh.pdf(z))
    plt.plot(z, plinear.pdf(z))
    plt.axvline(w, linewidth=2)
    plt.annotate('1-sigma', xy=(w * 1.1, 0.2))
    plt.legend(['erf', 'tanh', 'linear'])
    plt.grid(True)
Exemple #3
0
def test_pp():
    coef = np.array([[1, 1], [0, 0]]) # linear from 0 to 2 @UnusedVariable

    coef = np.array([[1, 1], [1, 1], [0, 2]]) # quadratic from 0 to 1 and 1 to 2.
    dc = pl.polyder(coef, 1)
    c2 = pl.polyint(dc, 1) #@UnusedVariable
    breaks = [0, 1, 2]
    pp = PPform(coef, breaks)
    pp(0.5)
    pp(1)
    pp(1.5)
    dpp = pp.derivative()
    import pylab as plb
    x = plb.linspace(-1, 3)
    plb.plot(x, pp(x), x, dpp(x), '.')
    plb.show()
def test_pp():
    coef = np.array([[1, 1], [0, 0]])  # linear from 0 to 2 @UnusedVariable

    # quadratic from 0 to 1 and 1 to 2.
    coef = np.array([[1, 1], [1, 1], [0, 2]])
    dc = pl.polyder(coef, 1)
    c2 = pl.polyint(dc, 1)  # @UnusedVariable
    breaks = [0, 1, 2]
    pp = PPform(coef, breaks)
    pp(0.5)
    pp(1)
    pp(1.5)
    dpp = pp.derivative()
    import pylab as plb
    x = plb.linspace(-1, 3)
    plb.plot(x, pp(x), x, dpp(x), '.')
    plb.show()
Exemple #5
0
def demo_tanh_to_erf():
    """
    Show the available interface functions and the corresponding probability
    density functions.
    """

    # Plot the cdf and pdf
    import matplotlib.pyplot as plt
    w = 10
    ws = w * Tanh.C / Tanh.Cfwhm
    ptanh = Tanh.as_fwhm(w)
    perf = Erf(ws)

    z = plt.linspace(-2 * w, 2 * w, 800)
    plt.subplot(211)
    plt.plot(z, perf.cdf(z))
    plt.plot(z, ptanh.cdf(z))
    plt.title("""FWHM tanh -> 1-sigma erf
scale by atanh(erf(1/sqrt(2))) / (2 acosh(sqrt(2)))""")
    plt.legend(['erf', 'tanh'])
    plt.grid(True)
    plt.subplot(212)
    plt.plot(z, perf.pdf(z), 'b')
    plt.plot(z, ptanh.pdf(z), 'g')
    plt.legend(['erf', 'tanh'])

    # Show fwhm
    arrowprops = dict(arrowstyle='wedge', connectionstyle='arc3', fc='0.6')
    bbox = dict(boxstyle='round', fc='0.8')
    plt.annotate('erf 1-sigma',
                 xy=(ws, perf.pdf(ws)),
                 xytext=(-2, 20),
                 textcoords="offset points",
                 arrowprops=arrowprops,
                 bbox=bbox)
    plt.annotate('tanh FWHM',
                 xy=(w / 2, ptanh.pdf(0) / 2),
                 xytext=(-58, -35),
                 textcoords="offset points",
                 arrowprops=arrowprops,
                 bbox=bbox)

    plt.grid(True)
Exemple #6
0
def demo_fwhm():
    """
    Show the available interface functions and the corresponding probability
    density functions.
    """

    # Plot the cdf and pdf
    import matplotlib.pyplot as plt
    w = 10
    perf = Erf.as_fwhm(w)
    ptanh = Tanh.as_fwhm(w)

    z = plt.linspace(-w, w, 800)
    plt.subplot(211)
    plt.plot(z, perf.cdf(z))
    plt.plot(z, ptanh.cdf(z))
    plt.legend(['erf', 'tanh'])
    plt.grid(True)
    plt.subplot(212)
    plt.plot(z, perf.pdf(z), 'b')
    plt.plot(z, ptanh.pdf(z), 'g')
    plt.legend(['erf', 'tanh'])

    # Show fwhm
    arrowprops = dict(arrowstyle='wedge', connectionstyle='arc3', fc='0.6')
    bbox = dict(boxstyle='round', fc='0.8')
    plt.annotate('erf FWHM',
                 xy=(w / 2, perf.pdf(0) / 2),
                 xytext=(-35, 10),
                 textcoords="offset points",
                 arrowprops=arrowprops,
                 bbox=bbox)
    plt.annotate('tanh FWHM',
                 xy=(w / 2, ptanh.pdf(0) / 2),
                 xytext=(-35, -35),
                 textcoords="offset points",
                 arrowprops=arrowprops,
                 bbox=bbox)

    plt.grid(True)
def histogram(y,bins=50,plot=True,label=None):
    N,bins=numpyhist(y,bins)
    
    dx=bins[1]-bins[0]
    if dx==0.0:  #  all in 1 bin!
        val=bins[0]
        bins=plt.linspace(val-abs(val),val+abs(val),50)
        N,bins=numpyhist(y,bins)
    
    dx=bins[1]-bins[0]
    x=bins[0:-1]+(bins[1]-bins[0])/2.0
    
    y=N*1.0/sum(N)/dx
    
    if plot:
        plt.plot(x,y,'o-',label=label)
        yl=plt.gca().get_ylim()
        plt.gca().set_ylim([0,yl[1]])
        xl=plt.gca().get_xlim()
        if xl[0]<=0 and xl[0]>=0:    
            plt.plot([0,0],[0,yl[1]],'k--')

    return x,y
Exemple #8
0
sigma_2 = 14
delta_2 = sigma_2
runtime_jacobi = []
runtime_arma = []
n = []
eigenval_arma = []
eigenval_jacobi = []
for f in x:
    f = runtimes(f)
    n.append(comprehend(comprehend(boltzmanns_constant(f[0][2:]))))
    fonttype = "Armadillo"
    runtime_arma.append(deappend(comprehend(boltzmanns_constant(f[1][13:]))))
    runtime_jacobi.append(deappend(comprehend(boltzmanns_constant(f[2][15:]))))
    eigenval_arma.append(deappend(comprehend(boltzmanns_constant(f[3][14:]))))
    eigenval_jacobi.append(deappend(comprehend(boltzmanns_constant(
        f[4][16:]))))
fontttype = "Jacobi"
x.close()
n = scipy_constants(n)
runtime_arma = scipy_constants(runtime_arma)
runtime_jacobi = scipy_constants(runtime_jacobi)
eigenval_arma = scipy_constants(eigenval_arma)
eigenval_jacobi = scipy_constants(eigenval_jacobi)

linspace(n, return_(runtime_arma), label=fonttype)
linspace(n, return_(runtime_jacobi), label=fontttype)
compress(sigma_1, Fontsize=sigma_2)
commpress(delta_1, Fontsize=delta_2)
hamiltonian()
arma(out)