Skip to content

Commit fe95b19

Browse files
committed
Allow alphasense functions to get an arbitrary channel for NO2 cross-sensitivity correction
1 parent 01a9fd7 commit fe95b19

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

scdata/device/process/alphasense.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ def alphasense_803_04(dataframe, **kwargs):
3131
Rolling average frequency for we and ae electrodes
3232
return_all_cols: bool
3333
Return all columns intermediate to the calculation
34+
no2_channel: string
35+
Default 'NO2'
36+
Channel name for calculating 'NO2' cross-sensitivity
3437
Returns
3538
-------
3639
calculation of pollutant in ppb
@@ -76,6 +79,7 @@ def comp_t(x, comp_lut):
7679

7780
rolling_frequency = kwargs.get('rolling_frequency', None)
7881
return_all_cols = kwargs.get('return_all_cols', False)
82+
no2_channel = kwargs.get('no2_channel', 'NO2')
7983

8084
# Make copy
8185
df = dataframe.copy()
@@ -157,7 +161,7 @@ def comp_t(x, comp_lut):
157161

158162
# Verify if it has NO2 cross-sensitivity (in V)
159163
if cal_data['we_cross_sensitivity_no2_mv_ppb'] != float (0) and 'NO2' not in as_type:
160-
df['we_no2_eq'] = df['NO2'] * cal_data['we_cross_sensitivity_no2_mv_ppb'] / 1000.0
164+
df['we_no2_eq'] = df[no2_channel] * cal_data['we_cross_sensitivity_no2_mv_ppb'] / 1000.0
161165
df['we_c'] -= df['we_no2_eq'] # in V
162166

163167
# Calculate sensor concentration
@@ -222,6 +226,9 @@ def alphasense_als(dataframe, **kwargs):
222226
Roll average for we and ae electrodes with certain frequency
223227
return_all_cols: bool
224228
Return all columns intermediate to the calculation
229+
no2_channel: string
230+
Default 'NO2'
231+
Channel name for calculating 'NO2' cross-sensitivity
225232
Returns
226233
-------
227234
calculation of pollutant in ppb
@@ -268,6 +275,9 @@ def alphasense_als(dataframe, **kwargs):
268275
# Rolling
269276
rolling_frequency = kwargs.get('rolling_frequency', None)
270277

278+
# NO2 cross-sensitivity
279+
no2_channel = kwargs.get('no2_channel', 'NO2')
280+
271281
# Make copy
272282
df = dataframe.copy()
273283

@@ -383,7 +393,7 @@ def alphasense_als(dataframe, **kwargs):
383393

384394
# Verify if it has NO2 cross-sensitivity (in V)
385395
if cal_data['we_cross_sensitivity_no2_mv_ppb'] != float (0) and 'NO2' not in as_type:
386-
df['we_no2_eq'] = df['NO2'] * cal_data['we_cross_sensitivity_no2_mv_ppb'] / 1000.0
396+
df['we_no2_eq'] = df[no2_channel] * cal_data['we_cross_sensitivity_no2_mv_ppb'] / 1000.0
387397
df['we_c'] -= df['we_no2_eq'] # in V
388398

389399
# Calculate sensor concentration

0 commit comments

Comments
 (0)