diff --git a/scripts/checkPulseData.py b/scripts/checkPulseData.py index d826906..8f7eb70 100644 --- a/scripts/checkPulseData.py +++ b/scripts/checkPulseData.py @@ -61,6 +61,10 @@ return (np.all(dx <= 0) or np.all(dx >= 0)) +def max_adc(x): + return np.max(x) + + def prune(x): return [element for element in x if element is not None] @@ -190,5 +194,23 @@ # Select the instances where pulse data are monotonic monotonics = data_frame[data_frame['MPVs'].apply(is_monotonic)] - import pickle - pickle.dump(monotonics, open('monotonics.pkl', 'wb')) + if not os.path.isfile('monotonics.pkl'): + import pickle + pickle.dump(monotonics, open('monotonics.pkl', 'wb')) + + # Combine masks with the '&' operator + # (intersection in numpy), e.g.: + # data_frame[mask_highVbias(125) & mask_monotonics] + def mask_highVbias(V): + return data_frame['V bias'] > V + + def mask_lowVbias(V): + return data_frame['V bias'] < V + + def mask_highsig(ADC): + return data_frame['MPVs'].apply(max_adc) > ADC + + def mask_lowsig(ADC): + return data_frame['MPVs'].apply(max_adc) < ADC + + mask_monotonics = data_frame['MPVs'].apply(is_monotonic)