-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathalphasense.py
174 lines (126 loc) · 5.56 KB
/
alphasense.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
# This script contains the code for the Alphasense calibration models AS1, AS2, AS3, AS4
def formula1( we_raw, ae_raw, we_0e, ae_0e, nt, sens ):
we_raw -= we_0e
ae_raw -= ae_0e
we_raw -= nt * ae_raw
return we_raw/sens
def formula2( we_raw, ae_raw, we_0e, ae_0e, we_0t, ae_0t, kt, sens ):
we_0 = we_0t - we_0e
ae_0 = ae_0t - ae_0e
we_raw -= we_0e
ae_raw -= ae_0e
we_raw -= kt * ae_raw * (we_0 / ae_0)
return we_raw/sens
def formula3( we_raw, ae_raw, we_0e, ae_0e, we_0t, ae_0t, kt, sens ):
we_0 = we_0t - we_0e
ae_0 = ae_0t - ae_0e
we_raw -= we_0e
ae_raw -= ae_0e
we_raw -= kt * ae_raw - (we_0 - ae_0)
return we_raw/sens
def formula4( we_raw, ae_raw, we_0e, ae_0e, we_0t, ae_0t, kt, sens ):
we_0 = we_0t - we_0e
we_raw -= we_0e
ae_raw -= ae_0e
we_raw -= kt * ae_raw - we_0
return we_raw/sens
def AS1_compute( g, dataset, no2x, no2y, o3x, o3y, no2_const, o3_const ):
'''
Parameters
----------
g : object
Object of class My_Globals in globals.py that contains all the global variables
dataset : string
Name of the dataset file, for example DD1(Jun).csv
no2x : array
Electrode potentials no2op1(mV) and no2op2(mV) from the NO2 sensor
no2y : array
Reference values for NO2(ppb)
o3x : array
Electrode potentials o3op1(mV) and o3op2(mV) from the O3 sensor
o3y : array
Reference values for O3(ppb)
no2_const : array
Constants for NO2 calibration. Get these from globals.py
o3_const : array
Constants for O3 calibration. Get these from globals.py
'''
const = g.AS_const[dataset]
pred_no2 = formula1(no2x[:,0], no2x[:,1], const['NO2_WE_0E'], const['NO2_AE_0E'], no2_const[:,0], const['SENSITIVITY_NO2'])
pred_o3 = formula1(o3x[:,0], o3x[:,1], const['O3_WE_0E'], const['O3_AE_0E'], o3_const[:,0], const['SENSITIVITY_O3'])
return pred_no2, pred_o3 - pred_no2
def AS2_compute( g, dataset, no2x, no2y, o3x, o3y, no2_const, o3_const ):
'''
Parameters
----------
g : object
Object of class My_Globals in globals.py that contains all the global variables
dataset : string
Name of the dataset file, for example DD1(Jun).csv
no2x : array
Electrode potentials no2op1(mV) and no2op2(mV) from the NO2 sensor
no2y : array
Reference values for NO2(ppb)
o3x : array
Electrode potentials o3op1(mV) and o3op2(mV) from the O3 sensor
o3y : array
Reference values for O3(ppb)
no2_const : array
Constants for NO2 calibration. Get these from globals.py
o3_const : array
Constants for O3 calibration. Get these from globals.py
'''
const = g.AS_const[dataset]
pred_no2 = formula2(no2x[:,0], no2x[:,1], const['NO2_WE_0E'], const['NO2_AE_0E'], const['NO2_WE_0T'], const['NO2_AE_0T'], no2_const[:,1], const['SENSITIVITY_NO2'])
pred_o3 = formula2(o3x[:,0], o3x[:,1], const['O3_WE_0E'], const['O3_AE_0E'], const['O3_WE_0T'], const['O3_AE_0T'], o3_const[:,1], const['SENSITIVITY_O3'])
return pred_no2, pred_o3 - pred_no2
def AS3_compute( g, dataset, no2x, no2y, o3x, o3y, no2_const, o3_const ):
'''
Parameters
----------
g : object
Object of class My_Globals in globals.py that contains all the global variables
dataset : string
Name of the dataset file, for example DD1(Jun).csv
no2x : array
Electrode potentials no2op1(mV) and no2op2(mV) from the NO2 sensor
no2y : array
Reference values for NO2(ppb)
o3x : array
Electrode potentials o3op1(mV) and o3op2(mV) from the O3 sensor
o3y : array
Reference values for O3(ppb)
no2_const : array
Constants for NO2 calibration. Get these from globals.py
o3_const : array
Constants for O3 calibration. Get these from globals.py
'''
const = g.AS_const[dataset]
pred_no2 = formula3(no2x[:,0], no2x[:,1], const['NO2_WE_0E'], const['NO2_AE_0E'], const['NO2_WE_0T'], const['NO2_AE_0T'], no2_const[:,2], const['SENSITIVITY_NO2'])
pred_o3 = formula3(o3x[:,0], o3x[:,1], const['O3_WE_0E'], const['O3_AE_0E'], const['O3_WE_0T'], const['O3_AE_0T'], o3_const[:,2], const['SENSITIVITY_O3'])
return pred_no2, pred_o3 - pred_no2
def AS4_compute( g, dataset, no2x, no2y, o3x, o3y, no2_const, o3_const ):
'''
Parameters
----------
g : object
Object of class My_Globals in globals.py that contains all the global variables
dataset : string
Name of the dataset file, for example DD1(Jun).csv
no2x : array
Electrode potentials no2op1(mV) and no2op2(mV) from the NO2 sensor
no2y : array
Reference values for NO2(ppb)
o3x : array
Electrode potentials o3op1(mV) and o3op2(mV) from the O3 sensor
o3y : array
Reference values for O3(ppb)
no2_const : array
Constants for NO2 calibration. Get these from globals.py
o3_const : array
Constants for O3 calibration. Get these from globals.py
'''
const = g.AS_const[dataset]
pred_no2 = formula4(no2x[:,0], no2x[:,1], const['NO2_WE_0E'], const['NO2_AE_0E'], const['NO2_WE_0T'], const['NO2_AE_0T'], no2_const[:,3], const['SENSITIVITY_NO2'])
pred_o3 = formula4(o3x[:,0], o3x[:,1], const['O3_WE_0E'], const['O3_AE_0E'], const['O3_WE_0T'], const['O3_AE_0T'], o3_const[:,3], const['SENSITIVITY_O3'])
return pred_no2, pred_o3 - pred_no2