-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathload_example_T1_timetrace3.py
84 lines (49 loc) · 1.32 KB
/
load_example_T1_timetrace3.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# -*- 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 ;)')
# Check the ckeys
print(d.ckeys)
# Get the axis names
label_s = []
for key in d.ckeys:
label_s.append(key)
# Extract the data
t = d[0]
PC0 = d[1]
PCp = d[2]
PCm = d[3]
ref = d[4]
# Uncertainties
ePC0 = np.sqrt(PC0)
ePCp = np.sqrt(PCp)
ePCm = np.sqrt(PCm)
eref = np.sqrt(ref)
# Get the dfferences and uncertainties
diffp = PC0-PCp
diffm = PC0-PCm
ediffp = np.sqrt(ePC0**2 + ePCp**2)
ediffm = np.sqrt(ePC0**2 + ePCm**2)
# Plot them
import matplotlib.pyplot as plt
plt.figure(tight_layout=True)
plt.errorbar(t,PC0,yerr=ePC0,label='ms0')
plt.errorbar(t,PCp,yerr=ePCp,label='ms+1')
plt.errorbar(t,PCm,yerr=ePCm,label='ms-1')
plt.errorbar(t,ref,yerr=eref,label='reference')
plt.legend()
plt.xlabel(label_s[0])
plt.ylabel('Total counts')
plt.title(d.path, fontsize=7)
plt.figure(tight_layout=True)
plt.errorbar(t,diffp,yerr=ediffp,label='Diff_+')
plt.errorbar(t,diffm,yerr=ediffm,label='Diff_-')
plt.legend()
plt.xlabel(label_s[0])
plt.ylabel('DifferenceTotal counts')
plt.title(d.path, fontsize=7)