From 5b418907cbc8b4d1827370fa50772a9617e705b4 Mon Sep 17 00:00:00 2001 From: Martin Killenberg <martin.killenberg@desy.de> Date: Wed, 25 Oct 2023 14:06:39 +0200 Subject: [PATCH] feat: introduce normalisation in analysis plots --- Python_script/analysis.py | 25 +++++++++++++++++++------ Python_script/first_tempsweep.txt | 2 +- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/Python_script/analysis.py b/Python_script/analysis.py index 21249a1..94e5b96 100644 --- a/Python_script/analysis.py +++ b/Python_script/analysis.py @@ -33,11 +33,13 @@ def extract_stable_data(datafile, measurement_set, reference_signal_names): # sweep_type is either 'temperature' or 'humidity' -def plot_sweep(temperatures, humidities, basename, sweep_type, measurement_sets, reference_signal_names): +def plot_sweep(temperatures, humidities, basename, sweep_type, measurement_sets, reference_signal_names, normalise = [True, False]): set_data = {} + derivatives = {} for measurement_set in measurement_sets: set_data[measurement_set] = {'signal0_means': [], 'signal0_vars': [], 'signal1_means': [], 'signal1_vars': [], 'x_data': []} + derivatives[measurement_set] = {'signal0_deltas': [], 'signal1_deltas': [], 'x_deltas': []} for temp, hum in zip(temperatures, humidities): datafile = basename+'_'+str(temp)+'deg_'+str(hum)+'rh.csv' @@ -60,10 +62,21 @@ def plot_sweep(temperatures, humidities, basename, sweep_type, measurement_sets, data['signal1_means'].append(datapoint['signal1_mean']) data['signal1_vars'].append(datapoint['signal1_var']) - #fig = plt.figure() - #gs = fig.add_gridspec(2, 1, hspace=0) - #(ax1, ax2) = gs.subplots(sharex=True) - fig, (ax1, ax2) = plt.subplots(2, sharex=True, gridspec_kw={'hspace': 0}, figsize=(10, 5)) + for measurement_set in measurement_sets: + data = set_data[measurement_set] + if normalise[0]: + data['signal0_means'] -= data['signal0_means'][0] + if normalise[1]: + data['signal1_means'] -= data['signal1_means'][0] + + fig = plt.figure(figsize=(10, 5)) + gs = gridspec.GridSpec(nrows=2, ncols=1, hspace=0)#, width_ratios=[3, 1], height_ratios=[3, 1]) + ax1 = fig.add_subplot(gs[0, 0]) + ax2 = fig.add_subplot(gs[1, 0],sharex=ax1) + ##gs = fig.add_gridspec(2, 1, hspace=0) + ##(ax1, ax2) = gs.subplots(sharex=True) + #fig, (ax1, ax2) = plt.subplots(2, sharex=True, gridspec_kw={'hspace': 0}, figsize=(10, 5)) + ax1.tick_params(bottom=True, top=True, direction='in') ax2.tick_params(bottom=True, top=True, direction='inout') @@ -104,5 +117,5 @@ def plot_sweep(temperatures, humidities, basename, sweep_type, measurement_sets, if __name__ == '__main__': print('run \'./prototype.py -t first_tempsweep.txt -p -o tempsweep1\' to get the data needed for this plot.' ) - plot_sweep(np.arange(25., 31.+1.), [35.]*7, 'tempsweep1', 'temperature', + plot_sweep(np.arange(20., 31.+1.), [35.]*12, 'tempsweep1', 'temperature', ['1.3GHz', '1.0GHz', '3.0GHz', '6.0GHz', '10.0GHz'], ['S21_PHASE', 'S21_MAGNITUDE']) diff --git a/Python_script/first_tempsweep.txt b/Python_script/first_tempsweep.txt index 9dc362c..fc6d256 100644 --- a/Python_script/first_tempsweep.txt +++ b/Python_script/first_tempsweep.txt @@ -1,2 +1,2 @@ -25 31 1 35 100 10 +20 31 1 35 100 10 -- GitLab