Skip to content
Snippets Groups Projects
Commit c7434f7b authored by Coda Phillips's avatar Coda Phillips
Browse files

Document electronics_checks

parent dd759ba6
No related branches found
No related tags found
No related merge requests found
......@@ -6,18 +6,19 @@ import itertools
electronic_checks = BaseCheckList()
def find_bb_outliers(frame, parameters, bb):
"""
Find outliers in blackbody temperatures.
Annotate any problems, and set quality flags for each thermistor
"""
window_length = parameters.get('window_length', 50)
if bb == 'HBB':
delta_thresh = .001
bbb_outliers = np.array(list(_scan_for_outliers(frame, '{}bottomTemp'.format(bb), delta_thresh)))
bba_outliers = np.array(list(_scan_for_outliers(frame, '{}apexTemp'.format(bb), delta_thresh)))
bbt_outliers = np.array(list(_scan_for_outliers(frame, '{}topTemp'.format(bb), delta_thresh)))
else:
delta_thresh = .01
bbb_outliers = np.array(list(_scan_for_outliers(frame, '{}bottomTemp'.format(bb), delta_thresh)))
bba_outliers = np.array(list(_scan_for_outliers(frame, '{}apexTemp'.format(bb), delta_thresh)))
bbt_outliers = np.array(list(_scan_for_outliers(frame, '{}topTemp'.format(bb), delta_thresh)))
bbb_outliers = np.array(list(_scan_for_outliers(frame, '{}bottomTemp'.format(bb), delta_thresh)))
bba_outliers = np.array(list(_scan_for_outliers(frame, '{}apexTemp'.format(bb), delta_thresh)))
bbt_outliers = np.array(list(_scan_for_outliers(frame, '{}topTemp'.format(bb), delta_thresh)))
variable_qcs = pd.DataFrame({
'qc_{}bottomTemp'.format(bb) : bbb_outliers * 1,
......@@ -53,12 +54,17 @@ def _find_6sigma_outliers(frame, window_length, estimation_func=_compute_robust_
return estimation_func(frame, window_length) > 6
def _scan_for_outliers(frame, variable, delta_thresh):
"""
Check for temperature changes exceeding the delta_thresh rate in degK / sec
"""
last = None
for i, row in frame.iterrows():
# First row cannot be an outlier
if last is None:
yield False
last = row
else:
# Compare each row to previous non-outlier row
time_diff = (row.datetime - last.datetime).total_seconds()
variable_diff = row[variable] - last[variable]
if abs(variable_diff / time_diff) < delta_thresh:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment