Пример #1
0
    lines.append(slope * x_linspace)
    slopes.append(slope)

    mag_wo_line = savgol_filter(
        savgol_filter(magnetisation - slope * field, 5, 3), 5, 3)

    subtracted_lines.append(mag_wo_line)

    popt, pcov = scipy.optimize.curve_fit(langevin, field, mag_wo_line)

    mu_eff = popt[0]
    c_imp = popt[1]

    langevins.append(langevin(x_linspace, mu_eff, c_imp))

fig, ax = MakePlot().create()

amp = (np.max(slopes) - np.min(slopes)) / 2
linspace = np.linspace(-120, 200, 800)

#optimize_func = lambda x: sinusoid(x[0],x[1],x[2], x[3]) - slopes
#est_amp, est_freq, est_phase, est_mean = scipy.optimize.leastsq(optimize_func, [-1*amp, 1/2, 0, np.min(slopes) + amp])[0]

#est_sine = sinusoid(est_amp,est_freq,est_phase,est_mean)

N, amp, omega, phase, offset, noise = 1000, 1., 2., .5, 4., 3

tt = np.linspace(-120, 150, N)

res = fit_sin(angles, slopes)
error = np.sqrt(res['maxcov'])
Пример #2
0
    t2 = temp_ranges[idx][1] + 1
    save_path = open_path + 'figures/'
    makedir(save_path)
    save_path = save_path +channel+'/'
    makedir(save_path)
    save_path+='smaller/'
    makedir(save_path)
    for temp in range(t1, t2):
        file_name = open_path + base_file_name + str(temp) + file_ext
        df_og = pd.read_csv(file_name)

        df = drop_nans(df_og, nan_on_two=nan_on_two)

        df, peaks_current = extract_sweep_peaks(df, 'ac_current_'+channel, 'current_sweep_'+channel, 'I = ')

        fig, axs = MakePlot(ncols=3, nrows=1, figsize=(16, 9)).create()
        ax1 = axs[0]
        ax2 = axs[1]
        ax3 = axs[2]

        sns.scatterplot(y='resistance_'+channel, x='time', hue='current_sweep_'+channel, data=df, ax=ax1, legend=False)
        # ax1.set_title('Resistance by Time')
        ax1.set_ylabel(r'$R  $', usetex=True, rotation=0,fontsize=16)
        ax1.set_xlabel(r'$t  $', usetex=True,fontsize=16)

        sns.scatterplot(x='voltage_amp_'+channel, y='resistance_'+channel, hue='current_sweep_'+channel, data=df, ax=ax2, legend=False)
        # ax2.set_title('Resistance by Time')
        ax2.set_ylabel(r'', usetex=True, rotation=0,fontsize=16)
        ax2.set_xlabel(r'$V  $', usetex=True,fontsize=16)

        sns.scatterplot(y='resistance_'+channel, x='b_field', hue='current_sweep_'+channel, data=df, ax=ax3, legend=True)
Пример #3
0
headers_ch1_short = [
    'voltage_amp_ch1', 'ac_current_ch1', 'sigma_resistance_ch1',
    'phase_angle_ch1', 'in_phase_voltage_ch1', 'quad_voltage_ch1', 'gain_ch1',
    'second_harmonic_ch1', 'third_harmonic_ch1'
]
nice_names_ch1_short = [
    'Voltage Amplitude (CH1)', 'AC Current (CH1)',
    'Standard Deviation of Resistance (CH1)', 'Phase Angle (CH1)',
    'In Phase Voltage (CH1)', 'Quadrature Voltage (CH1)', 'Gain (CH1)',
    'Second Harmonic (CH1)', 'Third Harmonic (CH1)'
]

for ind, header in enumerate(headers_ch1_short):

    for constant_temp, inds in w.groups.items():
        fig, axs = MakePlot().create()
        sns.scatterplot(y=df[header][inds], x=inds, ax=axs)
        #plt.plot(np.diff(df.temp[inds]))
        #for peak in locs: plt.axvline(peak)
        plt.title(nice_names_ch1_short[ind])
        axs.set_xlabel('Time')
        axs.set_ylabel(nice_names_ch1_short[ind])
        temp = round(float(constant_temp.split('_')[-1]))
        anchored_text = AnchoredText('T = ' + str(temp) + 'K',
                                     loc='upper left')
        axs.add_artist(anchored_text)
        plt.show()
        print('')
