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

Add hbb stability check

parent 96d42d97
No related branches found
No related tags found
No related merge requests found
......@@ -52,6 +52,27 @@ def hbb_thermistor_check(frame, parameters):
return frame
def hbb_stable_check(frame, parameters):
interval_seconds = frame['datetime'].diff().astype(np.int64) / 1e9
hbbb_diff = frame['HBBbottomTemp'].diff() / interval_seconds
hbba_diff = frame['HBBapexTemp'].diff() / interval_seconds
hbbt_diff = frame['HBBtopTemp'].diff() / interval_seconds
hsr = parameters.get('hbb_stable_rate', .002)
hbbb_diff_problem = abs(hbbb_diff.fillna(0)) > hsr
hbba_diff_problem = abs(hbba_diff.fillna(0)) > hsr
hbbt_diff_problem = abs(hbbt_diff.fillna(0)) > hsr
variable_qcs = pd.DataFrame({
'qc_HBBbottomTemp':hbbb_diff_problem * 1,
'qc_HBBapexTemp' : hbba_diff_problem * 1,
'qc_HBBtopTemp' : hbbt_diff_problem * 1
}, index=frame.index)
frame = update_variable_qc(frame, variable_qcs)
frame['hbb_stable_check'] = (hbbb_diff_problem | hbbt_diff_problem | hbbt_diff_problem) * 1
annotate_all(frame, hbbb_diff_problem, 'HBB bottom temperature not stable')
annotate_all(frame, hbba_diff_problem, 'HBB apex temperature not stable')
annotate_all(frame, hbbt_diff_problem, 'HBB top temperature not stable')
frame = invalidate_records(frame, 'hbb_stable_check')
return frame
class CheckList(BaseCheckList):
......@@ -60,6 +81,32 @@ class CheckList(BaseCheckList):
#### TESTS ####
def test_hbb_stable_check():
# Check with rates of .0016
dummy_data = pd.DataFrame({
'HBBbottomTemp':np.arange(0,2,.1),
'HBBapexTemp':np.arange(0,2,.1),
'HBBtopTemp':np.arange(0,2,.1),
'datetime':pd.date_range('1/1/2000', periods=20, freq='60s'),
'qc_notes':'',
'qc_percent':0,
'sceneMirrorPosition':ord('S')
})
frame = hbb_stable_check(
dummy_data, {'hbb_stable_rate':.002}
)
assert all(frame['hbb_stable_check'] == 0)
dummy_data.ix[10:,'HBBbottomTemp'] = np.arange(1,3,.2)
dummy_data.ix[10:,'HBBtopTemp'] = np.arange(1,3,.2)
dummy_data.ix[10:,'HBBbottomTemp'] = np.arange(1,3,.2)
frame = hbb_stable_check(
dummy_data, {'hbb_stable_rate':.002}
)
assert all(frame.ix[:10, 'hbb_stable_check'] == 0)
assert all(frame.ix[11:, 'hbb_stable_check'] == 1)
def test_hbb_thermistor_check():
frame = hbb_thermistor_check(pd.DataFrame({
'HBBbottomTemp':[300,333,336],
......
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