def fitAndPlotLinear(x, y, rngt, ax, alfa, showPlot, labelAlfa, p):
    markers=["o", "s","D","^","d","h","p","o"]
    labelRange = ['low', 'med', 'high']
    labelRange = labelRange+list([str(i) for i in rngt])
    cm = plt.get_cmap('Set1')
    cm1 = plt.get_cmap('Set3')
    slopes = []
    if showPlot:
        inf.smallerFont(ax, 8)
        ax.scatter(x, y, color=cm(abs(alfa/9)), alpha=0.75, edgecolors='none', marker=markers[alfa])#, "o", lw=0.5)
        arrow = dict(arrowstyle="-", connectionstyle="arc3", ls="--", color="gray")
        putLabels(ax, p.calc, alfa)
    for i in range(0,len(rngt)-1):
        a, b = fun.linearFit(x, y, rngt[i], rngt[i+1])
        slopes.append(b)
        if showPlot:
            ax.semilogy(x[rngt[i]:rngt[i+1]+1], np.exp(fun.linear(x[rngt[i]:rngt[i+1]+1], a, b)), ls="-", color=cm1((i+abs(alfa)*3)/12))
            xHalf = (x[rngt[i]]+x[rngt[i+1]]+1)/2
            text = "{:03.3f}".format(-b)
            yHalf = np.exp(fun.linear(xHalf, a, b))
            if alfa == -1:
                ax.text(xHalf, 2e1, r"$"+roman.toRoman(i+1)+r"$", color="gray", ha="right", va="center")#, transform=axarr[i].transAxes)
                xHalf *= 1.15
                yHalf *= 5
                text = r"$E_a="+text+r"$"

            bbox_props = dict(boxstyle="round", fc="w", ec="1", alpha=0.6)
            ax.text(xHalf,yHalf, text, color=cm(abs(alfa/9)), bbox=bbox_props, ha="center", va="center", size=6)
    if showPlot and alfa > -1:
        locator = LogLocator(100,[1e-1])
        ax.yaxis.set_major_locator(locator)
    return slopes
Exemple #2
0
def plotTotalTransitionRate(x,y, title):
    fig, ax = plt.subplots(1, 1, sharey=True, figsize=(5,4))
    fig.subplots_adjust(top=0.85, bottom=0.15, left=0.20, right=0.95, hspace=0.25, wspace=0.35)
    ax.plot(x,y,".-", label="data")
    [a,b] = fun.linearFit(x,y,0,len(x))
    ax.plot(x,fun.exp(x,a,b), label=r"$f(x) = "+str(a)+r"x^{"+str(b)+r"}$")
    ax.set_title(title)
    ax.set_xlabel(r"$1/k_BT$")
    ax.set_yscale("log")
    ax.legend(loc="best")
    fig.savefig(title+".svg")
    plt.close(fig)
def fitAndPlotLinear(x, y, rngt, axis, alfa, showPlot, labelAlfa):
    labelRange = ['low', 'med', 'high']
    labelRange = labelRange+list([str(i) for i in rngt])
    cm = plt.get_cmap('Set1')
    slopes = []
    if showPlot:   
        axis.scatter(x, y, color=cm(abs(alfa/9)), alpha=0.75, edgecolors='none')#, "o", lw=0.5)
    for i in range(0,len(rngt)-1):
        a, b = fun.linearFit(x, y, rngt[i], rngt[i+1])
        slopes.append(b)
        if showPlot:
            axis.semilogy(x[rngt[i]:rngt[i+1]+1], np.exp(fun.linear(x[rngt[i]:rngt[i+1]+1], a, b)), ls="-", label="{} {} {:03.3f} ".format(labelAlfa[alfa],labelRange[i],b))
            if i == len(rngt)-2:
                if alfa == -1:
                    axis.legend(prop={'size': 8}, bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.)
                else:
                    axis.legend(prop={'size': 5.1}, bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0., ncol=2)
    return slopes
Exemple #4
0
plot.plot2(x_volt_1,y_current_1, "Anodenspannung in $V$","Anodenstrom in $ A$","../plots/anode1.pdf", None)

for i in range(5):

    plt.axhline(m.saturation_current[i], linewidth=0.2, color='c')

plt.savefig('../plots/anode1.pdf')

plt.clf()
plt.clf()
#plot.plot([0,5,9,12,15,22],m.q_gone_korr, "Teilchennummer","Korrigierte Ladung $q / C$","../plots/ladung2.pdf", None)
plot.log_plot(x_volt_1,y_current_1, "Logarithmierte Anodenspannung $\ln(U)$","Logarithmierter Anodenstrom $\ln(\mu A)$","../plots/raum.pdf", None)

x_flow = np.linspace(1,3,1000)

plt.plot(x_flow, f.linearFit(x_flow, m.raumladung[0].nominal_value,m.raumladung[1].nominal_value), 'b-', label= "Linearer Fit")
plt.tight_layout(pad=0, h_pad=1.20, w_pad=1.20)
plt.legend(loc='best')
plt.savefig('../plots/raum.pdf')

plt.clf()
plt.clf()

plot.plot4(x_volt_langmuh,y_current_langmuh, "$\ln(U_A)$","$\ln(I_A)$","../plots/langmuh.pdf", None)

x_flow = np.linspace(1,3,1000)

