Skip to content

Commit e00e883

Browse files
committed
Fix power in sipm_currents
1 parent 94cd844 commit e00e883

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

smart_fact_crawler/__init__.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
from .tools import extract_run_id_from_system_status
1010
from .tools import get_entry
1111

12+
import re
13+
1214
from collections import namedtuple
1315
from functools import partial
1416

@@ -160,14 +162,26 @@ def sipm_currents(url=None, timeout=None, fallback=False):
160162
get = partial(get_entry, fallback=fallback)
161163
calibrated = get(table, 1, 1)
162164

165+
power_str = get(table, 6, 1, default='')
166+
# we expect something like 5W [4mW]
167+
match = re.match('(\d+)([a-zA-Z]+)\s*\[(\d+)([a-zA-Z]+)\]', power_str)
168+
if match is not None:
169+
cam_value, cam_unit, gapd_value, gapd_unit = match.groups()
170+
power_camera = Quantity(s2f(cam_value), cam_unit)
171+
power_gapd = Quantity(s2f(gapd_value), gapd_unit)
172+
else:
173+
power_camera = Quantity(float('nan'), 'W')
174+
power_gapd = Quantity(float('nan'), 'W')
175+
163176
return to_namedtuple('CurrentPage', {
164177
'timestamp': sft2dt(get(table, 0, 0)),
165178
'calibrated': calibrated == 'yes' if calibrated is not None else None,
166179
'min_per_sipm': Quantity(s2f(get(table, 2, 1)), 'uA'),
167180
'median_per_sipm': Quantity(s2f(get(table, 3, 1)), 'uA'),
168181
'mean_per_sipm': Quantity(s2f(get(table, 4, 1)), 'uA'),
169182
'max_per_sipm': Quantity(s2f(get(table, 5, 1)), 'uA'),
170-
'power': Quantity(s2f(get(table, 6, 1, default='')[:-1]), 'W'),
183+
'power_camera': power_camera,
184+
'power_gapd': power_gapd,
171185
})
172186

173187

0 commit comments

Comments
 (0)