Skip to content
Snippets Groups Projects
Commit b3214a39 authored by Martin Killenberg's avatar Martin Killenberg
Browse files

change analysis to also allow humidity plots

parent f423ece9
No related branches found
No related tags found
No related merge requests found
......@@ -2,7 +2,6 @@ import pandas as pd
import matplotlib.pyplot as plt
import math
def extract_stable_data(datafile):
datapoint = {}
#df is a pandas data frame
......@@ -30,20 +29,27 @@ def extract_stable_data(datafile):
return datapoint
def plot_temperature_sweep(temperatures, humidity, basename):
temps_from_data = []
# sweep_type is either 'temperature' or 'humidity'
def plot_sweep(temperatures, humidities, basename, sweep_type):
x_data = []
phases = []
phase_vars = []
magnitudes = []
magnitude_vars = []
for temp in temperatures:
datafile = basename+'_'+str(temp)+'deg_'+str(humidity)+'rh.csv'
for temp, hum in zip(temperatures, humidities):
datafile = basename+'_'+str(temp)+'deg_'+str(hum)+'rh.csv'
print(datafile)
datapoint = extract_stable_data(datafile)
if datapoint is None:
continue
temps_from_data.append(datapoint['temperature_mean'])
if sweep_type == 'temperature':
x_data.append(datapoint['temperature_mean'])
elif sweep_type == 'humidity':
x_data.append(datapoint['humidity_mean'])
else:
raise Exception('Unknown sweep_type:'+str(sweep_type))
phases.append(datapoint['phase_mean'])
phase_vars.append(datapoint['phase_var'])
magnitudes.append(datapoint['magnitude_mean'])
......@@ -55,14 +61,20 @@ def plot_temperature_sweep(temperatures, humidity, basename):
fig, ax1 = plt.subplots()
plt.title(basename + ': Temperature sweep at ' + str(humidity) + ' % r.h.')
if sweep_type == 'temperature':
plt.title(basename + ': Temperature sweep at ' + str(humidities[0]) + ' % r.h.')
ax1.set_xlabel('temperature [deg C]')
elif sweep_type == 'humidity':
plt.title(basename + ': Humidity sweep at ' + str(temperatures[0]) + ' deg C')
ax1.set_xlabel('relative humidity [%]')
else:
raise Exception('Unknown sweep_type:'+str(sweep_type))
ax1.errorbar(temps_from_data, phases, phase_vars, marker='+', linewidth=0)
ax1.set_xlabel('temperature [deg C]')
ax1.errorbar(x_data, phases, phase_vars, marker='+', linewidth=0)
ax1.set_ylabel('S21 phase [deg]', color='blue')
ax2 = ax1.twinx()
ax2.errorbar(temps_from_data, magnitudes_db, magnitude_vars_db, marker='x', color='red', linewidth=0)
ax2.errorbar(x_data, magnitudes_db, magnitude_vars_db, marker='x', color='red', linewidth=0)
ax2.set_ylabel('S21 magnitude [dB]', color='red')
fig.tight_layout() # otherwise the right y-label is slightly clipped
......@@ -70,6 +82,4 @@ def plot_temperature_sweep(temperatures, humidity, basename):
if __name__ == '__main__':
plot_temperature_sweep(range(20, 30+1), 40, 'tempsweep1')
plot_sweep(range(20, 30+1), [40]*11, 'tempsweep1', 'temperature')
......@@ -411,7 +411,7 @@ if __name__ == '__main__':
temp_extensions = []
for t in temperatures:
temp_extensions.append(str(t)+'deg_'+str(humidity)+'rh')
analysis.plot_temperature_sweep(temperatures, humidity, output_basename)
analysis.plot_sweep(temperatures, [humidity]*len(temperatures), output_basename, 'temperature')
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))
......
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