-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathanalysis_ESR.py
67 lines (44 loc) · 1.43 KB
/
analysis_ESR.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# -*- coding: utf-8 -*-
"""
Created on Wed Jul 8 07:57:17 2020
Example of how to load the saturation curve
@author: Childresslab
"""
import spinmob as sm
import numpy as np
#d = sm.data.load(text='Select saturation curve ;)')
ds = sm.data.load_multiple(text='ESR data')
# Check the ckeys
print(ds[-1].ckeys)
# Get the axis names
label_s = []
for key in ds[-1].ckeys:
label_s.append(key)
# Plot them
import matplotlib.pyplot as plt
plt.figure(tight_layout=True)
Z = [] # This will serve for a color plot
for d in ds:
fs = d[0] # Frequency in GHz
total_counts = d[1]# Total counts
etotal_counts = np.sqrt(total_counts) # uncertainty in the count. Assuming poisson
#Get the count rate in count/sec
dt = d.headers['dt_on'] # count time in us
rep = d.headers['repetition']
nb_iter = d.headers['iteration']
count_rate = total_counts*1e6/(nb_iter*rep*dt)
ecount_rate = etotal_counts*1e6/(nb_iter*rep*dt)
# Estimate the contrast
c = 100*(np.max(count_rate) - np.min(count_rate))/np.max(count_rate)
txt = (d.path.split('/')[-1] + '\nPower %.2f dBm'%d.headers['Power']+
'\n(Max-Min)/Max %.2f percent'%c)
plt.errorbar(fs,count_rate*1e-3,yerr=ecount_rate*1e-3,
label =txt)
# For the color plot
Z.append(count_rate)
plt.legend()
plt.ylabel("Kcount/sec")
plt.xlabel(label_s[0])
plt.title(d.path, fontsize=9)
plt.figure(tight_layout=True)
plt.pcolor(Z)