diff --git a/Python_script/prototype.py b/Python_script/prototype.py index 1fd3e18f1ae663bde35cce6ecf265b0ff04e1646..8eb47c72e5b9282405a6c665f79670c2e7544e99 100755 --- a/Python_script/prototype.py +++ b/Python_script/prototype.py @@ -87,10 +87,12 @@ class Measurements: self.temperature_stable = False self.humidity_stable = False - self.temperature_stable = (next_temp-self.target_accuracy[0] <= float(temp)) and (float(temp) <= next_temp+self.target_accuracy[0]) - self.humidity_stable = (next_hum-self.target_accuracy[1] <= float(hum)) and (float(hum) <= next_hum+self.target_accuracy[1]) + self.temperature_stable = (next_temp-self.target_accuracy[0] <= float(temp)) and \ + (float(temp) <= next_temp+self.target_accuracy[0]) + self.humidity_stable = (next_hum-self.target_accuracy[1] <= float(hum)) and \ + (float(hum) <= next_hum+self.target_accuracy[1]) - # The queue must no be longer than the max number of soaking reads. + # The queue must not be longer than the max number of soaking reads. # If the queue is already full, we have to pop the first element before we can add the # current measurement. if len(magnitudes_queue) == number_of_soaking_reads: @@ -126,7 +128,8 @@ class Measurements: + ' | soaking read nr' + str(len(magnitudes_queue))) self.data_write(writer, next_temp, next_hum, temp, hum, s11, s21, s12, s22) - if self.temperature_stable and self.humidity_stable and self.magnitude_stable and self.phase_stable: + if self.temperature_stable and self.humidity_stable and self.magnitude_stable and\ + self.phase_stable: print('SOAKING FINISHED!') break else: @@ -223,17 +226,32 @@ class Measurements: data = pd.read_csv(output_file) fig, ax1 = plt.subplots(2, figsize=(8, 8)) + + fig.suptitle("Graphical representation of chamber output", color="red") + + path_collection01 = ax1[0].scatter(data.TIMESTAMP, data.S11_PHASE, c='red', marker='<', label='Phase') twin2_0 = ax1[0].twinx() + path_collection02 = twin2_0.scatter(data.TIMESTAMP, data.S11_MAGNITUDE, c='#3120E0', marker='4', label='Magnitude') twin3_0 = ax1[0].twinx() - twin2_1 = ax1[1].twinx() - twin3_1 = ax1[1].twinx() + twin3_0.spines['right'].set_position(('outward', 40)) + path_collection03 = twin3_0.scatter(data.TIMESTAMP, data.EQUILIBRIUM_INDICATOR, c='black', marker=".", label='Equilibrium_Indicator') - fig.suptitle("Graphical representation of chamber output", color="red") + ax1[0].set_xlabel("TIMESTAMP") + ax1[0].set_ylabel("PHASE", color='red') + twin2_0.set_ylabel("MAGNITUDE", color='#3120E0') + twin3_0.set_ylabel("EQUILIBRIUM_INDICATOR", color='black') + + ax1[0].grid(True, linestyle=":") + all_path_collections = [path_collection01, path_collection02, path_collection03] + labels = [pc.get_label() for pc in all_path_collections] + ax1[0].legend(all_path_collections, labels, loc='lower right') - ax1[1].scatter(data.TIMESTAMP, data.READBACK_TEMPERATURE, c='blue', marker='p') - twin2_1.scatter(data.TIMESTAMP, data.READBACK_HUMIDITY, c='green', marker="*") + path_collection11 = ax1[1].scatter(data.TIMESTAMP, data.READBACK_TEMPERATURE, c='blue', marker='p', label="Temperature") + twin2_1 = ax1[1].twinx() + path_collection12 = twin2_1.scatter(data.TIMESTAMP, data.READBACK_HUMIDITY, c='green', marker="*", label="Humidity") + twin3_1 = ax1[1].twinx() twin3_1.spines['right'].set_position(('outward', 40)) - twin3_1.scatter(data.TIMESTAMP, data.EQUILIBRIUM_INDICATOR, c='black', marker=".") + path_collection13 = twin3_1.scatter(data.TIMESTAMP, data.EQUILIBRIUM_INDICATOR, c='black', marker=".", label="Equilibrium_Indicator") ax1[1].set_xlabel("TIMESTAMP") ax1[1].set_ylabel("TEMPERATURE ", color='blue') @@ -241,23 +259,13 @@ class Measurements: twin3_1.set_ylabel("EQUILIBRIUM_INDICATOR", color='black') ax1[1].grid(True, linestyle=":") - ax1[1].legend(["Temperature", "Humidity", 'Equilibrium_indicator'], loc=6, fontsize=10) - - ax1[0].scatter(data.TIMESTAMP, data.S11_PHASE, c='red', marker='<') - twin2_0.scatter(data.TIMESTAMP, data.S11_MAGNITUDE, c='#3120E0', marker='4') - twin3_0.spines['right'].set_position(('outward', 40)) - twin3_0.scatter(data.TIMESTAMP, data.EQUILIBRIUM_INDICATOR, c='black', marker=".") - - ax1[0].set_xlabel("TIMESTAMP") - ax1[0].set_ylabel("PHASE", color='red') - twin2_0.set_ylabel("MAGNITUDE", color='#3120E0') - twin3_0.set_ylabel("EQUILIBRIUM_INDICATOR", color='black') - - ax1[0].grid(True, linestyle=":") - ax1[0].legend(["Phase", "Magnitude", 'Equilibrium_indicator'], loc=6, fontsize=10) + all_path_collections = [path_collection11, path_collection12, path_collection13] + labels = [pc.get_label() for pc in all_path_collections] + ax1[1].legend(all_path_collections, labels, loc='lower right') plt.show() + if __name__ == '__main__': parser = ArgumentParser() parser.add_argument("-c", "--chamber",