Пример #1
0
def import_moke(filename, roi=[-np.inf, np.inf], normalise=True):
    """
    Returns moke data from a file
    ----------------------------------------------------
    Params:
    - filename of data file (str)
    - region of interest - lower and upper bound of roi (2-long array)
    - normalise = True/False

    Returns:
    - x and y data for MOKE in ROI
    ----------------------------------------------------
    """
    lower = roi[0]
    upper = roi[1]
    d = Data(filename)
    d.setas(x='Field(T)', y='MOKE Signal')  # Set axes

    if normalise == True:
        d.y = normalise_moke(d.y)

    d.del_rows('Field(T)', (lower, upper),
               invert=True)  # Delete rows except for ROI

    return d.x, d.y
Пример #2
0
# We then threshold for zero crossing of the derivative
# And check the second derivative to see whether we like the peak as signficant. This is the significance parameter
# and seems to be largely empirical
# Finally we interpolate back to the complete data set to make sure we get the angle as well as the counts.
d.lmfit(ExponentialModel,result=True,replace=False,header="Envelope")
d.subtract("Counts","Envelope",replace=False,header="peaks")
d.setas="xy"
sys.exit()
t=Data(d.interpolate(d.peaks(significance=sensitivity,width=8,poly=4)))

t.column_headers=copy(d.column_headers)
d%='peaks'
t%='peaks'
d.setas="xy"
d.labels[d.find_col('Angle')]=r"Reflection Angle $\theta$"
t.del_rows(0, lambda x,y: x<critical_edge)
t.setas="xy"
t.template.fig_width=7.0
t.template.fig_height=5.0
t.plot(fmt='go',  plotter=pyplot.semilogy)
main_fig=d.plot(figure=t.fig, plotter=pyplot.semilogy)
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"
Пример #3
0
# We then threshold for zero crossing of the derivative
# And check the second derivative to see whether we like the peak as signficant. This is the significance parameter
# and seems to be largely empirical
# Finally we interpolate back to the complete data set to make sure we get the angle as well as the counts.
d.lmfit(ExponentialModel, result=True, replace=False, header="Envelope")
d.subtract("Counts", "Envelope", replace=False, header="peaks")
d.setas = "xy"
sys.exit()
t = Data(d.interpolate(d.peaks(significance=sensitivity, width=8, poly=4)))

t.column_headers = copy(d.column_headers)
d %= "peaks"
t %= "peaks"
d.setas = "xy"
d.labels[d.find_col("Angle")] = r"Reflection Angle $\theta$"
t.del_rows(0, lambda x, y: x < critical_edge)
t.setas = "xy"
t.template.fig_width = 7.0
t.template.fig_height = 5.0
t.plot(fmt="go", plotter=pyplot.semilogy)
main_fig = d.plot(figure=t.fig, plotter=pyplot.semilogy)
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"
Пример #4
0
iterator="iterator" #Temperature ramp iteration column label
threshold=0.85 #Fraction of transition to fit to

data=Data(filename)  #Use FALSE to get a dialog box to the file containing Tc data

#Define my working x and y axes
#Split one file into a folder of two files by the iterator column
fldr=data.split(iterator)

result=Data()
for data in fldr: #For each iteration ramp in the Tc data
    row=[data.mean(iterator)]
    data.figure(figsize=(8,4))
    for i,r_col in enumerate(r_cols):
        data.setas(x=t_col,y=r_col)
        data.del_rows(isnan(data.y))

        #Normalise data on y axis between +/- 1
        data.normalise(base=(-1.,1.), replace=True)

        #Swap x and y axes around so that R is x and T is y
        data=~data

        #Curve fit a straight line, using only the central 90% of the resistance transition
        data.curve_fit(linear,bounds=lambda x,r:-threshold<x<threshold,result=True,p0=[7.0,0.0]) #result=True to record fit into metadata

        #Plot the results
        data.setas[-1]="y"
        data.subplot(1,len(r_cols),i+1)
        data.plot(fmt=["k.","r-"])
        data.annotate_fit(linear,x=-1.,y=7.3c,fontsize="small")
Пример #5
0
    d = Data(j)
    e = Data(j)
    f = Data(j)

    d.setas(x='Magnetic Field (Oe)', y='Moment (emu)')
    d.y *= 1e6
    e.setas(x='Magnetic Field (Oe)', y='Moment (emu)')
    e.y *= 1e6
    f.setas(x='Magnetic Field (Oe)', y='Moment (emu)')
    f.y *= 1e6

    # plt.plot(d.x, d.y, zorder=1, label='Data', color='red')
    # plt.scatter(d.x, d.y, zorder=2, s=10, label='_nolegend_', color='red')

    if j == 'Tops036_01_MvH_30kOe_300K.dat' or j == 'Tops036_06_MvH_30kOe_300K.dat' or j == 'Tops036_11_MvH_30kOe_300K.dat':
        d.del_rows('Magnetic Field (Oe)', (-8500, 8500), invert=True)
        e.del_rows('Magnetic Field (Oe)', (-30000, -8000), invert=True)
        f.del_rows('Magnetic Field (Oe)', (8000, 30000), invert=True)
    else:

        d.del_rows('Magnetic Field (Oe)', (-300, 300), invert=True)
        e.del_rows('Magnetic Field (Oe)', (-7000, -250), invert=True)
        f.del_rows('Magnetic Field (Oe)', (250, 7000), invert=True)

    params1, covar1 = curve_fit(linear, e.x, e.y)
    params2, covar2 = curve_fit(linear, f.x, f.y)
    perr1 = np.sqrt(np.diag(covar1))
    perr2 = np.sqrt(np.diag(covar2))

    m1, c1 = params1[0], params1[1]
    m2, c2 = params2[0], params2[1]
Пример #6
0
iterator="iterator" #Temperature ramp iteration column label
threshold=0.85 #Fraction of transition to fit to

data=Data(filename)  #Use FALSE to get a dialog box to the file containing Tc data

#Define my working x and y axes
#Split one file into a folder of two files by the iterator column
fldr=data.split(iterator)

result=Data()
for data in fldr: #For each iteration ramp in the Tc data
    row=[data.mean(iterator)]
    data.figure(figsize=(8,4))
    for i,r_col in enumerate(r_cols):
        data.setas(x=t_col,y=r_col)
        data.del_rows(isnan(data.y))

        #Normalise data on y axis between +/- 1
        data.normalise(base=(-1.,1.), replace=True)

        #Swap x and y axes around so that R is x and T is y
        data=~data

        #Curve fit a straight line, using only the central 90% of the resistance transition
        data.curve_fit(linear,bounds=lambda x,r:-threshold<x<threshold,result=True,p0=[7.0,0.0]) #result=True to record fit into metadata

        #Plot the results
        data.setas[-1]="y"
        data.subplot(1,len(r_cols),i+1)
        data.plot(fmt=["k.","r-"])
        data.annotate_fit(linear,x=-1.,y=7.3c,fontsize="small")
Пример #7
0
for pat in r_pat:
    r_col = d.find_col(pat, force_list=True)
    if len(r_col) == 1:
        r_col = r_col[0]
        break
else:
    r_col = select_col(d, "Select column for resistance data :")

rho0 = d.min(r_col)[0]
A = rho0 * 40
thetaD = 300.0
p0 = [thetaD, rho0, A]
print("Initial guesses: {}".format(p0))

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)
]