diff --git a/Python_script/PostPlot.py b/Python_script/PostPlot.py index fe71d54c94653b02c92055ef3445930d8e6e9fe7..23f576fdbcbe8b128da24ac391833467642e33ab 100644 --- a/Python_script/PostPlot.py +++ b/Python_script/PostPlot.py @@ -10,7 +10,6 @@ import sys from pathlib import Path import os import MeasurementPlot -import time # after measurement has finished from stored csv-data a post plot of all temperature steps is plotted and store in @@ -47,13 +46,9 @@ class PostPlot: # reset index of data frame data_frame.reset_index(inplace=True, drop=True) - # self.postplot_obj = MeasurementPlot.MeasurementPlot(legend_loc = 'upper left', \ - # legend_bbox_to_anchor = (1.09, 1)) - # set y-Achlabel in all subplots to Time an in square brackets the selected time unit for element in self.postplot_obj.ax1: - element.set_xlabel("Time [%s]" %time_unit) - + element.set_xlabel("Time [%s]" %time_unit) # make a copy of data_frame in parameterlist without changing original during modification postplot_data_frame = data_frame.copy() @@ -65,10 +60,10 @@ class PostPlot: # set scaling of time axis depending on the time unit given in parameter list, Michael # default unit is minutes, Michael - time = self.scaling_time_axes(time_sec, time_unit) + time_vals = self.scaling_time_axes(time_sec, time_unit) # update Timestamps with calculated time values - postplot_data_frame.update(time) + postplot_data_frame.update(time_vals) # refresh subflots with data in data frame self.postplot_obj.draw(postplot_data_frame, pdf_name = '') @@ -112,18 +107,18 @@ class PostPlot: # scaling time axes depending on the time unit def scaling_time_axes(self, time_sec, time_unit): if time_unit == 'min': - time = time_sec/60 + time_vals = time_sec/60 elif time_unit == 'hours': - time = time_sec/3600 + time_vals = time_sec/3600 elif time_unit == 'sec': - time = time_sec + time_vals = time_sec else: - time = time_sec/60 + time_vals = time_sec/60 - return time + return time_vals @@ -165,7 +160,8 @@ 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) # set filename of post plot, Michael diff --git a/Python_script/ext_sensor_names.json b/Python_script/ext_sensor_names.json deleted file mode 100644 index f727cd4a81482d36e8ccd7996fd3307821819606..0000000000000000000000000000000000000000 --- a/Python_script/ext_sensor_names.json +++ /dev/null @@ -1 +0,0 @@ -{"legend_sensor0": ["TEMP-Sensor DUT", "HUM-Sensor DUT"], "legend_sensor1": ["Room Temperature" , "Room Humidity", "Air Pressure Room"], "time_unit": "min", "regression_state": "False", "plot_regression": "False", "plot_corr_coeff": "False"} diff --git a/Python_script/prototype.py b/Python_script/prototype.py index 138f2231ec16a6269d306cad0901b5650dfdbf6f..698189ead4ade02848d4fc13d6ade91a80aaf528 100755 --- a/Python_script/prototype.py +++ b/Python_script/prototype.py @@ -14,11 +14,11 @@ import json import MeasurementPlot import sys import analysis -import ahlborn_temp_hum_sensors +import almemo710 import PostPlot import os import pyvisa -import distutils.util as util +import socket TEMPERATURE_STABLE = 0x1 @@ -31,9 +31,11 @@ MEASUREMENT_STABLE = 0x10 # Class has only attributes which we are using in the read_data_function to read data from VNA and Chamber class MeasurementData: - # values for percentage temp_heater, percentage humidity heater, temperature sensor0, temperature sensor1, air pressure + # values for percentage temp_heater, percentage humidity heater, temperature sensor0, temperature sensor1, air pressure, Michael + # values for measurement instruments temperature, measurement instruments humidity def __init__(self, timestamp, temp, hum, power, frequency, s11, s21, s12, s22, perc_temp_heater, \ - perc_hum_heater, temp_sens0, temp_sens1, hum_sens0, hum_sens1, air_press): + perc_hum_heater, temp_dut, temp_room, temp_meas_instr, hum_dut, hum_room, \ + hum_meas_instr, air_press_room): self.timestamp = timestamp self.temp = temp self.hum = hum @@ -47,28 +49,34 @@ class MeasurementData: self.perc_temp_heater = perc_temp_heater self.perc_hum_heater = perc_hum_heater # new variables for DUT temp, room temp, Michael - self.temp_sens0 = temp_sens0 - self.temp_sens1 = temp_sens1 - # new variables for DUT humidity, room humidity, air pressure room - self.hum_sens0 = hum_sens0 - self.hum_sens1 = hum_sens1 - self.air_press = air_press + # new variable for measurement instruments temp, Michael + self.temp_dut = temp_dut + self.temp_room = temp_room + self.temp_meas_equip = temp_meas_instr + # new variables for DUT humidity, room humidity, air pressure room, Michael + self.hum_dut = hum_dut + self.hum_room = hum_room + self.air_press_room = air_press_room + # new variable for measurement instruments humidity, Michael + self.hum_meas_instr = hum_meas_instr class Measurements: - def __init__(self, chamber_address, vna_address, output_basename, standby, config_data): + def __init__(self, chamber_address, vna_address, output_basename, standby, config_data, \ + config_ext_sens_data, logger_adress): self.max_delta_temp = config_data['delta_temp'] self.max_delta_hum = config_data['delta_hum'] self.max_delta_mag = config_data['delta_mag'] self.max_delta_phase = config_data['delta_phase'] + self.ext_sens_data =config_ext_sens_data self.sleep_time = config_data["sleep_time"] self.frequency = config_data["frequency"] self.vna_config_file = config_data["vna_config_file"] target_accuracy = [self.max_delta_temp, self.max_delta_hum] self.chamber = climate_chamber.create_chamber(chamber_address, target_accuracy) self.vna = VNA.create_vna(vna_address, target_accuracy) - # new object for external sensors, fixed IP for deviced, Michael - self.ext_sensors = ahlborn_temp_hum_sensors.ahlborn(ip = '192.168.115.44', wait_time = 1) + # new object for external sensors, decice 'ALMEMO710', fixed IP in code for device, Michael + self.ext_sensors = almemo710.almemo710(ip = logger_adress, wait_time = 1) self.standby = standby self.output_basename = output_basename self.clock = virtual_time.get_clock(chamber_address, target_accuracy) @@ -82,6 +90,10 @@ class Measurements: self.vna.create_new_trace("Trace2", "S12") self.vna.create_new_trace("Trace3", "S21") self.vna.create_new_trace("Trace4", "S22") + self.postplot_obj = None + + # request all sensor channels from ALMEMO710 of all sensors that are connected to this device, Michael + self.ext_sensors.request_sens_channel_list() self.measurement_plot = MeasurementPlot.MeasurementPlot() self.data_collection = [] @@ -160,12 +172,13 @@ class Measurements: def perform_single_measurement(self, output, target_temp, target_hum, soaking_time, n_stable_reads): with open(output, mode='w', newline='') as csv_file: # fieldnames for percentage temperature heater and percntage humidity heater, - # DUT Temperature, DUT humidity, room temperature, room humidity, airpressure room added, Michael + # DUT Temperature, DUT humidity, room temperature, room humidity, airpressure room added, + # measurement instruments temperature, measurement instruments humidity, Michael fieldnames = ['TIMESTAMP', 'TARGET_TEMPERATURE', 'READBACK_TEMPERATURE', 'TARGET_HUMIDITY', 'READBACK_HUMIDITY', 'RF_POWER', 'RF_FREQUENCY', 'DUT_IDENTIFIER', 'RUN_ID', 'EQUILIBRIUM_INDICATOR', 'TEMP_HEATER', 'HUM_HEATER', - 'TEMP_SENSOR0', 'TEMP_SENSOR1', 'HUM_SENSOR0', - 'HUM_SENSOR1','AIR_PRESSURE', + 'TEMP_DUT', 'TEMP_ROOM', 'TEMP_MEAS_INSTR', + 'HUM_DUT','HUM_ROOM', 'HUM_MEAS_INSTR', 'AIR_PRESSURE_ROOM', 'S11_MAGNITUDE', 'S11_PHASE', 'S12_MAGNITUDE', 'S12_PHASE', 'S21_MAGNITUDE', 'S21_PHASE', 'S22_MAGNITUDE', 'S22_PHASE'] # csv.dict writer add adda row wise @@ -302,29 +315,39 @@ class Measurements: s22 = self.get_trace_data("Trace4") # if readout is successful, leave loop, Michael break - # excption for pyvisa error or timeout + # exception for pyvisa error or timeout except pyvisa.errors.VisaIOError: # call reset function for VNA statstus register and error queue self.vna.reset_status() print('An error occured during VNA read out') - # wait one second for netxt try, Michael + # wait one second for next try, Michael time.sleep(1) iteration+=1 - # request temperatures, humidities and and air pressure from external sensors, Michael - temperatures, humidities, pressures = self.get_ext_sensor_values() - # get DUT temperature and room temeprature out of array, Michael - temp_sens0 = temperatures[0] - temp_sens1 = temperatures[1] - # get room temeprature, room humidity and air pressure of room out of array, Michael - hum_sens0 = humidities[0] - hum_sens1 = humidities[1] - air_press = pressures [0] + # loop with 3 Itherations in case of ALMEMO 710 readout error, Michael + while iteration < 3: + + try: + # request temperatures, humidities and and air pressure from external sensors, Michael + temp_dut, temp_room, temp_meas_inst, hum_dut, hum_room, hum_meas_inst, \ + air_press_room = self.get_ext_sensor_values() + # if readout successfull, leave loop, Michael + break + # exception for telnet socket timeout + except socket.timeout: + + print('An error occured during ALMEMO read out') + # wait one second for next try, Michael + time.sleep(1) + iteration+=1 + - # values percentage temp_heater und percentage hum_heater, temp_sens0, temp_sens1, hum sens0, hum sens 1 - # air_press added to parameterlist oder returned values, Michael + # values percentage temp_heater, percentage hum_heater, temp_dut, temp_room, temp_meas_instr, + # hum_dut, hum_room, hum_meas_instr air_press_room added to parameterlist in returned + # values, Michael return MeasurementData(int(self.clock.time()), temp, hum, power, frequency, s11, s21, s12, s22, \ - perc_temp_heater, perc_hum_heater, temp_sens0, temp_sens1, hum_sens0, hum_sens1, air_press) + perc_temp_heater, perc_hum_heater, temp_dut, temp_room, temp_meas_inst, \ + hum_dut, hum_room, hum_meas_inst, air_press_room) def store_and_plot_data(self, target_temp, target_hum, data, equi_indicator): measurement = { @@ -340,16 +363,20 @@ class Measurements: 'TEMP_HEATER': data.perc_temp_heater, # percentage humidity heater added, Michael 'HUM_HEATER': data.perc_hum_heater, - # Temperature Sensor0 of external temp sensors added, Michael - 'TEMP_SENSOR0': data.temp_sens0, - # Temperature Sensor 1 of external temp sensors added, Michael - 'TEMP_SENSOR1': data.temp_sens1, - # Humidity Sensor0 of external hum sensors added, Michael - 'HUM_SENSOR0': data.hum_sens0, - # Humidity Sensor 1 of external hum sensors added, Michael - 'HUM_SENSOR1': data.hum_sens1, - # Air pressure of external sensors added, Michael - 'AIR_PRESSURE': data.air_press, + # Temperature for DUT of external temp sensors added, Michael + 'TEMP_DUT': data.temp_dut, + # Temperature for room of external temp sensors added, Michael + 'TEMP_ROOM': data.temp_room, + # Temperature for measure instruments of external temp sensors added, Michael + 'TEMP_MEAS_INSTR': data.temp_meas_instr, + # Humidity for DUT of external hum sensors added, Michael + 'HUM_DUT': data.hum_dut, + # Humidity for room of external hum sensors added, Michael + 'HUM_ROOM': data.hum_room, + # Humidity for measurement instruments of external hum sensors added, Michael + 'HUM_MEAS_INSTR': data.hum_instr, + # Air pressure for room of external sensors added, Michael + 'AIR_PRESS_ROOM': data.air_press_room, 'S11_PHASE': self.calculate_mean_phase(data.s11), 'S11_MAGNITUDE': 20*math.log10(self.calculate_mean_magnitude(data.s11)), 'S21_PHASE': self.calculate_mean_phase(data.s21), @@ -372,31 +399,30 @@ class Measurements: # new method to request temperaure values from external sensors of ahlborn, Michael def get_ext_sensor_values(self): - # call method for request sensor data from ahlborn, Michael - self.ext_sensors.request_temp_hum_data_from_ahlborn() - # extract parameters of all temperature entries from buffer of ahlborn - # and store parameters in class properties, Michael - self.ext_sensors.get_param_of_temp_entries() - - # get list of all temperature entries from ahlborn class, Michael - temperatures = self.ext_sensors.temp_vals - - # extract parameters of all humidity entries from buffer of ahlborn - # and store parameters in class properties, Michael - humidities = self.ext_sensors.get_param_of_hum_entries() - - # get list of all humidity entries from ahlborn class, Michael - humidities = self.ext_sensors.hum_vals - - # extract parameters of all pressure entries from buffer of ahlborn - # and store parameters in class properties, Michael - self.ext_sensors.get_param_of_press_entries() - - # get list of all pressure entries from ahlborn class, Michael - pressures = self.ext_sensors.press_vals + # request temperatures, humidities and and air pressure from external sensors, Michael + self.ext_sensors.request_meas_vals_all_channels() + # get DUT temperature, room temperature and measurement instruments temperature , Michael + temp_dut = self.ext_sensors.fetch_channel_param_from_meas_buffer(pattern = \ + self.ext_sens_data['ch_temp_dut'])[0].meas_val + temp_room =self.ext_sensors.fetch_channel_param_from_meas_buffer(pattern = \ + self.ext_sens_data['ch_temp_room'])[0].meas_val + temp_meas_inst = self.ext_sensors.fetch_channel_param_from_meas_buffer(pattern = \ + self.ext_sens_data['ch_temp_meas_inst'])[0].meas_val + # get DUT humidity, room humidity and meas_instruments humidity, Michael + hum_dut = self.ext_sensors.fetch_channel_param_from_meas_buffer(pattern = \ + self.ext_sens_data['ch_hum_dut'])[0].meas_val + hum_room =self.ext_sensors.fetch_channel_param_from_meas_buffer(pattern = \ + self.ext_sens_data['ch_hum_room'])[0].meas_val + hum_meas_inst = self.ext_sensors.fetch_channel_param_from_meas_buffer(pattern = \ + self.ext_sens_data['ch_hum_meas_inst'])[0].meas_val + # get air pressure room, Michael + air_press_room = self.ext_sensors.fetch_channel_param_from_meas_buffer(pattern = \ + self.ext_sens_data['ch_air_press_room'])[0].meas_val - # return temepratures, humidities, pressures that have been requested from ahlborn - return temperatures, humidities, pressures + # return temp_dut, temp_room, temp_meas_inst, hum_dut, hum_room, hum_meas_inst, + # air_press_room + return temp_dut, temp_room, temp_meas_inst, hum_dut, hum_room, hum_meas_inst, \ + air_press_room def calculate_complex_numbers(self, values_list): @@ -453,24 +479,10 @@ class Measurements: def plot_output(output_basename, measurements_appendices, show_blocking_plot, ext_sens_data, title = ''): # declaration empty tuple for regression state, plot regression, plot correlation coefficient, Michael - reply_tuple =() - # set legend entries to imported values from json file ext_sens_data.json, Michael - legend_sensor0 = list(ext_sens_data['legend_sensor0']) - legend_sensor1 = list(ext_sens_data['legend_sensor1']) - # set time unit for PostPlot of measurement results to imported value from json file ext_sens_data.json, Michael - time_unit = str(ext_sens_data['time_unit']) - # list of requested values for plot options in PostPlot, Michael - query_list = ['regression_state','plot_regression', 'plot_corr_coeff'] - # set state of plot option to imported values of json file ext_sens_data.json, Michael - for element in query_list: - try: - # covert string to bool, Michael - reply_tuple += (util.strtobool(ext_sens_data[element]),) - # on error add false to tuple - except ValueError: - reply_tuple += (False) - # set values for regression state, plot regression and plot correlation coeffient for values of reply tuple, Michael - regression_state, plot_regression, plot_corr_coeff= reply_tuple + + # set time unit for PostPlot of measurement results to imported value from json file + # ext_sens_data.json, Michael + time_unit = str(ext_sens_data['time_unit']) list_of_frames = [] # storepath is set to working directory with subfolder Plots, Michael @@ -480,36 +492,20 @@ def plot_output(output_basename, measurements_appendices, show_blocking_plot, ex for index, m in enumerate(measurements_appendices): measurement_name = output_basename+'_'+str(m) list_of_frames.append(pd.read_csv(measurement_name+'.csv')) - # call method for postplot, Michael - # add the imported legend entries from ext_sens_data.json for sensor 0 and sensor1 to parameterlist - # of postplot method, Michael - # add the imported time unit from ext_sens_data.json to parameterlist, Michael - # entries for regression_state and plot regression for first postplot are set to false because start - # condition of a sweep, Michael - # plot correclation coefficent is set to the from ext_sens_data.json imported value, Michael - if index < 1: - post_plot.plot_frame_data(list_of_frames[-1], title,legend_sensor0, legend_sensor1, time_unit, \ - False, False, plot_corr_coeff) - # add the imported legend entries from ext_sens_data.json for sensor 0 and sensor1 to parameterlist - # of postplot method, Michael - # add the imported time unit from ext_sens_data.json to parameterlist, Michael - # entries for regression_state and plot regression for all other postplot are set to the from ext_sens_data.json - # imported values, Michael - # plot correclation coefficent is set to False for all othwer plots - else: - post_plot.plot_frame_data(list_of_frames[-1], title,legend_sensor0, legend_sensor1, time_unit, \ - regression_state, plot_regression, False) + + + # plot frame data + post_plot.plot_frame_data(list_of_frames[-1], title, time_unit,) + # store generated postplot to the in storepath defined destination, Michael post_plot.save_fig(storepath, measurement_name+'.pdf') combined_data_frame = pd.concat(list_of_frames, ignore_index=True, sort=False) - # create postplot of alle measurements, Michael - # add the imported legend entries from ext_sens_data.json for sensor 0 and sensor1 to parameterlist - # of postplot method, Michael - # add the imported time unit from ext_sens_data.json to parameterlist - # all other parameters are set to false because they do not work for full transistion of data - post_plot.plot_frame_data(combined_data_frame, title,legend_sensor0, legend_sensor1, time_unit, False, False, False) + # create postplot of all measurements, Michael + # add the imported time unit from ext_sens_data.json to parameterlist + post_plot.plot_frame_data(combined_data_frame, title, time_unit) + # save postplot of all measurents to the in storpath defined destination and name it FullTransistion post_plot.save_fig(storepath, 'FullTransistion.pdf') @@ -517,6 +513,7 @@ def plot_output(output_basename, measurements_appendices, show_blocking_plot, ex plt.ioff() plot = MeasurementPlot.MeasurementPlot(title) plot.draw(combined_data_frame, output_basename + '_graph.pdf') + def run_temperature_sweep_from_file(temperature_sweep_file, meas): with open(temperature_sweep_file) as file: diff --git a/Python_script/the.pdf b/Python_script/the.pdf index 691f4a3aed70efd37119f8d86de94c9046609bba..ac2e8eb8f746bcf84571f39dc69f2410d5f8c126 100644 Binary files a/Python_script/the.pdf and b/Python_script/the.pdf differ