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

change analysis plot to dB

parent 94718c3e
No related branches found
No related tags found
No related merge requests found
import pandas as pd
import matplotlib.pyplot as plt
import math
def extract_stable_data(datafile):
datapoint = {}
......@@ -46,15 +47,22 @@ def plot_temperature_sweep(start_temp, stop_temp, humidity, basename):
phase_vars.append(datapoint['phase_var'])
magnitudes.append(datapoint['magnitude_mean'])
magnitude_vars.append(datapoint['magnitude_var'])
magnitudes_db = [ 20* math.log10(x) for x in magnitudes ]
#approximate formula for small errors (linear approximation)
magnitude_vars_db = [ 20 / math.log(10) * dx/x for x, dx in zip( magnitudes, magnitude_vars )]
fig, ax1 = plt.subplots()
plt.title('Temperature sweep at ' +str(humidity) + ' % r.h.')
ax1.errorbar(temps,phases,phase_vars,marker='+',linewidth=0)
ax1.set_xlabel('temperature [deg C]')
ax1.set_ylabel('S21 phase [deg]', color='blue')
ax2 = ax1.twinx()
ax2.errorbar(temps,magnitudes,magnitude_vars,marker='x',color='red',linewidth=0)
ax2.set_ylabel('S21 magnitude [lin]', color='red')
ax2.errorbar(temps,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
plt.show()
......
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