next_frame = filtered_frame[ (filtered_frame.sample_dir == sample) & (filtered_frame.pressure == pressure) & (filtered_frame.voltage == voltage)] next_frame = next_frame.sort_values(by='temperature') if plot_p_diff: plt.plot(next_frame.temperature.tolist(),next_frame.result.tolist(), color= p_diff_color_map.get_color(False), lw = 1, marker = 'o') fplot.add_label('p_diff', p_diff_color_map.get_color(True), marker = 'o' ) if plot_p_BMP: plt.plot(next_frame.temperature.tolist(),next_frame.p_BMP.tolist(), color = p_diff_color_map.get_color(False), lw = 1, marker = 'o') fplot.add_label('p_BMP', p_diff_color_map.get_color(True), marker = 'o' ) if plot_p_MSP: plt.plot(next_frame.temperature.tolist(),next_frame.p_MSP.tolist(), color = p_diff_color_map.get_color(False), lw = 1, marker = 'o') fplot.add_label('p_MSP', p_diff_color_map.get_color(True), marker = 'o' ) plt.plot([-8,-5,0,10,22,40], [-700,-700,-700,-700,-500,-700], 'k', ls = '--') plt.plot([-8,-5,0,10,22,40], [ 700, 700, 700, 700, 500, 700], 'k', ls = '--') fplot.set_plot_config('Temperature [°C]', 'Pressure [mbar]', '{}; {}; {} bar; {} V'.format(root_dir.replace('_',' '), sample, pressure/1000 ,voltage), ylim = [-2000,None]) plt.savefig( '{}/{}/{}/{}/{}_{}_bar_{}_V.png'.format( cwd, results_dir, p_diff_graphs, p_diff_base, sample, pressure/1000, voltage)) plt.close() print('Generating p_diff graphs ....... ({:02d}/{:02d})'.format(g_num, g_total), end="\r", flush=True) g_num += 1 print('Generating p_diff graphs ....... ({:02d}/{:02d})'.format(g_num-1, g_total)) # ============================================================================= # generating p_diff graphs for each file # ============================================================================= os.makedirs('{}/{}/{}/{}'.format(cwd, results_dir, p_diff_graphs, p_diff_file), exist_ok=True) g_num, g_total = 1, 0 for root_dir in root_dirs: filtered_frame = input_frame[input_frame.root_dir == root_dir]
min_index, min_value = fdproc.minimum_index_calculation_using_derivation( time, force, low_threshold, high_threshold) max_index, max_value = fdproc.maximum_index_calculation_by_index( time, force, 0, min_index) results_frame = pd.DataFrame( [[root_dir, sample_dir, filename, max_value]], columns=['root_dir', 'sample_dir', 'filename', 'max_force']) results_frames_list.append(results_frame) plt.figure() # single figure plt.plot(time, force, c=c_map_single_graph.get_color(False), label='') plt.plot(time[min_index], force[min_index], 'r', marker=min_marker) plt.plot(time[max_index], force[max_index], 'k', marker=max_marker) fplot.set_plot_config(xa_label='Time [s]', ya_label='Force [N]', title='{}; {}'.format(root_dir, sample_dir)) fplot.add_label(sample_dir, c_map_single_graph.get_color(False)) fplot.add_label('maximum_force', 'k', 0, '-', max_marker, 6) fplot.add_label('minimum_force', 'r', 0, '-', min_marker, 6) plt.savefig('{}/{}/{}/{}_{}.png'.format(cwd, results_dir, single_file_graphs, root_dir, sample_dir)) plt.close() plt.figure(number) # dirr figure plt.plot(data_frame['sec'], data_frame['N'], c=c_map_root_graph.get_color(False), label='') plt.plot(time[max_index], force[max_index], 'ko')
plt.plot(last_frame.temperature,last_frame.pDiff, color= p_diff_color_map.get_color(False), lw = 1, marker = 'o', label = '') fplot.add_label('p_diff', p_diff_color_map.get_color(True), marker = 'o' ) for msp, msp_cor, msp_cor_new, temp, pDiff in zip(last_frame.valid_MSP_rate, last_frame.valid_msp_rate_cor,last_frame.valid_msp_rate_cor2, last_frame.temperature, last_frame.pDiff ): plt.annotate("{} \n {} \n {}".format(msp, msp_cor, msp_cor_new), [temp, pDiff], fontsize = 16, fontweight='bold', color='red') plt.plot(last_frame.temperature,last_frame.pDiff_BMP, color = p_diff_color_map.get_color(False), lw = 1, marker = 'o', label = '') fplot.add_label('p_BMP', p_diff_color_map.get_color(True), marker = 'o' ) plt.plot(last_frame.temperature,last_frame.pDiff_MSP, color = p_diff_color_map.get_color(False), lw = 1, marker = 'o', label = '') fplot.add_label('p_MSP', p_diff_color_map.get_color(True), marker = 'o' ) plt.plot([-8,-5,0,10,22,40], [-700,-700,-700,-700,-500,-700], 'k', ls = '--') plt.plot([-8,-5,0,10,22,40], [ 700, 700, 700, 700, 500, 700], 'k', ls = '--') plt.legend(loc = 'lower right') fplot.set_plot_config('Temperature [°C]', 'Pressure [mbar]',' {}; {} bar; {} V'.format( sample, pressure/1000 ,voltage/1000), ylim = [-2000,None]) plt.savefig( '{}/{}/{}/{}_{}_bar_{}_V.png'.format( cwd, results_dir, p_diff_graphs, sample, pressure/1000, voltage/1000)) plt.close() # ============================================================================= # Generating comparison graphs for each combination file/voltage/pressure # ============================================================================= print('Generating comparison graphs') os.makedirs('{}/{}/{}'.format(cwd, results_dir, comparison_graphs), exist_ok=True) minimum, maximum = -800, 800 pressures = sorted([ a for a in result_frame.pressure.unique()]) for pressure in pressures:
filesc = fio.get_files(path, contains=['C0'], extension=['csv']) filescc = fio.get_files(path, contains=['C1'], extension=['csv']) filesc = filesc + filescc for file in filesc: print(file) dataframe = pd.read_csv(file, sep=';', decimal=',') weight = dataframe[r'Weight [g]'].tolist() time = dataframe.Time time = time.tolist() time = time_stamp_to_time_diff(time) plt.plot(time, weight, 'g') fplot.add_label('C', 'g') plt.grid() fplot.set_plot_config('Time [s]', 'Weight [g]') # ============================================================================= # # ============================================================================= plt.figure() filesa = fio.get_files(path, contains=['A0'], extension=['csv']) filesaa = fio.get_files(path, contains=['A1'], extension=['csv']) filesa = filesa + filesaa for file in filesa: print(file) dataframe = pd.read_csv(file, sep=';', decimal=',') weight = dataframe[r'Weight [g]'].tolist() time = dataframe.Time time = time.tolist() time = time_stamp_to_time_diff(time)
fplot.set_rc_params(font_size_offset=4) path = r'X:/Dnox/Tesla/2017/E1700224-08/data/recording/ecr_samples.xlsx' frame = pd.read_excel(path, usecols=[0, 1]).dropna() ecr_maxima = frame["Maximum force"].tolist() fplot.plot_swarm([ecr_maxima], [1], color='b') fplot.plot_violin([ecr_maxima], [1]) path = r'X:/Dnox/Tesla/2017/E1700224-08/data/recording/serial_samples.xlsx' frame = pd.read_excel(path, usecols=[0, 1]).dropna() series_maxima = frame["Maximum force"].tolist() fplot.plot_violin([series_maxima], [2], body_color='g') fplot.plot_swarm([series_maxima], [2], color='g') fplot.set_plot_config(xa_label='sample groups sequence', ya_label='Force [N]', title='', xlim=[0, 3], ylim=[None, None]) fplot.modify_ticks(['ecr samples', 'series samples'], [1, 2]) fplot.add_label('ecr samples', 'b', line_width=0, marker='o', marker_size=6) fplot.add_label('serial samples', 'g', line_width=0, marker='o', marker_size=6) fplot.set_rc_params() plt.grid() plt.savefig( r'X:/Dnox/Tesla/2017/E1700224-08/data/recording/results/swarm_comparison.png' )