NREL / flasc

A rich floris-driven suite for SCADA analysis
https://nrel.github.io/flasc/
BSD 3-Clause "New" or "Revised" License
30 stars 18 forks source link

[BUGFIX] Fix stuck sensor detection only applying to last column #177

Closed misi9170 closed 5 months ago

misi9170 commented 6 months ago

Addresses issue raised in #175.

The stuck sensor indices were only being returned for the last column checked, as opposed to a union of the indices over all columns. This PR addresses that issue.

To do

@DanielKerrigan 's script below now produces the expected results

import pandas as pd
from flasc.turbine_analysis.find_sensor_faults import find_sensor_stuck_faults

df = pd.DataFrame({"a": [0, 0, 0, 1, 2, 3], "b": [4, 5, 6, 7, 7, 7]})

results_a = find_sensor_stuck_faults(df, columns=["a"], ti=0, plot_figures=False)
print("columns=['a']:", results_a)

results_b = find_sensor_stuck_faults(df, columns=["b"], ti=0, plot_figures=False)
print("columns=['b']:", results_b)

results_ab = find_sensor_stuck_faults(df, columns=["a", "b"], ti=0, plot_figures=False)
print("columns=['a', 'b']:", results_ab)

results_ba = find_sensor_stuck_faults(df, columns=["b", "a"], ti=0, plot_figures=False)
print("columns=['b', 'a']:", results_ba)

# Output:
# columns=['a']: [0 1 2]
# columns=['b']: [3 4 5]
# columns=['a', 'b']: [0 1 2 3 4 5]
# columns=['b', 'a']: [0 1 2 3 4 5]
misi9170 commented 5 months ago

Two of the examples (that I'm aware of) use find_stuck_sensor_faults(), called within ws_pow_filtering.py's filter_by_sensor_stuck_faults():

misi9170 commented 5 months ago

Thanks @paulf81 . I realized I hadn't pushed the changes to the examples (not to the running code, just to the notebook output), so I'll do that now and then merge.