Beispiel #1
0
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)
Beispiel #2
0
"""Add an inset to a plot."""
from Stoner import Data

p = Data("sample.txt", setas="xy")
p.plot()
p.inset(loc=1, width="50%", height="50%")
p.setas = "x.y"
p.plot()
p.title = ""  # Turn off the inset title
Beispiel #3
0
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,