def plotter(field, resistance, fitted_line): fig, ax = MakePlot().create() ax.plot(field, 1/resistance) if field[0]>0: ax.plot(np.linspace(0,14,200),1/np.poly1d(fitted_line)(np.linspace(0,14,200))) else: ax.plot(np.linspace(-14, 0, 200), 1 / np.poly1d(fitted_line)(np.linspace(-14, 0, 200))) ax.ticklabel_format(style='sci', axis='y', scilimits=(0, 0)) ax.set_ylabel(r'Conductance $(\frac{2 e^2}{h})$', fontsize=12, fontname='arial') ax.set_xlabel(r'Magnetic Field (T)', fontsize=12, fontname='arial') ax.set_title(r'Checking Fit of Step', fontsize=14, fontname='arial') ax.set_xlim() ax.set_ylim() ax.minorticks_on() ax.tick_params('both', which='both', direction='in', bottom=True, top=True, left=True, right=True) fig.show()
temps_c = ['1.75 K +', '1.75 K -', '2.00 K +', '2.00 K -', '2.25 K +','2.25 K -', '2.50 K +', '2.50 K -'] temps_d = ['1.75 K +', '1.75 K -', '2.00 K +', '2.00 K -', '2.25 K +','2.25 K -'] currents = [r'800 $\mu A$', r'900 $\mu A$'] data_sets = [curr_800, curr_900] sample = 'VT64' res_up_plus, res_down_plus, res_up_minus, res_down_minus = [], [], [], [] b_up_plus, b_down_plus, b_up_minus, b_down_minus = [], [], [], [] fig, axs = MakePlot(nrows=2,ncols=1,figsize=(9,12)).create() axes = [axs[0],axs[1]] for ind, curr_data_name in enumerate(data_sets): temps = temps_a res_lst, field_lst = [], [] label_lst = [] c = 0 for idx, current_temp_data_name in enumerate(curr_data_name): dat = load_matrix(main_path+current_temp_data_name).T
yerr_neg_900 = np.std(np.array([dG_900_neg_up, dG_900_neg_down]), axis=0) B900_neg = np.average(np.array([B_900_neg_up, B_900_neg_down]), axis=0) xerr_neg_900 = np.std(np.array([B_900_neg_up, B_900_neg_down]), axis=0) line_pos800 = np.poly1d(np.polyfit(B800_pos, dG800_pos, 1)) line_neg800 = np.poly1d(np.polyfit(B800_neg, dG800_neg, 1)) line_pos900 = np.poly1d(np.polyfit(B900_pos, dG900_pos, 1)) line_neg900 = np.poly1d(np.polyfit(B900_neg, dG900_neg, 1)) linspace_pos = np.linspace(0, 14, 10) linspace_neg = np.linspace(-14, 0, 10) # Need to put in xy error bars on the points. STD of the above averages. fig, ax = MakePlot(figsize=(16, 9)).create() ax.scatter(B800_pos, dG800_pos, c='r', label=r'800 $\mu$A') ax.scatter(B800_neg, dG800_neg, c='r') ax.errorbar(B800_pos, dG800_pos, xerr=xerr_pos_800, yerr=yerr_pos_800, fmt='none', c='r', alpha=0.5) ax.errorbar(B800_neg, dG800_neg, xerr=xerr_neg_800, yerr=yerr_neg_800,
cap_no_outliers = remove_outliers2(capacitance, 2) cap_interpolated = np.copy(cap_no_outliers) nans, x = nan_helper(cap_interpolated) cap_interpolated[nans] = np.interp(x(nans), x(~nans), cap_interpolated[~nans]) cap_interpolated = savgol_filter(cap_interpolated, get_loess_window(field, 2.2), 2) field = field[15:] cap_interpolated = cap_interpolated[15:] R = R[15:] ref_C0 = cap_interpolated[0] fig, axs = MakePlot(nrows=1, ncols=2).create() fig2, ax2 = MakePlot().create() fig3, ax3 = MakePlot().create() fig_together, axs_together = MakePlot(nrows=1, ncols=2).create() for ind, filename_open in enumerate(filenames): d = {} field, cap_interpolated, R, idx2, raw_cap = process_data(main_path, filename_open) if idx2.shape[0] != 0: b_sign_change_idx = np.argmin(cap_interpolated)
from tools.MakePlot import * import matplotlib.pyplot as plt import scipy.interpolate import scipy.ndimage import matplotlib.colors as mcolors from matplotlib.ticker import FormatStrFormatter main_path = '/Volumes/GoogleDrive/My Drive/Heatmap Cooldowns/' save_path = '/Volumes/GoogleDrive/My Drive/Thesis Figures/Transport/' possible_currents1 = np.array([10,20,50,100,200,500,1000,1500]) fig, ax = MakePlot(figsize=(32,18)).create() # scan is at 1 mA # VT1 # df = load_matrix(main_path+'RvsT_FeSb2-VT1&26-cooldown.dat') # df = df[['Temperature (K)', 'Bridge 1 Resistance (Ohms)']] # # resistance = scipy.ndimage.median_filter(np.array(df['Bridge 1 Resistance (Ohms)']),size=3) # temperature = np.array(df['Temperature (K)']) # VT26 # df = load_matrix(main_path+'RvsT_FeSb2-VT1&26-cooldown.dat') # df = df[['Temperature (K)', 'Bridge 2 Resistance (Ohms)']] # # resistance = scipy.ndimage.median_filter(np.array(df['Bridge 2 Resistance (Ohms)']),size=3)
#currents_log = np.logspace(-3,np.log10(1.5),10000) currents_log = np.linspace(0.01,1.5,10000) temperoos, cureentoos = [], [] temp_lst = [] xx, yy = np.meshgrid(temps, possible_currents1 / 1000) data_grid_og = np.array([np.ravel(xx), np.ravel(yy)]).T temperatures = np.linspace(2, temps[-1], 10000) grid_x, grid_y = np.meshgrid(temperatures, currents_log) sample_lst = [] fig, axs = MakePlot(figsize=(32,18),nrows=5, ncols=4).create() axs = [axs[0,0], axs[0,1], axs[0,2],axs[0,3], axs[1,0], axs[1,1], axs[1,2],axs[1,3], axs[2,0], axs[2,1], axs[2,2],axs[2,3], axs[3,0], axs[3,1], axs[3,2],axs[3,3], axs[4,0], axs[4,1], axs[4,2],axs[4,3]] for i, temp in enumerate(temps): temp_path = main_path + 'VT26/' + str(temp) + '/' current_lst = [] ax = axs[i]
for temp in temps: temp_path = main_path + sample + '/' + str(temp) + '/' resistance_lst, current_lst, field_curr, tempatu_lst = [], [], [], [] for current in possible_currents1: resistance, field = load_r_and_h(temp_path, current) #nans, x = nan_helper(resistance) #resistance[nans] = np.interp(x(nans), x(~nans), resistance[~nans]) max_resistance_loc = np.argmax(resistance) fig, ax = MakePlot().create() plt.axvline(field[max_resistance_loc]) plt.scatter(x=field, y=resistance) plt.title('Temp = ' + str(temp) + 'current' + str(current) + 'sample:' + sample) plt.show() field_curr.append(field[max_resistance_loc]) tempatu_lst.append(temp) current_lst.append(current / 1000) fields_lst.append(field_curr) temperoos.append(tempatu_lst) cureentoos.append(current_lst) df = pd.DataFrame({
r_no_hall, r_hall, field = extract_n_remove_hall(dat) small_df = pd.DataFrame({ r"Magnetic Field (T)": field, r"Transverse Resistance $(\Omega)$": r_hall, r"Longitudinal Resistance $(\Omega)$": r_no_hall, r"Rotation Angle (degrees)": [filename.split('.')[-3].split('_')[-1]] * len(field) }) dat_lst.append(small_df) df = pd.concat(dat_lst) fig, ax = MakePlot(nrows=1, ncols=2).create() sns.lineplot(x="Magnetic Field (T)", y=r"Longitudinal Resistance $(\Omega)$", hue='Rotation Angle (degrees)', data=df, ax=ax[0], legend=False) sns.lineplot(x="Magnetic Field (T)", y=r"Transverse Resistance $(\Omega)$", hue='Rotation Angle (degrees)', data=df, ax=ax[1]) plt.suptitle( 'VT49 Transverse and Longitudinal Resistance by Field and Angle (1.8 K)') plt.savefig(main_path + 'resistance_all_same_ax.png', dpi=600)
from tools.MakePlot import * import matplotlib.pyplot as plt import scipy.interpolate import scipy.ndimage import matplotlib.colors as mcolors from matplotlib.ticker import FormatStrFormatter main_path = '/Volumes/GoogleDrive/My Drive/Heatmap Cooldowns/' save_path = '/Volumes/GoogleDrive/My Drive/Thesis Figures/Transport/' possible_currents1 = np.array([10,20,50,100,200,500,1000,1500]) fig, ax = MakePlot(figsize=(32,18)).create() # scan is at 1 mA # VT1 df = load_matrix(main_path+'RvsT_FeSb2-VT1&26-cooldown.dat') df = df[['Temperature (K)', 'Bridge 1 Resistance (Ohms)']] resistance_vt1 = scipy.ndimage.median_filter(np.array(df['Bridge 1 Resistance (Ohms)']),size=3) temperature_vt1 = np.array(df['Temperature (K)']) # VT26 df = load_matrix(main_path+'RvsT_FeSb2-VT1&26-cooldown.dat') df = df[['Temperature (K)', 'Bridge 2 Resistance (Ohms)']] resistance_vt26 = scipy.ndimage.median_filter(np.array(df['Bridge 2 Resistance (Ohms)']),size=3)
temp_lst.append(flatten(resistance_lst)) fields_lst.append(flatten(field_curr)) temperoos.append(flatten(tempatu_lst)) cureentoos.append(flatten(current_lst)) df = pd.DataFrame({ 'Magnetoresistive Ratio': flatten(temp_lst), 'Temperature (K)': flatten(temperoos), 'Current (mA)': flatten(cureentoos), 'Magnetic Field (T)': flatten(fields_lst) }) groupers = df.groupby('Current (mA)') fig, ax = MakePlot(nrows=2, ncols=5).create() axs = [ ax[0, 0], ax[0, 1], ax[0, 2], ax[0, 3], ax[0, 4], ax[1, 0], ax[1, 1], ax[1, 2], ax[1, 3], ax[1, 4] ] for ind, key in enumerate(groupers.groups.keys()): if ind != 7: sns.scatterplot(x='Magnetic Field (T)', y='Magnetoresistive Ratio', hue='Temperature (K)', data=df[df['Current (mA)'] == key], palette="bright", legend=False, ax=axs[ind]) #style='Temperature (K)', if ind == 7:
for current in possible_currents1: resistance, field = load_r_and_h(load_path, current) resistances.append(resistance) fields.append(field) currents.append([current] * len(resistance)) df = pd.DataFrame({ r'Resistance $(\Omega)$': flatten(resistances), 'Current (mA)': flatten(currents), 'Magnetic Field (T)': flatten(fields) }) groupers = df.groupby('Current (mA)') fig, ax = MakePlot(nrows=2, ncols=5).create() axs = [ ax[0, 0], ax[0, 1], ax[0, 2], ax[0, 3], ax[0, 4], ax[1, 0], ax[1, 1], ax[1, 2], ax[1, 3], ax[1, 4] ] for ind, key in enumerate(groupers.groups.keys()): sns.scatterplot(x='Magnetic Field (T)', y=r'Resistance $(\Omega)$', data=df[df['Current (mA)'] == key], legend=False, ax=axs[ind]) # style='Temperature (K)', if ind < 5: axs[ind].set_xlabel('') if ind != 0:
sample = 'VT64' colours = sns.color_palette('muted') plot = 'long' for ind, curr_data_name in enumerate(data_sets): if ind <= 5: temps = temps_a else: temps = temps_b res_lst, field_lst = [], [] label_lst = [] fig_long, ax_long = MakePlot().create() fig_trans, ax_trans = MakePlot().create() c = 0 for idx, current_temp_data_name in enumerate(curr_data_name): dat = load_matrix(main_path + current_temp_data_name).T res_lst.append(dat[0]) field_lst.append(dat[1]) label_lst.append([temps[idx]] * len(dat[0])) start_loc = 0 max_loc = np.argmax(dat[1]) min_loc = np.argmin(dat[1]) mid_loc = (min_loc - max_loc) / 2 mid_loc = 1 + max_loc + int(mid_loc.round(0))
temps_c = ['1.75 K +', '1.75 K -', '2.00 K +', '2.00 K -', '2.25 K +','2.25 K -', '2.50 K +', '2.50 K -'] temps_d = ['1.75 K +', '1.75 K -', '2.00 K +', '2.00 K -', '2.25 K +','2.25 K -'] currents = [r'500 $\mu A$', r'600 $\mu A$',r'700 $\mu A$',r'800 $\mu A$', r'900 $\mu A$', r'1000 $\mu A$', r'1100 $\mu A$', r'1200 $\mu A$', r'1500 $\mu A$'] data_sets = [curr_500, curr_600, curr_700, curr_800, curr_900, curr_1000, curr_1100, curr_1200, curr_1500] sample = 'VT64' res_up_plus, res_down_plus, res_up_minus, res_down_minus = [], [], [], [] b_up_plus, b_down_plus, b_up_minus, b_down_minus = [], [], [], [] fig, axs = MakePlot(nrows=3,ncols=3,figsize=(16,9)).create() axes = [axs[0,0], axs[0,1], axs[0,2], axs[1,0], axs[1,1], axs[1,2], axs[2,0], axs[2,1], axs[2,2]] for ind, curr_data_name in enumerate(data_sets): if ind == 0 or 2<ind<=5: temps = temps_a elif ind == 1 : temps = temps_c elif ind == 2: temps = temps_d else: temps = temps_b
diff_down_neg = median_filter( np.abs(1 / ffit_down_neg(field_down_neg[small_locs]) / conductance_quantum - 1 / resistance_down_neg[small_locs] / conductance_quantum), 4) down_minus.append(diff_down_neg) vec_down_minus.append(field_down_neg[small_locs]) max_down_minus.append(np.max(diff_down_neg)) max_down_minus_field.append( field_down_neg[small_locs][np.argmax(diff_down_neg)]) sns.set_context('paper') sns.set_context('paper') fig, ax = MakePlot().create() clrs = sns.color_palette('husl', n_colors=10) line_up_plus = np.poly1d(np.polyfit(max_up_plus_field, max_up_plus, 1)) line_down_plus = np.poly1d( np.polyfit(max_down_plus_field, max_down_plus, 1)) line_up_minus = np.poly1d(np.polyfit(max_up_minus_field, max_up_minus, 1)) line_down_minus = np.poly1d( np.polyfit(max_down_minus_field, max_down_minus, 1)) for i in range(len(up_minus)): plt.plot(vec_up_plus[i], up_plus[i], label=temps[i], color=clrs[i],
temps2 = (2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 20.0, 21.0 ) #,22.0,23.0,24.0,25.0,26.0,27.0,28.0,29.0) temp_lab1 = [ 2, 5 ] #,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21]#,22,23,24,25,26,27,28,29]#,19,20,21]#,22] temp_lab2 = [ 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21 ] #,22,23,24,25,26,27,28,29]#,19,20,21]#,22] possible_currents1 = np.array([10, 20, 50, 100, 200, 500, 1000, 1500]) possible_currents2 = np.array([50, 1000]) fig, axs = MakePlot(figsize=(32, 18), nrows=2, ncols=2).create() axs_temp = [axs[0, 0], axs[0, 1]] axs_curr = [axs[1, 0], axs[1, 1]] for i, temp in enumerate(temps): temp_path = main_path + 'VT1/' + str(temp) + '/' ax = axs_temp[i] if i == 1: possible_currents1 = possible_currents1[:-1]
def fit_wo_step2(resistance, field, window_length=5, polyorder=3, deg=3, return_field=False, plot=False, num_pts=6, return_area=False, return_shortened_locs=False): resistance_smooth = scipy.signal.savgol_filter(x=resistance, window_length=window_length, polyorder=polyorder) first_diff = np.diff(resistance_smooth) B1, B2 = get_B1_and_B2(first_diff) step_locs = np.arange(B1, B2) # select a region with 6 points before and 6 points after step # add in functionality here to ensure num_pts not greater/less than total num_left, num_right = num_pts, num_pts if B1 - num_left < 0: num_left = 0 if B2 + num_right > field.shape[0]: num_right = field.shape[0] smaller_region = np.arange(B1 - num_left, B2 + num_right) B1 = field[B1] B2 = field[B2] region_to_fit = np.setdiff1d(smaller_region, step_locs) fitted_line = np.polyfit(x=field[region_to_fit], y=resistance[region_to_fit], deg=deg) if plot: fig, ax = MakePlot().create() ax.plot(field, 1 / resistance) ax.plot(np.linspace(0, 14, 200), 1 / np.poly1d(fitted_line)(np.linspace(0, 14, 200))) plt.show() if return_shortened_locs: step_locs = smaller_region if return_area: area = integrate_the_step(field[smaller_region], np.poly1d(fitted_line), resistance[smaller_region]) if return_field: return np.poly1d(fitted_line), B1, B2, area, step_locs else: return np.poly1d(fitted_line), area, step_locs else: if return_field: return np.poly1d(fitted_line), B1, B2, step_locs else: return np.poly1d(fitted_line), step_locs else: if return_area: area = integrate_the_step(field[smaller_region], np.poly1d(fitted_line), resistance[smaller_region]) if return_field: return np.poly1d(fitted_line), B1, B2, area else: return np.poly1d(fitted_line), area else: if return_field: return np.poly1d(fitted_line), B1, B2 else: return np.poly1d(fitted_line)
currents_c = [ r'500 $\mu A$', '', '', r'800 $\mu A$', r'900 $\mu A$', r'1000 $\mu A$', r'1100 $\mu A$', r'1200 $\mu A$', r'1500 $\mu A$' ] data_sets = [ temp_1p75, temp_2p00, temp_2p25, temp_2p5, temp_2p75, temp_3p00, temp_3p25, temp_3p5, temp_3p75 ] sample = 'VT64' res_up_plus, res_down_plus, res_up_minus, res_down_minus = [], [], [], [] b_up_plus, b_down_plus, b_up_minus, b_down_minus = [], [], [], [] fig, axs = MakePlot(nrows=3, ncols=3).create() axes = [ axs[0, 0], axs[0, 1], axs[0, 2], axs[1, 0], axs[1, 1], axs[1, 2], axs[2, 0], axs[2, 1], axs[2, 2] ] for ind, curr_data_name in enumerate(data_sets): if ind < 3: currents = currents_a elif ind == 3: currents = currents_b else: currents = currents_c res_lst, field_lst = [], []
angles = [ 0, 0, 10, 20, 25, 27.5, 30, 30, 32.5, 35, 35, 37.5, 40, 50, 60, 70, 80 ] filenames_2ndsweep = [ '033.txt', '034.txt', '035.txt', '040.txt', '036.txt', '037.txt', '038.txt', '039.txt' ] angles_2 = [0, 10, 20, 26, 30, 40, 50, 60] C0_a = find_C0(main_path, '033.txt') C0_b = C0_a print(C0_a) fig, axs = MakePlot(nrows=1, ncols=2).create() axins = axs[0].inset_axes([0.1, 0.375, 0.25, 0.25]) for ind, filename_open in enumerate(filenames): d = {} field, cap_interpolated, R, idx2, raw_cap = process_data(main_path, filename_open, ref_C0=C0_a) ax = axs[0] ax.scatter(field, raw_cap, c=plt.cm.jet(ind / len(filenames)),
from matplotlib.cm import get_cmap from tools.DataFile import DataFile from tools.MakePlot import * import matplotlib.pyplot as plt import scipy.interpolate import scipy.ndimage import matplotlib.colors as mcolors from matplotlib.ticker import FormatStrFormatter main_path = '/Volumes/GoogleDrive/My Drive/Heatmap Cooldowns/' save_path = '/Volumes/GoogleDrive/My Drive/Thesis Figures/Transport/' possible_currents1 = np.array([10, 20, 50, 100, 200, 500, 1000, 1500]) fig, ax = MakePlot(figsize=(32, 18)).create() # scan is at 1 mA df = load_matrix(main_path + 'RvsT_FeSb2-VT1&26-cooldown.dat') df = df[['Temperature (K)', 'Bridge 1 Resistance (Ohms)']] resistance = scipy.ndimage.median_filter(np.array( df['Bridge 1 Resistance (Ohms)']), size=3) temperature = np.array(df['Temperature (K)']) ax.plot(temperature, resistance, linewidth=5, c='purple', label='VT1') df = load_matrix(main_path + 'RvsT_FeSb2-VT1&26-cooldown.dat') df = df[['Temperature (K)', 'Bridge 2 Resistance (Ohms)']] resistance = scipy.ndimage.median_filter(np.array(
main_path = '/Users/npopiel/Documents/MPhil/Data/' save_path = '/Volumes/GoogleDrive/My Drive/Thesis Figures/Transport/' samples = ['VT11'] temps = [ 10.0 ] #,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0,11.0,12.0,13.0,14.0,15.0,16.0,17.0,18.0,19.0,20.0,21.0)#,22.0,23.0,24.0,25.0,26.0,27.0,28.0,29.0) temp_lab1 = [ 2 ] #,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21]#,22,23,24,25,26,27,28,29]#,19,20,21]#,22] possible_currents1 = np.array([10, 20, 50, 100, 200, 500, 1000, 1500]) fig, axs = MakePlot(figsize=(32, 18), nrows=2, ncols=4).create() axs = [ axs[0, 0], axs[0, 1], axs[0, 2], axs[0, 3], axs[1, 0], axs[1, 1], axs[1, 2], axs[1, 3] ] for i, temp in enumerate(temps): temp_path = main_path + 'VT1/' + str(temp) + '/' for ind, current in enumerate(possible_currents1): ax = axs[ind] resistance, field = load_r_and_h(temp_path, current) lab = str(current) + r' $\mu \mathrm{A}$'
import matplotlib.colors as mcolors from matplotlib.ticker import FormatStrFormatter main_path = '/Users/npopiel/Documents/MPhil/Data/' save_path = '/Volumes/GoogleDrive/My Drive/Thesis Figures/Transport/' data = np.loadtxt( '/Volumes/GoogleDrive/My Drive/Thesis Figures/NJM_Nov19_sweep.130.dat', delimiter='\t', skiprows=10) field = data[:, 0] resistance = data[:, 1] * 1e5 fig, ax = MakePlot(figsize=(16, 9), nrows=1, ncols=1).create() ax.plot(field, resistance, linewidth=1.8, c='k') ax.ticklabel_format(style='sci', axis='y', scilimits=(0, 0), useMathText=True) ax.minorticks_on() ax.tick_params('both', which='major', direction='in', length=6, width=2, bottom=True, top=True, left=True, right=True)