diff options
author | Blaise Thompson <blaise@untzag.com> | 2018-04-16 08:45:36 -0500 |
---|---|---|
committer | Blaise Thompson <blaise@untzag.com> | 2018-04-16 08:45:36 -0500 |
commit | 3671f4e2c92f28319e9c8e44071604e98d8d783f (patch) | |
tree | eaf532281be6a18d51587d769c59b2482c5ed0e1 /acquisition/shots_processing.py | |
parent | 1df434357600bcae9d11f20a3062cb915704979a (diff) |
2018-04-16 08:45
Diffstat (limited to 'acquisition/shots_processing.py')
-rw-r--r-- | acquisition/shots_processing.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/acquisition/shots_processing.py b/acquisition/shots_processing.py new file mode 100644 index 0000000..a112ebd --- /dev/null +++ b/acquisition/shots_processing.py @@ -0,0 +1,29 @@ +import numpy as np
+
+def process(shots, names, kinds):
+ channel_indicies = [i for i, x in enumerate(kinds) if x == 'channel']
+ out = np.full(len(channel_indicies)+1, np.nan)
+ channel_indicies.pop(0)
+ out_names = []
+ # signal diff
+ # A B C D
+ # chopper 1: - + + -
+ # chopper 2: - - + +
+ # we want A-B+C-D
+ c1 = shots[-2]
+ c2 = shots[-1]
+ a = np.mean(shots[0, (c1==-1)*(c2==-1)])
+ b = np.mean(shots[0, (c1==+1)*(c2==-1)])
+ c = np.mean(shots[0, (c1==+1)*(c2==+1)])
+ d = np.mean(shots[0, (c1==-1)*(c2==+1)])
+ out[0] = a-b+c-d
+ out_names.append('signal_diff')
+ # signal mean
+ out[1] = np.mean(shots[0])
+ out_names.append('signal_mean')
+ # others
+ for i in channel_indicies:
+ out[i+1] = np.mean(shots[i])
+ out_names.append(names[i])
+ # finish
+ return [out, out_names]
|