From 71119df0eedc87f5a5eeaa50551bb177bf4636e6 Mon Sep 17 00:00:00 2001 From: Martin Killenberg <martin.killenberg@desy.de> Date: Tue, 17 Jan 2023 12:56:26 +0100 Subject: [PATCH] improve plot headers --- Python_script/prototype.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/Python_script/prototype.py b/Python_script/prototype.py index 7457736..e5c4a25 100755 --- a/Python_script/prototype.py +++ b/Python_script/prototype.py @@ -75,6 +75,8 @@ class Measurements: next_soaking = int(list_of_values[2]) # soaking_time next_reads = int(list_of_values[3]) # number of stable readings + self.measurement_plot.fig.suptitle("Measurement "+str(measurement_number)+': ' + str(next_temp) + + ' degC, ' + str(next_hum) + ' rel. hum.', color="red") self.perform_single_measurement(self.output_basename+'_'+str(measurement_number)+'.csv', next_temp, next_hum, next_soaking, next_reads) measurement_number += 1 @@ -84,12 +86,12 @@ class Measurements: plt.close() - return measurement_number - if self.standby: standby_response = self.chamber.set_mode('STANDBY') print(standby_response) + return measurement_number + def perform_temperature_sweep(self, start_temp, stop_temp, temp_step, target_hum, soaking_time, n_stable_reads): current_temp = start_temp temperatures = [] @@ -100,8 +102,12 @@ class Measurements: for temp in temperatures: output_name = self.output_basename + '_'+str(temp)+'deg.csv' + self.measurement_plot.fig.suptitle("Temp. sweep measurement "+str(temperatures.index(temp)+1)+'/'+str(len(temperatures))+ + ': ' + str(temp) + ' degC, ' + str(target_hum) + ' rel. hum.', + color="red") self.perform_single_measurement(output_name, temp, target_hum, soaking_time, n_stable_reads) + plt.close() return temperatures def perform_single_measurement(self, output, target_temp, target_hum, soaking_time, n_stable_reads): @@ -320,7 +326,7 @@ class Measurements: return (target_hum-self.max_delta_hum <= float(readback_hum)) and \ (float(readback_hum) <= target_hum+self.max_delta_hum) -def plot_output(output_basename, measurements_appendices, show_blocking_plot): +def plot_output(output_basename, measurements_appendices, show_blocking_plot, title = ''): list_of_frames = [] for m in measurements_appendices: measurement_name = output_basename+'_'+str(m) @@ -329,7 +335,7 @@ def plot_output(output_basename, measurements_appendices, show_blocking_plot): combined_data_frame = pd.concat(list_of_frames, ignore_index=True, sort=False) if show_blocking_plot: plt.ioff() - plot = MeasurementPlot.MeasurementPlot() + plot = MeasurementPlot.MeasurementPlot(title) plot.draw(combined_data_frame, output_basename + '_graph.pdf') def run_temperature_sweep_from_file(temperature_sweep_file, meas): @@ -397,14 +403,15 @@ if __name__ == '__main__': try: if args.file: n_measurements = mes.perform_measurements(args.file) - plot_output(output_basename, range(n_measurements), args.plot) + plot_output(output_basename, range(n_measurements), args.plot, output_basename) if args.temperaturesweepfile: temperatures = run_temperature_sweep_from_file(args.temperaturesweepfile, mes) #run analysis here temp_extensions = [] for t in temperatures: temp_extensions.append(str(t)+'deg') - plot_output(output_basename, temp_extensions, args.plot) + plot_output(output_basename, temp_extensions, args.plot, output_basename + ': Temperature sweep ' + + str(temperatures[0]) + ' degC to ' + str(temperatures[-1]) + ' degC') print(str(temp_extensions)) finally: mes.chamber.close() -- GitLab