d.show() #Now convert the angle to sin^2 t.apply(lambda x: np.sin(np.radians(x[0]/2.0))**2, 0,header=r"$sin^2\theta$") # Now create the m^2 order m=np.arange(len(t))+fringe_offset m=m**2 #And add it to t t.add_column(m, column_header='$m^2$') #Now we can it a straight line t.setas="x..y" fit=t.lmfit(Linear,result=True,replace=False,header="Fit") g=t["LinearModel:slope"] gerr=t["LinearModel:slope err"]/g g=np.sqrt(1.0/g) gerr/=2.0 l=float(d['Lambda']) th=l/(2*g) therr=th*(gerr) t.inset(loc="top right",width=0.5,height=0.4) t.plot_xy(r"Fit",r"$sin^2\theta$", 'b-',label="Fit") t.plot_xy(r"$m^2$",r"$sin^2\theta$", 'ro',label="Peak Position") t.xlabel="Fringe $m^2$" t.ylabel=r"$sin^2\theta$" t.title="" t.legend(loc="upper left") t.draw() pyplot.sca(t.axes[0]) # Get the wavelength from the metadata # Calculate thickness and report pyplot.text (0.05,0.05, "Thickness is: {} $\AA$".format(format_error(th,therr,latex=True)), transform=main_fig.axes[0].transAxes)
m = m ** 2 # And add it to t t.add_column(m, column_header="$m^2$") # Now we can it a straight line t.setas = "x..y" fit = t.lmfit(Linear, result=True, replace=False, header="Fit") g = t["LinearModel:slope"] gerr = t["LinearModel:slope err"] / g g = np.sqrt(1.0 / g) gerr /= 2.0 l = float(d["Lambda"]) th = l / (2 * g) therr = th * (gerr) t.inset(loc="top right", width=0.5, height=0.4) t.plot_xy(r"Fit", r"$sin^2\theta$", "b-", label="Fit") t.plot_xy(r"$m^2$", r"$sin^2\theta$", "ro", label="Peak Position") t.xlabel = "Fringe $m^2$" t.ylabel = r"$sin^2\theta$" t.title = "" t.legend(loc="upper left") t.draw() pyplot.sca(t.axes[0]) # Get the wavelength from the metadata # Calculate thickness and report pyplot.text( 0.05, 0.05, "Thickness is: {} $\AA$".format(format_error(th, therr, latex=True)), transform=main_fig.axes[0].transAxes, )
m = np.arange(len(t)) + fringe_offset m = m**2 #And add it to t t.add_column(m, column_header='$m^2$') #Now we can it a straight line t.setas = "x..y" fit = t.lmfit(Linear, result=True, replace=False, header="Fit") g = t["LinearModel:slope"] gerr = t["LinearModel:slope err"] / g g = np.sqrt(1.0 / g) gerr /= 2.0 l = float(d['Lambda']) th = l / (2 * g) therr = th * (gerr) t.inset(loc="top right", width=0.5, height=0.4) t.plot_xy(r"Fit", r"$sin^2\theta$", 'b-', label="Fit") t.plot_xy(r"$m^2$", r"$sin^2\theta$", 'ro', label="Peak Position") t.xlabel = "Fringe $m^2$" t.ylabel = r"$sin^2\theta$" t.title = "" t.legend(loc="upper left") t.draw() pyplot.sca(t.axes[0]) # Get the wavelength from the metadata # Calculate thickness and report pyplot.text(0.05, 0.05, "Thickness is: {} $\AA$".format(format_error(th, therr, latex=True)), transform=main_fig.axes[0].transAxes)
"""Plot data using two y-axes.""" from Stoner import Data p = Data("sample.txt", setas="xyy") p.plot_xy(0, 1, "k-") p.y2() p.plot_xy(0, 2, "r-")
d.del_rows(0, lambda x, r: np.any(np.isnan(r))) popt, pcov = d.curve_fit(bg_wrapper, xcol=t_col, ycol=r_col, p0=p0, absolute_sigma=False) perr = np.sqrt(np.diag(pcov)) labels = [r"\theta_D", r"\rho_0", r"A"] units = ["K", r"\Omega m", r"\Omega m"] annotation = [ "${}$: {}\n".format(l, format_error(v, e, latex=True, mode="eng", units=u)) for l, v, e, u in zip(labels, popt, perr, units) ] annotation = "\n".join(annotation) popt = np.append(popt, 5) T = d.column(t_col) d.add_column(blochGrueneisen(T, *popt), header=r"Bloch") d.plot_xy( t_col, [r_col, "Bloch"], ["ro", "b-"], label=["Data", r"$Bloch-Gr\"ueisen Fit$"], ) d.xlabel = "Temperature (K)" d.ylabel = "Resistance ($\Omega$)" text(0.05, 0.65, annotation, transform=d.axes[0].transAxes)