for root_dir in root_dirs: filtered_frame = input_frame[input_frame.root_dir == root_dir] samples_s = sorted([a for a in filtered_frame.sample_dir.unique()]) for sample in samples_s: for pressure in pressures: for voltage in voltages: p_diff_color_map.reset() plt.ioff() plt.figure() plt.ioff() 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))
line, = axes.plot(numpy_2d_array[0], numpy_2d_array[1], color=cur_data.line_plot_settings_color, linewidth=cur_data.line_plot_settings_line_width, ls=cur_data.line_plot_settings_line_style, marker=cur_data.line_plot_settings_marker, ms=cur_data.line_plot_settings_marker_size) else: pass # ============================================================================= # LINE-LABEL PLOT FOR EACH LINE # ============================================================================= if cur_data.line_label_plot_settings_plot == "each" and cur_data.line_plot_settings_plot == "each": fplot.add_label(cur_data.labels_line[number], line.get_color(), cur_data.line_label_plot_settings_line_width, cur_data.line_label_plot_settings_line_style, cur_data.line_label_plot_settings_marker, cur_data.line_label_plot_settings_marker_size) else: pass # ============================================================================= # DERIVATION LINE PLOT FOR EACH LINE # ============================================================================= if cur_data.derivation_plot_settings_plot == "each" and cur_data.derivation_plot_settings_color == "random" and cur_data.derivation_calculation_settings_calculate: line2, = axes.plot( numpy_2d_array[0][low:high], derivation, color=c_map.get_der_color(), linewidth=cur_data.derivation_plot_settings_line_width, ls=cur_data.derivation_plot_settings_line_style, marker=cur_data.derivation_plot_settings_marker,
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.figure(len(unique_root_dirs) + 1) # combined 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) plt.plot(time, weight, 'b') fplot.add_label('A', 'b') filesb = fio.get_files(path, contains=['B0'], extension=['csv']) filesbb = fio.get_files(path, contains=['B1'], extension=['csv']) filesb = filesb + filesbb for file in filesb: 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, 'r') fplot.add_label('B', 'r')
plt.figure() plt.ioff() 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,
samples = sorted([ a for a in result_frame['sample'].unique() ]) for sample in samples: next_frame = result_frame[result_frame['sample'] == sample] pressures = sorted([ a for a in next_frame['pressure'].unique() ]) for pressure in pressures: next_frame2 = next_frame[next_frame['pressure'] == pressure] voltages = sorted([ a for a in next_frame2['voltage'].unique()]) for voltage in voltages: last_frame = next_frame2[next_frame2['voltage'] == voltage] p_diff_color_map.reset() plt.figure() last_frame = last_frame.sort_values(by='temperature') 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))
samples = sorted([a for a in hydra_frame['Ident No.'].unique()]) print('sample', ' ', 'volumetric', ' ', 'p_diff') for sample in samples: p_diff = hydra_frame.loc[ (hydra_frame['Ident No.'] == sample), ['066_Diff_BMP_VIS_P_Mess_6_0bar_MP4_Sp1']].values[0] volumetric = hydra_frame.loc[ (hydra_frame['Ident No.'] == sample), ['006_BerechnetesHubvolumen_6_0bar_3_Sp1']].values[0] plt.plot(volumetric / volumetric_constant - 1, p_diff, color=c_map.get_color(False), marker='o', markeredgecolor='k') fplot.add_label(sample, c_map.get_color(True), 0, '-', 'o') print(sample, ' ', volumetric / volumetric_constant - 1, ' ', p_diff) x = np.linspace(-0.08, 0.08, 20000) over_200_ppm = 6372549.02 * x**6 - 800150.8296 * x**5 + 19541.8552 * x**4 + 562.4057315 * x**3 - 18.20980735 * x**2 - 9.135497395 * x**1 + 1.300099753 * x**0 over_10_ppm = 4017242.862 * x**6 - 438603.9335 * x**5 - 8783.299926 * x**4 + 1736.291492 * x**3 + 8.192154187 * x**2 - 10.47552085 * x**1 + 0.990573908 * x**0 under_200_ppm = -59264.74327 * x**6 - 4554.65587 * x**5 + 335.2822676 * x**4 + 57.22096531 * x**3 + 2.013566176 * x**2 - 8.579590974 * x**1 - 0.383176295 * x**0 under_10_ppm = -169755.1637 * x**6 - 13455.58466 * x**5 + 3216.230457 * x**4 + 89.40620783 * x**3 - 19.32913576 * x**2 - 8.298948559 * x**1 - 0.070463402 * x**0 aa = np.where(under_200_ppm < -0.5)[0][0] start = np.where((x >= -0.04))[0][0]
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' )