def file_check(filename): filebase = filename filename = filebase + ".txt." #read in the first line. with open(filename, 'r') as f: line1 = f.readline().strip() new_format = False old_format = False #"name" is characteristic of the new format. if "Name" in line1: new_format = True old_format = False elif "Name" not in line1: new_format = False old_format = True if old_format == True: nanonightly.convert_to_new(filename) filename = filebase + "_KSV_NIMA_Format.txt" skip = 1 return old_format, new_format
filename = filebase +".txt." with open(filename, 'r') as f: line1 = f.readline().strip() new_format = False old_format = False if "Name" in line1: new_format = True old_format = False elif "Name" not in line1: new_format = False old_format = True if old_format == True: nanonightly.convert_to_new(filename) filename = filebase + "_KSV_NIMA_Format.txt" skip = 1 # We then use this to do our data analysis. t, Bpos, Bspd, A, Mma, P1, P2 = nanonightly.loadtxt(filename, unpack = True, usecols = [0,1,2,3,4,5,6], skiprows=44) t_smooth, A_smooth = nanonightly.smooth_data(t, A, new_array_len = len(t), window_size = size, poly_order = order) t_smooth, P1_smooth = nanonightly.smooth_data(t, P1, new_array_len = len(t), window_size = size, poly_order = order) t_smooth, P2_smooth = nanonightly.smooth_data(t, P2, new_array_len = len(t), window_size = size, poly_order = order) t_smooth, Bpos_smooth = nanonightly.smooth_data(t, Bpos, new_array_len = len(t), window_size = size, poly_order = order) t_smooth, Bspd_smooth = nanonightly.smooth_data(t, Bspd, new_array_len = len(t), window_size = size, poly_order = order) t_smooth, Mma_smooth = nanonightly.smooth_data(t, Mma, new_array_len = len(t), window_size = size, poly_order = order) #t, Bpos, Bspd, A, Mma, P1, P2 = loadtxt(filename, unpack = True, usecols = [0,1,2,3,4,5,6], skiprows=44)