def plot_sample(plate_id, plate_map, echem_tech, scan_type, sample_number): ''' plot echem data (e.g. 'CA1','CV2') for the specified sample_number from a given plate input: plate_id (int: 4 digit), plate_map (int: 2 digit), echem_tech (string:, e.g. 'CV2'), scan_type (string:'pre' or 'post'), sample_number(int) output: 3 figures of potential vs. time, current vs. time, potential vs. current ''' sample_techfile_dict = plate_sample_techfile(plate_id, plate_map, echem_tech, scan_type) techfile = sample_techfile_dict[sample_number] with open(techfile) as f: data = [] for line in f: try: if type(eval(line.split('\t')[0])) == float: data.append(line) except SyntaxError: continue mydata = np.zeros((len(data), 3)) for index, line in enumerate(data): mydata[index, 0] = float(line.split('\t')[0]) mydata[index, 1] = float(line.split('\t')[1]) mydata[index, 2] = float(line.split('\t')[-2]) t = mydata[:, 0] # time in sec V = mydata[:, 1] # voltage in V I = mydata[:, 2] # current in A fig, ax = plt.subplots(nrows=1, ncols=3, figsize=(16, 4)) ax[0].plot(t, V) ax[0].set_xlabel('time (s)') ax[0].set_ylabel('Potential vs. Reference (V)') ax[1].plot(t, I) ax[1].set_xlabel('time (s)') ax[1].set_ylabel('Current (A)') ax[1].set_title("Sample{0} from plate{1} {2}_{3}PETS".format( sample_number, plate_id, echem_tech, scan_type), fontsize=16) ax[2].plot(V, I) ax[2].set_xlabel('Potential vs. Reference (V)') ax[2].set_ylabel('Current (A)') plt.tight_layout() plt.show()
# -*- coding: utf-8 -*- """ Created on Tue Feb 26 17:28:25 2019 @author: eche """ from collections import defaultdict import numpy as np import matplotlib.pyplot as plt from Plate_Map import plate_map from Plate_Sample_File import plate_sample_techfile sample_loc_dict = plate_map(69) # needs to be updated {sample_number:(x,y)} sample_techfile_dict = plate_sample_techfile(5136, 69, 'CV2') # needs to be updated E = defaultdict(list) # E = {sample number : [E(V)]} for sample_number, techfile in sample_techfile_dict.items(): with open(techfile) as f: data = [] for line in f: try: if type(eval(line.split('\t')[0])) == float: data.append(line) except SyntaxError: continue for line in data: E[sample_number].append(float(line.split('\t')[1])) Emin = {sample_number: np.max(E_list) for sample_number, E_list in E.items()
from scipy.signal import savgol_filter import matplotlib.pyplot as plt from Plate_Sample_File import plate_sample_techfile from Quality_Check import CV2_quality_check from Plate_Map import plate_map_dict ################################################################################### parent_folder_path = r"C:\INST\RUNS\20190603_MnNiMgCaFeY-postPETS_50522" #needs to be updated ################################################################################### plate_id = int(os.path.basename(parent_folder_path).split("_")[-1][:-1]) plate_map = 69 #needs to be updated if necessary echem_tech = 'CV2' #needs to be updated if necessary scan_type = 'post' if 'post' in parent_folder_path else 'pre' sample_techfile_dict = plate_sample_techfile(plate_id, plate_map, echem_tech, scan_type) sample_loc_dict, sample_comp_dict = plate_map_dict(plate_map) I = {} # I = {sample number : 1d_array(I(A))} for sample_number, CV2_file_path in sample_techfile_dict.items(): #if CV2_quality_check(CV2_file_path): # check if sample scan passes cv2 quality check with open(CV2_file_path) as f: txt = f.readlines() current = np.zeros(shape=(len(txt[15:]))) for index, line in enumerate(txt[15:]): current[index] = float(line.split()[-2]) I[sample_number] = current I_smooth = { sample_number: savgol_filter(current, 5, 2) for sample_number, current in I.items()
# -*- coding: utf-8 -*- """ Created on Mon Feb 11 14:14:12 2019 @author: eche """ from collections import defaultdict import numpy as np import matplotlib.pyplot as plt from Plate_Map import plate_map from Plate_Sample_File import plate_sample_techfile sample_loc_dict = plate_map(69) # needs to be updated {sample_number:(x,y)} sample_techfile_dict = plate_sample_techfile(5146, 69, 'CA5') # needs to be updated avg_time = 2 # needs to be updated (seconds from the end) dt = 0.1 # time interval between two voltages I = defaultdict(list) # E = {sample number : [I(A)]} for sample_number, techfile in sample_techfile_dict.items(): with open(techfile) as f: data = [] for line in f: try: if type(eval(line.split('\t')[0])) == float: data.append(line) except SyntaxError: continue for line in data: I[sample_number].append(float(line.split('\t')[-2]))
# -*- coding: utf-8 -*- """ Created on Mon Feb 11 14:02:49 2019 @author: Yu """ from collections import defaultdict import numpy as np import matplotlib.pyplot as plt from Plate_Map import plate_map from Plate_Sample_File import plate_sample_techfile sample_loc_dict = plate_map(93) # needs to be updated {sample_number:(x,y)} sample_techfile_dict = plate_sample_techfile(5208, 93, 'CP4') # needs to be updated avg_time = 2 # needs to be updated (seconds from the end) dt = 0.1 # time interval between two voltages E = defaultdict(list) # E = {sample number : [E(V)]} for sample_number, techfile in sample_techfile_dict.items(): with open(techfile) as f: data = [] for line in f: try: if type(eval(line.split('\t')[0])) == float: data.append(line) except SyntaxError: continue for line in data: E[sample_number].append(float(line.split('\t')[1]))