plt.plot(x_flow, f.linearFit(x_flow, m.raumladung[0].nominal_value,m.raumladung[1].nominal_value), 'b-', label= "Linearer Fit")
plt.tight_layout(pad=0, h_pad=1.20, w_pad=1.20)
plt.legend(loc='best')
plt.savefig('../plots/langmuh.pdf')
Exemple #5
0
def plot(ax, ax2, data, i, alp=1):
    marker = ["o", "s", "H", "D", "^", "d", "h", "p", "o"]
    cm = plt.get_cmap("Accent")
    alpha = 0.5
    mew = 0
    data = np.array(data)
    try:
        flux = data[0, 0]
    except IndexError:
        raise
    factor = data[0, 6]

    x = 1 / kb / data[:, 1] + np.log(flux**factor)
    lw = 3
    lg1, = ax.plot(x,
                   data[:, 3],
                   label=r"$F=$" + fun.base10(flux),
                   lw=lw,
                   marker="",
                   ls="-",
                   mew=mew,
                   ms=12,
                   alpha=alpha,
                   color=cm(i / 8))
    ax.plot(x,
            data[:, 4],
            label=r"$N_h$" + fun.base10(flux),
            lw=lw + 1,
            ls="-.",
            mew=1,
            color=cm(i / 8),
            ms=7,
            alpha=1)
    ax2.plot(x,
             data[:, 3] / data[:, 4],
             label="aa",
             color=cm(i / 8),
             ls="",
             marker="o",
             ms=2,
             mec=cm(i / 8),
             mfc=cm(i / 8),
             alpha=alp)
    arrow = dict(arrowstyle="->",
                 connectionstyle="arc3",
                 ls="-",
                 color=cm(i / 8))
    if str(flux)[0] == "5":
        ax.annotate(fun.base10(flux),
                    xy=(x[2], data[:, 4][2]),
                    color=cm(i / 8),
                    xytext=(0.9, 0.52 - 0.05 * i),
                    textcoords="axes fraction",
                    arrowprops=arrow)
    if flux == 5e4:
        #Fit
        rngt = inf.defineRanges("AgUc", "simple", data[:, 1])
        for i in range(len(rngt) - 2, -1, -1):
            y = data[:, 4]
            a, b = fun.linearFit(x, y, rngt[i], rngt[i + 1])
            ax.semilogy(x[rngt[i]:rngt[i + 1] + 1],
                        np.exp(fun.linear(x[rngt[i]:rngt[i + 1] + 1], a, b)),
                        ls="-",
                        color="lightgray",
                        zorder=+200)
            xHalf = (x[rngt[i]] + x[rngt[i + 1]] + 1) / 2
            text = "{:03.3f}".format(-b)
            yHalf = np.exp(fun.linear(xHalf, a, b)) * 10
            text = r"$" + text + r"$"
            ax.text(xHalf,
                    yHalf,
                    text,
                    color="black",
                    ha="center",
                    va="center",
                    size=10,
                    zorder=+400)
        i = 0  # print "interpolation" to the rest of lower x values
        ax.semilogy(x[0:rngt[i + 1] + 1],
                    np.exp(fun.linear(x[0:rngt[i + 1] + 1], a, b)),
                    ls=":",
                    color="lightgray",
                    zorder=+300)
        #Fit f
        for i in range(len(rngt) - 2, -1, -1):
            y = data[:, 3] / data[:, 4]
            a, b = fun.linearFit(x, y, rngt[i], rngt[i + 1])
            ax2.plot(x[rngt[i]:rngt[i + 1] + 1],
                     np.exp(fun.linear(x[rngt[i]:rngt[i + 1] + 1], a, b)),
                     ls="-",
                     color="lightgray",
                     zorder=+200)
            xHalf = (x[rngt[i]] + x[rngt[i + 1]] + 1) / 2
            text = "{:03.3f}".format(-b)
            yHalf = np.exp(fun.linear(xHalf, a, b)) * 1.02
            text = r"$" + text + r"$"
            ax2.text(xHalf,
                     yHalf,
                     text,
                     color="gray",
                     ha="center",
                     va="center",
                     size=10,
                     zorder=+400)
        i = 0  # print "interpolation" to the rest of lower x values
        ax2.plot(x[0:rngt[i + 1] + 1],
                 np.exp(fun.linear(x[0:rngt[i + 1] + 1], a, b)),
                 ls=":",
                 color="lightgray",
                 zorder=+300)
    if flux == 3.5e0:
        rngt = inf.defineRanges("basic", "simple", data[:, 1])
        for i in range(len(rngt) - 2, -1, -1):  #reverse iteration
            y = data[:, 4]
            a, b = fun.linearFit(x, y, rngt[i], rngt[i + 1])
            ax.semilogy(x[rngt[i]:rngt[i + 1] + 1],
                        np.exp(fun.linear(x[rngt[i]:rngt[i + 1] + 1], a, b)),
                        ls="-",
                        color="lightgray",
                        zorder=+200)
            xHalf = (x[rngt[i]] + x[rngt[i + 1]] + 1) / 2
            text = "{:03.3f}".format(-b)
            yHalf = np.exp(fun.linear(xHalf, a, b)) * 10
            text = r"$" + text + r"$"
            ax.text(xHalf,
                    yHalf,
                    text,
                    color="black",
                    ha="center",
                    va="center",
                    size=10,
                    zorder=+400)
        # print "interpolation" to the rest of lower x values
        ax.semilogy(np.arange(120, 70, -1),
                    np.exp(fun.linear(np.arange(120, 70, -1), a, b)),
                    ls=":",
                    color="lightgray",
                    zorder=+300)
        #Fit f
        for i in range(len(rngt) - 2, -1, -1):  #reverse iteration
            y = data[:, 3] / data[:, 4]
            a, b = fun.linearFit(x, y, rngt[i], rngt[i + 1])
            ax2.plot(x[rngt[i]:rngt[i + 1] + 1],
                     np.exp(fun.linear(x[rngt[i]:rngt[i + 1] + 1], a, b)),
                     ls="-",
                     color="lightgray",
                     zorder=+200)
            xHalf = (x[rngt[i]] + x[rngt[i + 1]] + 1) / 2
            text = "{:03.3f}".format(-b)
            yHalf = np.exp(fun.linear(xHalf, a, b)) * 1.02
            text = r"$" + text + r"$"
            ax2.text(xHalf,
                     yHalf,
                     text,
                     color="gray",
                     ha="center",
                     va="center",
                     size=7,
                     zorder=+400)

    return lg1