Skip to content
Snippets Groups Projects
Commit d7104a63 authored by Michael Pawelzik's avatar Michael Pawelzik
Browse files

test for module postplot

analysis functions for postplot added
parent ba043c31
No related branches found
No related tags found
1 merge request!3feat: introduce external sensors
......@@ -10,6 +10,7 @@ import sys
from pathlib import Path
import os
import MeasurementPlot
import curvefit_and_correlation
# after measurement has finished from stored csv-data a post plot of all temperature steps is plotted and store in
......@@ -24,11 +25,11 @@ class PostPlot:
get_ipython().run_line_magic('matplotlib', 'qt')
self.postplot_obj = MeasurementPlot.MeasurementPlot(legend_loc = 'upper left', \
self.measplot_obj = MeasurementPlot.MeasurementPlot(legend_loc = 'upper left', \
legend_bbox_to_anchor = (1.09, 1))
# set parameter figure of class to object parameter figure
self.fig = self.postplot_obj.fig
self.fig = self.measplot_obj.fig
# read csv-file and import data to data frame
def import_csv(self, csv_file):
......@@ -47,7 +48,7 @@ class PostPlot:
data_frame.reset_index(inplace=True, drop=True)
# set y-Achlabel in all subplots to Time an in square brackets the selected time unit
for element in self.postplot_obj.ax1:
for element in self.measplot_obj.ax1:
element.set_xlabel("Time [%s]" %time_unit)
# make a copy of data_frame in parameterlist without changing original during modification
......@@ -66,7 +67,7 @@ class PostPlot:
postplot_data_frame.update(time_vals)
# refresh subflots with data in data frame
self.postplot_obj.draw(postplot_data_frame, pdf_name = '')
self.measplot_obj.draw(postplot_data_frame, pdf_name = '')
# cal PK2PK values of magnitude and phase
PK2PK = self.calc_mag_phase_pkpk_values(data_frame)
......@@ -77,11 +78,13 @@ class PostPlot:
def edit_annotation_in_plot(self, annotate_string ='', anno_fontsize = 16):
self.fig
# update text of annotation in first subplot
self.postplot_obj.annotation.set_text(annotate_string)
self.measplot_obj.annotation.set_text(annotate_string)
# edit annotation fontsize in first subplot
self.postplot_obj.annotation.set_fontsize(anno_fontsize)
self.measplot_obj.annotation.set_fontsize(anno_fontsize)
def calc_mag_phase_pkpk_values(self, data_frame):
......@@ -128,7 +131,7 @@ if __name__ == '__main__':
# set result path for post plot
Results_Path = r'C:\Users\pawelzik\Desktop\Results\THRU_27032023Copy'
Results_Path = r'C:\Users\pawelzik\Desktop\Results\JBY240_14032023Copy'
# set time unit for post post plot
......@@ -142,10 +145,20 @@ if __name__ == '__main__':
# search all csv files in results folder
csv_file_list = list(Path(Results_Path).glob("**/*.csv"))
# choose annotation option
plot_correlation_coeff = False
plot_regression_coeff = False
# activate plot curvefitting
plot_trace_curvefit = False
# create postplot object, Michael
plot_obj = PostPlot()
fit_corr_obj = curvefit_and_correlation.reg_and_corr(plot_obj)
# empty data frame for concat the data frames from csv import to plot full transistion
concat_data_frame = pd.DataFrame()
......@@ -161,9 +174,36 @@ if __name__ == '__main__':
# concate datesframe for plotting full transistion data
concat_data_frame = pd.concat([concat_data_frame,data_frame],ignore_index=True, sort = False)
# plot frame data
plot_obj.plot_frame_data(data_frame, title, time_unit)
if plot_correlation_coeff == True:
# determine correlation coefficient between func 1 and func 2
corr_coeff =fit_corr_obj.calc_correlation(func_1 = data_frame.S21_PHASE , \
func_2 = data_frame.TEMP_DUT)
# plot correlation coefficient
plot_obj.edit_annotation_in_plot(annotate_string = corr_coeff)
elif plot_regression_coeff == True:
# start curvefit and determine coefficients best fit function
reg_coeff = fit_corr_obj.calc_regression_coeff_phase_S21(data_frame, time_unit = 'min')
# plot regression coefficients
plot_obj.edit_annotation_in_plot(annotate_string = reg_coeff)
plot_obj.edit_annotation_in_plot(annotate_string = reg_coeff)
if plot_trace_curvefit == True:
fit_corr_obj.plot_phase_curve_fit(data_frame = data_frame, \
postplot_obj = plot_obj.measplot_obj, \
time_unit = time_unit, state = True)
# set filename of post plot, Michael
filename = str(csv_file.stem) + '.pdf'
......@@ -175,6 +215,9 @@ if __name__ == '__main__':
# title of this plot will be always full transistion, Michel
plot_obj.plot_frame_data(concat_data_frame, 'Full Transistion', time_unit)
fit_corr_obj.plot_phase_curve_fit(data_frame = concat_data_frame, \
postplot_obj = plot_obj.measplot_obj, \
time_unit = time_unit, state = False)
# filename of plot that contains all steps of sweep is set to FullTransistion, Michael
filename = 'Full_Transistion' + '.pdf'
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment