import matplotlib.pyplot as plt import functions_io as fio import functions_csv as fcsv import functions_plot as fplot import functions_excel as fexcel import functions_data_processing as fdp x = np.linspace(-0.08, 0.08, 160) 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 #plt.plot(x, over_200_ppm, 'r') #plt.plot(x, over_10_ppm, 'r') #plt.plot(x, under_200_ppm, 'r') #plt.plot(x, under_10_ppm, 'r') fplot.modify_ticks(['-8%', '-4%', '-0%', '4%', '8%'], [-0.08, -0.04, 0, 0.04, 0.08]) plt.xlim(-0.08, 0.08) plt.ylim(-1, 1.5) plt.fill_between(x, -10, under_200_ppm, facecolor='red', alpha=0.5) plt.fill_between(x, under_200_ppm, under_10_ppm, facecolor='yellow', alpha=0.5) plt.fill_between(x, under_10_ppm, over_10_ppm, facecolor='green', alpha=0.5) plt.fill_between(x, over_10_ppm, over_200_ppm, facecolor='yellow', alpha=0.5) plt.fill_between(x, over_200_ppm, 10, facecolor='red', alpha=0.5) plt.grid(color='k')
if next_frame3.temperature.tolist() != [-8,-5,0,10,22,40]: print('Temperature values mismatch at comparison graph generating') if pressure == 4500: plt.plot([0,1,2,3,4,5], [-700,-700,-700,-700,-500,-700], 'k', ls = '--') if pressure == 6000: plt.plot([0,1,2,3,4,5], [-700,-700,-700,-700,-500,-700], 'k', ls = '--') plt.plot([0,1,2,3,4,5], [700,700,700,700,500,700], 'k', ls = '--') if pressure == 8500: plt.plot([0,1,2,3,4,5], [700,700,700,700,500,700], 'k', ls = '--') plt.plot(6.5,minimum , markersize = 0) fplot.set_plot_config('Temperature [°C]', 'Pressure [mbar]',' {}; {} bar; {} V'.format( root_dir, pressure/1000 ,voltage/1000), ylim = [minimum -100, maximum+100]) fplot.modify_ticks(['-8','-5','0','10','22','40'], [0,1,2,3,4,5], action = "clear", axes_type = 'x') plt.savefig( '{}/{}/{}/{}_bar_{}_V.png'.format( cwd, results_dir, comparison_graphs, pressure/1000, voltage/1000)) plt.close()
for temperature in temperatures: next_frame = input_frame[(input_frame.root_dir == root_dir) & (input_frame.temperature == temperature) & (input_frame.pressure == pressure) & (input_frame.voltage == voltage)] data.append(next_frame.result.tolist()) if plot_violin: fplot.plot_violin(data, each_dir_data_positions[number], body_color = comp_color_map.get_color(False), opacity = opacity) if plot_box: fplot.plot_box(data, each_dir_data_positions[number], box_color = "k") if plot_swarm: fplot.plot_swarm(data, each_dir_data_positions[number], color=comp_color_map.get_color(False), marker ="o", ms=10, diff=0.1) else: pass fplot.add_label(root_dir.replace('_',' '), comp_color_map.get_color(True), line_width = 0, line_style = '-', marker = 'o', marker_size = 10) fplot.modify_ticks(temperatures, labels_positions, action = "clear") plt.xlim(labels_positions[0]-2, labels_positions[len(labels_positions)-1]+2) if pressure == 4500: plt.plot(labels_positions, [-700,-700,-700,-700,-500,-700], 'k', ls = '--') if pressure == 8500: plt.plot(labels_positions, [ 700, 700, 700, 700, 500, 700], 'k', ls = '--') if pressure == 6000: plt.plot(labels_positions, [-700,-700,-700,-700,-500,-700], 'k', ls = '--') plt.plot(labels_positions, [ 700, 700, 700, 700, 500, 700], 'k', ls = '--') else: pass fplot.set_plot_config('Temperature [°C]', 'p_diff [mbar]','{} bar; {} V'.format( pressure/1000, voltage)) plt.savefig('{}/{}/{}/{}_{}_comparison.png'.format(cwd, results_dir, comparison_graphs, pressure, voltage)) print('Generating comparison graphs ... ({:02d}/{:02d})'.format(g_num, g_total), end="\r", flush=True)
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' )