From 25e8d959352cd33edf76d2b7b35fbbef6ee015eb Mon Sep 17 00:00:00 2001 From: Michael Pawelzik <michael.pawelzik@desy.de> Date: Wed, 26 Jul 2023 14:10:53 +0200 Subject: [PATCH] modification of measurement plot class: - fifth subplot plot changed to show temperature and humidity of meas instrument climate chamber modification of data point generation: - measurement instrument temperature and measurment instrument humidity added --- Python_script/MeasurementPlot.py | 195 +++++++++++++++++++------------ 1 file changed, 118 insertions(+), 77 deletions(-) diff --git a/Python_script/MeasurementPlot.py b/Python_script/MeasurementPlot.py index ade605f..141f11f 100644 --- a/Python_script/MeasurementPlot.py +++ b/Python_script/MeasurementPlot.py @@ -11,21 +11,13 @@ class PlottingError(Exception): pass class MeasurementPlot: - def __init__(self, title='', legend_sensor0 = ['Temperature Sensor0', 'Humidity Sensor0'], \ - legend_sensor1 =['Temperature Sensor1','Humidity Sensor1', 'Air Pressure Sensor1']): + def __init__(self, title=''): # set python for opening an separate plot window when starting from anaconda, Michael if 'ipykernel' in sys.modules: from IPython import get_ipython get_ipython().run_line_magic('matplotlib', 'qt') - # set contents of labels for additional external sensors in legend of subplots, Michael - label_temp_sensor0 = legend_sensor0[0] - label_hum_sensor0 = legend_sensor0[1] - - label_temp_sensor1 = legend_sensor1[0] - label_hum_sensor1 = legend_sensor1[1] - label_air_press_sensor1 = legend_sensor1[2] - + # Third, Fourth and Fifth plot for additional external sensors, Michael self.fig, self.ax1 = plt.subplots(5, figsize=(25, 20)) self.fig.subplots_adjust(bottom= 0.1, hspace = 0.4) @@ -77,14 +69,14 @@ class MeasurementPlot: self.ax1[1].legend(all_path_collections, labels, loc='lower right') - # Third plot: temperature external sensor0, humidity external sensors0, Michael - # sensor 0 is the sensor at port 0 of ahlborn and used for the DUT temperature, DUT humidity, Michael - # label for temeprature and humidity of sensor 0 can be configure by ext_sens_data.json, Michael + # Third plot: parameter of external sensors + # DUT temperature, DUT humidity, Michael + # configuration of used sensor port in ext_sens_data.json, Michael - self.path_collection_temp_sensor0 = self.ax1[2].scatter([],[], c='red', marker='p', label=label_temp_sensor0) + self.path_collection_temp_dut = self.ax1[2].scatter([],[], c='red', marker='p', label='DUT temperature') self.ext_sens_hum_axis = self.ax1[2].twinx() - self.path_collection_hum_sensor0 = self.ext_sens_hum_axis.scatter([],[], c='purple', marker='*', label=label_hum_sensor0) + self.path_collection_hum_dut = self.ext_sens_hum_axis.scatter([],[], c='purple', marker='*', label='DUT humidity') self.ax1[2].set_xlabel("TIMESTAMP") @@ -92,23 +84,22 @@ class MeasurementPlot: self.ext_sens_hum_axis.set_ylabel("HUMIDITY [%RH]", color = 'purple') self.ax1[2].grid(True, linestyle=":") - all_path_collections = [self.path_collection_temp_sensor0, self.path_collection_hum_sensor0] + all_path_collections = [self.path_collection_temp_dut, self.path_collection_hum_dut] labels = [pc.get_label() for pc in all_path_collections] self.ax1[2].legend(all_path_collections, labels, loc='lower right') - # Forth plot: temperatur external sensor1, humidity external sensors1, air pressure external sensor 1, Michael - # sensor 1 is the sensor at port 1 of ahlborn and used for the room temperature, the room humidity - # and the air pressure in the room, Michael - # label for temeprature and humidity of sensor 0 can be configure by ext_sens_data.json, Michael + # Forth plot: parameter of external sensors + # room temperature, room humidity , air pressure room, Michael + # configuration of used sensor port in ext_sens_data.json, Michael - self.path_collection_temp_sensor1 = self.ax1[3].scatter([],[], c='green', marker='*', label=label_temp_sensor1) + self.path_collection_temp_room = self.ax1[3].scatter([],[], c='green', marker='*', label='room temperature') self.sec_ext_hum_sens_axis = self.ax1[3].twinx() - self.path_collection_hum_sensor1 = self.sec_ext_hum_sens_axis.scatter([],[], c='orange', marker='>', label=label_hum_sensor1) + self.path_collection_hum_room = self.sec_ext_hum_sens_axis.scatter([],[], c='orange', marker='>', label='room humidity') self.press_axis = self.ax1[3].twinx() self.press_axis.spines['right'].set_position(('outward', 75)) - self.path_collection_press = self.press_axis.scatter([],[], c='grey', marker='4', label=label_air_press_sensor1) + self.path_collection_air_press_room = self.press_axis.scatter([],[], c='grey', marker='4', label='air pressure room') self.ax1[3].set_xlabel("TIMESTAMP") self.ax1[3].set_ylabel("TEMPERATURE [°C]", color='green') @@ -116,28 +107,53 @@ class MeasurementPlot: self.press_axis.set_ylabel("AIR PRESSURE [mb]", color ='grey') self.ax1[3].grid(True, linestyle=":") - all_path_collections = [self.path_collection_temp_sensor1, self.path_collection_hum_sensor1, \ - self.path_collection_press] + all_path_collections = [self.path_collection_temp_room, self.path_collection_hum_room, \ + self.path_collection_air_press_room] labels = [pc.get_label() for pc in all_path_collections] self.ax1[3].legend(all_path_collections, labels, loc='lower right') - # Fifth plot: heater activity of temeprature heater and humidity heater - # values for activity are requested from climate chamber, Michael - - self.path_collection_temp_heater = self.ax1[4].scatter([],[], c='black', marker='<', label='Temp Heater') - self.path_collection_hum_heater = self.ax1[4].scatter([],[], c='brown', marker='o', label='Hum Heater') + # Fifth plot: parameter of external sensors + # meas instruments temperature, meas instruments humidity, Michael + # configuration of used sensor port in ext_sens_data.json, Michael + self.path_collection_temp_meas_instr = self.ax1[4].scatter([], [], c='black', marker='p', label="meas instr temperature") + self.third_ext_hum_sens_axis = self.ax1[4].twinx() + self.path_collection_hum_meas_instr = self.third_ext_hum_sens_axis.scatter([], [], c='brown', marker="*", label="meas instr humidity") + + # units added to y-axes of subplot 5, Michael self.ax1[4].set_xlabel("TIMESTAMP") - self.ax1[4].set_ylabel("HEATER PERCENTAGE [%]", color='black') - + self.ax1[4].set_ylabel("TEMPERATURE [°C] ", color='black') + self.third_ext_hum_sens_axis.set_ylabel("HUMIDITY [%RH]", color='brown') + self.ax1[4].grid(True, linestyle=":") - all_path_collections = [self.path_collection_temp_heater, \ - self.path_collection_hum_heater] + all_path_collections = [self.path_collection_temp_meas_instr, \ + self.path_collection_hum_meas_instr] labels = [pc.get_label() for pc in all_path_collections] - self.ax1[4].legend(all_path_collections, labels, loc='lower right') + self.ax1[4].legend(all_path_collections, labels, loc='lower right') - + + ###################################################################################### + + ## Block for plot Heater percentage in fifth subplot + # heater activity of temperature heater and humidity heater + # values requested from environmental test chamber + + # self.path_collection_temp_heater = self.ax1[4].scatter([],[], c='black', marker='<', label='Temp Heater') + # self.path_collection_hum_heater = self.ax1[4].scatter([],[], c='brown', marker='o', label='Hum Heater') + + # self.ax1[4].set_xlabel("TIMESTAMP") + # self.ax1[4].set_ylabel("HEATER PERCENTAGE [%]", color='black') + + # self.ax1[4].grid(True, linestyle=":") + # all_path_collections = [self.path_collection_temp_heater, \ + # self.path_collection_hum_heater] + # labels = [pc.get_label() for pc in all_path_collections] + # self.ax1[4].legend(all_path_collections, labels, loc='lower right') + + ####################################################################################### + + def draw(self, data_frame, pdf_name=''): timestamps = data_frame.TIMESTAMP @@ -173,49 +189,67 @@ class MeasurementPlot: self.humidity_axis.set_ylim(minimum, maximum) self.path_collection_hum.set_offsets(np.c_[timestamps, humidities]) - # refresh temperatures for external sensors in subplots for sensor 0 and sensor1, Michael - temp_sensor0 = data_frame.TEMP_SENSOR0 - temp_sensor1 = data_frame.TEMP_SENSOR1 + # refresh temperatures for used external sensors in subplots, Michael + temp_dut = data_frame.TEMP_DUT + temp_room = data_frame.TEMP_ROOM - minimum, maximum = self.get_extended_min_max(temp_sensor0) + minimum, maximum = self.get_extended_min_max(temp_dut) self.ax1[2].set_ylim(minimum, maximum) + self.path_collection_temp_dut.set_offsets(np.c_[timestamps, temp_dut]) - minimum, maximum = self.get_extended_min_max(temp_sensor1) + minimum, maximum = self.get_extended_min_max(temp_room) self.ax1[3].set_ylim(minimum, maximum) + self.path_collection_temp_room.set_offsets(np.c_[timestamps, temp_room]) - self.path_collection_temp_sensor0.set_offsets(np.c_[timestamps, temp_sensor0]) - self.path_collection_temp_sensor1.set_offsets(np.c_[timestamps, temp_sensor1]) - - # refresh humidities external sensors in subplots for sensor 0 and sensor 1, Michael - hum_sensor0 = data_frame.HUM_SENSOR0 - hum_sensor1 = data_frame.HUM_SENSOR1 + # refresh humidities external sensors in subplots for DUT humidity and room + # humidity, Michael + hum_dut = data_frame.HUM_DUT + hum_room = data_frame.HUM_ROOM - minimum, maximum = self.get_extended_min_max(hum_sensor0) + minimum, maximum = self.get_extended_min_max(hum_dut) self.ext_sens_hum_axis.set_ylim(minimum, maximum) - minimum, maximum = self.get_extended_min_max(hum_sensor1) + minimum, maximum = self.get_extended_min_max(hum_room) self.sec_ext_hum_sens_axis.set_ylim(minimum, maximum) - self.path_collection_hum_sensor0.set_offsets(np.c_[timestamps, hum_sensor0]) - self.path_collection_hum_sensor1.set_offsets(np.c_[timestamps, hum_sensor1]) + self.path_collection_hum_dut.set_offsets(np.c_[timestamps, hum_dut]) + self.path_collection_hum_room.set_offsets(np.c_[timestamps, hum_room]) - # refresh air pressure of external sensor in subplot for sensor 1 Michael - air_press = data_frame.AIR_PRESSURE - minimum, maximum = self.get_extended_min_max(air_press) + # refresh air pressure of external sensor in subplot for air pressure room, Michael + air_press_room = data_frame.AIR_PRESS_ROOM + minimum, maximum = self.get_extended_min_max(air_press_room) self.press_axis.set_ylim(minimum, maximum) - self.path_collection_press.set_offsets(np.c_[timestamps, air_press]) + self.path_collection_air_press_room.set_offsets(np.c_[timestamps, air_press_room]) + + # refresh temperature and humidity of external sensor in subplot for measurement + # for instrument temperature and measurement instrument humidity, Michael + temp_meas_instr = data_frame.TEMP_MEAS_INSTR + hum_meas_instr = data_frame.HUM_MEAS_INSTR + + minimum, maximum = self.get_extended_min_max(temp_meas_instr) + self.ax1[4].set_ylim(minimum, maximum) + + minimum, maximum = self.get_extended_min_max(hum_meas_instr) + self.third_ext_hum_sens_axis.set_ylim(minimum, maximum) + self.path_collection_temp_meas_instr.set_offsets(np.c_[timestamps, temp_meas_instr]) + self.path_collection_hum_meas_instr.set_offsets(np.c_[timestamps, hum_meas_instr]) + + ######################################################################### + ## Block for refreshing heater percentages in subplot for heater values # refresh heater percentage values of climate chamber in subplot of heater values, Michael - temp_heater = data_frame.TEMP_HEATER - hum_heater = data_frame.HUM_HEATER - min_temp_heater, max_temp_heater = self.get_extended_min_max(temp_heater) - min_hum_heater, max_hum_heater = self.get_extended_min_max(hum_heater) - minimum = min(min_temp_heater, min_hum_heater) - maximum = max(max_temp_heater, max_hum_heater) - self.ax1[4].set_ylim(minimum-0.05*(maximum-minimum), maximum+0.05*(maximum-minimum)) - self.path_collection_temp_heater.set_offsets(np.c_[timestamps, temp_heater]) - self.path_collection_hum_heater.set_offsets(np.c_[timestamps, hum_heater]) + # temp_heater = data_frame.TEMP_HEATER + # hum_heater = data_frame.HUM_HEATER + # min_temp_heater, max_temp_heater = self.get_extended_min_max(temp_heater) + # min_hum_heater, max_hum_heater = self.get_extended_min_max(hum_heater) + # minimum = min(min_temp_heater, min_hum_heater) + # maximum = max(max_temp_heater, max_hum_heater) + # self.ax1[4].set_ylim(minimum-0.05*(maximum-minimum), maximum+0.05*(maximum-minimum)) + # self.path_collection_temp_heater.set_offsets(np.c_[timestamps, temp_heater]) + # self.path_collection_hum_heater.set_offsets(np.c_[timestamps, hum_heater]) + + ######################################################################### self.path_collection_equi0.set_offsets(np.c_[timestamps, data_frame.EQUILIBRIUM_INDICATOR]) self.path_collection_equi1.set_offsets(np.c_[timestamps, data_frame.EQUILIBRIUM_INDICATOR]) @@ -254,20 +288,27 @@ if __name__ == '__main__': 'EQUILIBRIUM_INDICATOR': i % 4, 'S21_PHASE': 20 - 2*i, 'S21_MAGNITUDE': 0.3*i, - 'TEMP_HEATER': 10, - # percentage humidity heater, Michael - 'HUM_HEATER': 3, - # Temperature Sensor0of external temp sensor added, Michael - 'TEMP_SENSOR0': i, - # Temperature Sensor 1 of external temp sensor added, Michael - 'TEMP_SENSOR1': 25-i, - # Humidity Sensor0 of external hum sensor added, Michael - 'HUM_SENSOR0': 40, - # Humidity Sensor 1 of external hum sensor added, Michael - 'HUM_SENSOR1': 45, + ############################################################### + ##Block for simulation acivity temp heater and hum heater + # 'TEMP_HEATER': 10, + # # percentage humidity heater, Michael + # 'HUM_HEATER': 3, + # DUT Temperature of external temp sensor added, Michael + 'TEMP_DUT': i, + # room temperature of external temp sensor added, Michael + 'TEMP_ROOM': 25-i, + # DUT Humidity of external hum sensor added, Michael + 'HUM_DUT': 40, + # room humidity of external hum sensor added, Michael + 'HUM_ROOM': 45, # Air pressure of external sensor added, Michael - 'AIR_PRESSURE': 1200-10*i - } + 'AIR_PRESS_ROOM': 1000+10*i, + # measurement instrument temperature of external temp sensor added, Michael + 'TEMP_MEAS_INSTR': 40-1.5*i, + # measurement instrument humidity of external hum sensor added, Michael + 'HUM_MEAS_INSTR': 55 + } + measurements.append(measurement) data_frame = pd.DataFrame(measurements) # plot of data frame with test data for actual step -- GitLab