'''
    for constant_temp, inds in w.groups.items():
        fig, axs = MakePlot().create()
Пример #4
0
    subtracted_lines_fc.append(scipy.ndimage.median_filter(mag_wo_line_fc, size=2))





# Figure 2 of Koyama et al FeSi

T = np.array(temps)
chi = np.array(slopes_fc)
Ms = np.array(subtracted_lines_fc)
#Ms = np.array(mags_fc)
Bs = np.array(fields_fc)

fig, ax = MakePlot(nrows=2,ncols=5,figsize=(32,18)).create()
ax_lab_size = 36
title_size = 69
plt.style.use('seaborn-paper')

ax1 = ax[0,0]
ax2 = ax[0,1]
ax3 = ax[0,2]
ax4 = ax[0,3]
ax5 = ax[0,4]
ax6 = ax[1,0]
ax7 = ax[1,1]
ax8 = ax[1,2]
ax9 = ax[1,3]
ax10 = ax[1,4]
Пример #5
0
# ax.tick_params('both', which='both', direction='in',
#     bottom=True, top=True, left=True, right=True)
#
# plt.legend(title=r'Temperature $(K)$', loc='best',frameon=True, fancybox=False, edgecolor='k', framealpha=1, borderpad=1)
# plt.title('Arrot Plot in Positive Field Region',fontsize=18,fontname='arial')
#
# plt.show()

# 3B 150 K zoom

# Now ill attempt to fit a line to the arrot plot after removing the first 8 points!
lines_to_fit = []
inverse_gammas = []
err = []
for q in range(len(H_over_M)):
    fig, ax = MakePlot().create()
    x = H_over_M[q] - 1 / chi[q]
    y = M_sqr[q]
    y = scipy.ndimage.median_filter(y, size=10)
    fit, cov = np.polyfit(x[15:], y[15:], 1, cov=True)
    err.append(np.sqrt(np.diag(cov))[0])
    inverse_gammas.append(fit[0])

    print('len of fit region', len(x[15:]))

    ax.plot(H_over_M[q] - 1 / chi[q], M_sqr[q], marker='o', label='150 K')  #
    ax.plot(x[15:], np.poly1d(fit)(x[15:]))

    ax.ticklabel_format(style='sci', axis='y', scilimits=(0, 0))
    ax.set_ylabel(r'$M^2$ $(emu^2)$', fontsize=12, fontname='arial')
    ax.set_xlabel(r'$\frac{H}{M} - \frac{1}{\chi}$ $(\frac{T}{emu})$',
Пример #6
0
    #field_df['DC Moment Fixed Ctr (emu)'] = field_df['DC Moment Fixed Ctr (emu)'].rolling(3).mean()
    field_df['Placement'] = labels[ind]
    field_lst.append(field_df)


big_field_df = pd.concat(field_lst)




big_field_df['Magnetic Field (T)'] = big_field_df['Magnetic Field (Oe)']/10000


sns.set_palette('Paired')

fig, axs = MakePlot(ncols=1, nrows=1, figsize=(16, 9)).create()
ax1 = axs

sns.scatterplot(y='DC Moment Fixed Ctr (emu)', x='Magnetic Field (T)', data=big_field_df, hue='Placement',style='Placement',  alpha=0.7,  ax=ax1)
# ax1.set_title('Field Sweep')
# ax1.set_ylabel(r'Magnetic Moment $(emu)$', usetex=True, rotation=90, fontsize=16)
# ax1.set_xlabel(r'Magnetic Field $(T)$', usetex=True, fontsize=16)

fig.suptitle('Angular Dependence of Magnetization', fontsize=22)
# plt.figlegend(frameon=False,
#                 loc='center right',
#                 title='Angle')  # ,labels=np.unique(df.current_sweep_ch2.values), frameon=True)
#
plt.show()
#plt.savefig('/Users/npopiel/Desktop/fig_w_eaton_smooth.png', dpi=600)
Пример #7
0
    subtracted_lines_fc.append(mag_wo_line_fc)

big_field_df = pd.concat(lst)

big_field_df[
    'Magnetic Field (T)'] = big_field_df['Magnetic Field (Oe)'] / 10000

# Figure 2 of Koyama et al FeSi

T = np.array(temps)
chi = np.array(slopes_fc)
#Ms = np.array(subtracted_lines_fc)
Ms = np.array(mags_fc)
Bs = np.array(fields_fc)

fig, ax = MakePlot(nrows=2, ncols=6, figsize=(32, 18)).create()
ax_lab_size = 36
title_size = 69
plt.style.use('seaborn-paper')

ax1 = ax[0, 0]
ax2 = ax[0, 1]
ax3 = ax[0, 2]
ax4 = ax[0, 3]
ax5 = ax[0, 4]
ax6 = ax[0, 5]
ax7 = ax[1, 0]
ax8 = ax[1, 1]
ax9 = ax[1, 2]
ax10 = ax[1, 3]
ax11 = ax[1, 4]
Пример #8
0
# Now i need to subtract diamagnetic background off of the field sweeps

relevant_cols = [
    'Temperature (K)', 'Magnetic Field (Oe)', 'DC Moment Fixed Ctr (emu)',
    'DC Moment Free Ctr (emu)'
]

x_linspace = np.linspace(-7, 7, 10000)



lines_fc,  fields_fc, mags_fc, subtracted_lines_fc, slopes_fc = [], [], [], [], []
lines_zfc,  fields_zfc, mags_zfc, subtracted_lines_zfc, slopes_zfc = [], [], [], [], []

fig, ax = MakePlot(nrows=1, ncols=3).create()
# Plot original
ax1 = ax[0]
ax2 = ax[1]
ax3 = ax[2]

ax1.plot(field_base_fc,
         scipy.ndimage.median_filter(mag_base_fc -
                                     slope_base_fc * field_base_fc,
                                     size=5),
         c='purple',
         linewidth=2.5,
         label='0.05 T Cool')
ax1.plot(field_base_zfc,
         scipy.ndimage.median_filter(mag_base_zfc -
                                     slope_base_zfc * field_base_zfc,
Пример #9
0
sigma = 13.95


def select_values_near_n(array, n=13.95, cond='max'):
    lst = []
    c = 0
    for ind, el in enumerate(array):
        if cond == 'max':
            if el > n:
                lst.append(c)
        else:
            if el < n:
                lst.append(c)
        c += 1

    return lst


locs_of_maxima = select_values_near_n(df['b_field'])

ordered_bs = np.argsort(df.b_field)

fig2, axs2 = MakePlot().create()
plt.plot(df.b_field)
for loc in locs_of_maxima:
    plt.axvline(loc, c='red')
#plt.plot(np.diff(df.b_field[:num_pts_b_vis]))
plt.title('Verification of Extracting Constant Temperature Regions')
plt.show()
print()
Пример #10
0
        resistance_ratios.append(resistance_ratio)
        voltage_ratios.append(voltage_ratio)
        temps.append([temp] * len(voltage_ratio))
        current_for_ratio.append(current_ratio)

    diction = {
        'Resistance': np.array(flatten(resistance_ratios)) * 100,
        'Current': np.array(flatten(current_for_ratio)) * 1000,
        'Voltage': flatten(voltage_ratios),
        'Temperature': flatten(temps)
    }

    data = pd.DataFrame(diction)

    fig, axs = MakePlot(figsize=(16, 9)).create()
    sns.set_palette('bright')
    sns.lineplot(y='Resistance',
                 x='Temperature',
                 hue='Current',
                 palette='bright',
                 data=data,
                 ax=axs,
                 linestyle='-',
                 legend=True)
    axs.set_ylabel(r'R', rotation=0, fontsize=16)
    axs.set_xlabel(r'T', fontsize=16)
    axs.set_title(titles1[idx], fontsize=22)
    name1 = main_path + 'r_v_temp_' + samples[idx] + '.pdf'
    plt.savefig(name1, dpi=200)
    #plt.show()
Пример #11
0
# FOr the FC, get each data without the line!

wo_line_1zfc = magnetisation_zfc - upper_fit_inc_zfc[0]*(field_zfc)
wo_line_2zfc = magnetisation_zfc - upper_fit_dec_zfc[0]*(field_zfc)
wo_line_3zfc = magnetisation_zfc - lower_fit_inc_zfc[0]*(field_zfc)
wo_line_4zfc = magnetisation_zfc - lower_fit_dec_zfc[0]*(field_zfc)

sns.set_palette('husl')

# Okay, in essence I want to plot raw data in first panel, second panel, all diamagnetic lines,
# next four the raw minus each fitted line,
# maybe a langevin fit also?

# then repeat for ZFC

fig, ax = MakePlot(nrows=2, ncols=3).create()
# Plot original
ax1 = ax[0,0]
ax2 = ax[0,1]
ax3 = ax[0,2]
ax4 = ax[1,0]
ax5 = ax[1,1]
ax6 = ax[1,2]

ax1.plot(field_fc,magnetisation_fc,  linewidth=2.5)
#ax1.plot(fields_zfc[0],subtracted_lines_zfc[0], linewidth=2.5, label='Zero Field Cool')
ax1.ticklabel_format(style='sci', axis='y', scilimits=(0, 0))
ax1.set_ylabel('Magnetisation (emu)', fontsize=12,fontname='arial')
ax1.set_xlabel('Magnetic Field (T)', fontsize=12,fontname='arial')
ax1.set_title(r'Raw Data', fontsize=14,fontname='arial')
ax1.set_xlim()
Пример #12
0
Ms = np.array(mags_fc)
Bs = np.array(fields_fc)

# Figure 3 of Koyama et al FeSi

M_sqr = Ms**2
H_over_M = Bs / Ms

string_temps = [
    r'$100$', r'$125$', r'$150$', r'$175$', r'$200$', r'$250$', r'$275$',
    r'$300$'
]

temperatures = T

fig, ax = MakePlot().create()

offset_val = -0.01

arrot_100 = load_matrix(
    '/Volumes/GoogleDrive/My Drive/Data/isotherms/arrot-100.csv')

xs = H_over_M - 1 / chi
ys = M_sqr

xs = xs.tolist()[::-1]
ys = ys.tolist()[::-1]

xs.append(arrot_100[17:, 0] + 0.04)
ys.append(arrot_100[17:, 1])
Пример #13
0
    open_path = main_path + folder + '/'
    t1 = temp_ranges[idx][0]
    t2 = temp_ranges[idx][1] + 1
    save_path = open_path + 'figures/'
    makedir(save_path)
    for temp in range(t1, t2):
        file_name = open_path + base_file_name + str(temp) + file_ext
        df = drop_nans(pd.read_csv(file_name))

        df, peaks_voltage = extract_sweep_peaks(df, 'voltage_amp_ch2',
                                                'voltage_sweep_ch2', 'sweep_')

        df, peaks_current = extract_sweep_peaks(df, 'ac_current_ch2',
                                                'current_sweep_ch2', 'I = ')

        fig, axs = MakePlot(ncols=3, nrows=3, figsize=(16, 9)).create()
        ax1 = axs[0, 0]
        ax2 = axs[0, 1]
        ax3 = axs[0, 2]
        ax4 = axs[1, 0]
        ax5 = axs[1, 1]
        ax6 = axs[1, 2]
        ax7 = axs[2, 0]
        ax8 = axs[2, 1]
        ax9 = axs[2, 2]

        sns.scatterplot(y='resistance_ch2',
                        x='time',
                        hue='current_sweep_ch2',
                        data=df,
                        ax=ax1,
Пример #14
0
    subtracted_lines_fc.append(mag_wo_line_fc)

big_field_df = pd.concat(lst)

big_field_df[
    'Magnetic Field (T)'] = big_field_df['Magnetic Field (Oe)'] / 10000

# Figure 2 of Koyama et al FeSi

T = np.array(temps)
chi = np.array(slopes_fc)
#Ms = np.array(subtracted_lines_fc)
Ms = np.array(mags_fc)
Bs = np.array(fields_fc)

fig, ax = MakePlot(figsize=(32, 18)).create()
ax_lab_size = 36
title_size = 69
plt.style.use('seaborn-paper')

for i, t in enumerate(T):
    if t == 300:
        ax.plot(Bs[i][3:-3],
                Ms[i][3:-3],
                marker='o',
                label=str(t),
                c=plt.cm.gnuplot(i / len(T)))
    else:
        ax.plot(Bs[i][3:],
                Ms[i][3:],
                marker='o',
Пример #15
0

big_field_df = pd.concat(field_lst)
big_temp_df = pd.concat(temp_lst)

big_field_df['Magnetic Field (T)'] = big_field_df['Magnetic Field (Oe)']/10000

big_temp_df['Magnetic Field (T)'] = big_temp_df['Magnetic Field (Oe)']/10000

big_field_df['DC Moment Fixed Ctr (emu)'] = moving_average(big_field_df['DC Moment Fixed Ctr (emu)'],15)

big_temp_df['DC Moment Fixed Ctr (emu)'] = moving_average(big_temp_df['DC Moment Fixed Ctr (emu)'],15)

sns.set_palette('Paired')

fig, axs = MakePlot(ncols=1, nrows=2, figsize=(16, 9)).create()
ax1 = axs[0]
ax2 = axs[1]


sns.lineplot(y='DC Moment Fixed Ctr (emu)', x='Magnetic Field (T)', data=big_field_df, hue='Angle', ax=ax1, legend=False)
# ax1.set_title('Field Sweep')
# ax1.set_ylabel(r'Magnetic Moment $(emu)$', usetex=True, rotation=90, fontsize=16)
# ax1.set_xlabel(r'Magnetic Field $(T)$', usetex=True, fontsize=16)

sns.lineplot(y='DC Moment Fixed Ctr (emu)', x='Temperature (K)',  hue='Angle', data=big_temp_df, ax=ax2)
# ax2.set_title('Temperature Sweep')
# ax2.set_ylabel(r'Magnetic Moment $(emu)$', usetex=True, rotation=90, fontsize=16)
# ax2.set_xlabel(r'Temperature $(K)$', usetex=True, fontsize=16)

legend = ax2.legend()