From c7434f7b80b95a3c9bf512a1ba363609eef91be5 Mon Sep 17 00:00:00 2001 From: Coda Phillips <cphillips@sean.ssec.wisc.edu> Date: Thu, 18 Aug 2016 16:20:22 -0500 Subject: [PATCH] Document electronics_checks --- electronic_checks.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/electronic_checks.py b/electronic_checks.py index 5bd1af4..b41d1f8 100644 --- a/electronic_checks.py +++ b/electronic_checks.py @@ -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: -- GitLab