-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BUGFIX] Fix stuck sensor detection only applying to last column (#177)
* Append index faults by column to avoid only returning last columns faults * Add test for find_sensor_stuck_faults * Ruff format. * Option for returning stuck sensors by column. * Rerun smarteole examples in case. * Rerun artificial data examples.
- Loading branch information
Showing
10 changed files
with
2,363 additions
and
2,539 deletions.
There are no files selected for viewing
348 changes: 54 additions & 294 deletions
348
examples_artificial_data/01_raw_data_processing/00_filter_ws_power_curves.ipynb
Large diffs are not rendered by default.
Oops, something went wrong.
2,402 changes: 1,204 additions & 1,198 deletions
2,402
examples_artificial_data/01_raw_data_processing/01_northing_calibration.ipynb
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
70 changes: 35 additions & 35 deletions
70
examples_smarteole/05_baseline_energy_ratio_analysis.ipynb
Large diffs are not rendered by default.
Oops, something went wrong.
100 changes: 50 additions & 50 deletions
100
examples_smarteole/06_wake_steering_energy_ratio_analysis.ipynb
Large diffs are not rendered by default.
Oops, something went wrong.
62 changes: 31 additions & 31 deletions
62
examples_smarteole/07_emgauss_scada_tuning_optimization_method.ipynb
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import numpy as np | ||
import pandas as pd | ||
|
||
from flasc.turbine_analysis.find_sensor_faults import find_sensor_stuck_faults | ||
|
||
|
||
def test_find_sensor_stuck_faults(): | ||
df_test = pd.DataFrame({"a": [0, 0, 0, 1, 2, 3, 4], "b": [4, 5, 6, 6, 7, 7, 7]}) | ||
|
||
# Test default behavior | ||
results_a = find_sensor_stuck_faults(df_test, columns=["a"], ti=0, plot_figures=False) | ||
assert (results_a == np.array([0, 1, 2])).all() | ||
|
||
results_b = find_sensor_stuck_faults(df_test, columns=["b"], ti=0, plot_figures=False) | ||
assert (results_b == np.array([4, 5, 6])).all() | ||
|
||
results_ab = find_sensor_stuck_faults(df_test, columns=["a", "b"], ti=0, plot_figures=False) | ||
assert (results_ab == np.array([0, 1, 2, 4, 5, 6])).all() | ||
|
||
results_ba = find_sensor_stuck_faults(df_test, columns=["b", "a"], ti=0, plot_figures=False) | ||
assert (results_ab == results_ba).all() | ||
|
||
results_ab2 = find_sensor_stuck_faults( | ||
df_test, columns=["a", "b"], ti=0, n_consecutive_measurements=2, plot_figures=False | ||
) | ||
assert (results_ab2 == np.array([0, 1, 2, 3, 4, 5, 6])).all() | ||
|
||
# Test returning by column | ||
results = find_sensor_stuck_faults( | ||
df_test, columns=["a", "b"], ti=0, plot_figures=False, return_by_column=True | ||
) | ||
test_dict = {"a": np.array([0, 1, 2]), "b": np.array([4, 5, 6])} | ||
assert results["a"].size == 3 | ||
assert results["b"].size == 3 | ||
assert results.keys() == test_dict.keys() | ||
assert all((results[k] == test_dict[k]).all() for k in test_dict) | ||
|
||
# Test stddev_threshold | ||
df_test = pd.DataFrame({"a": [0, 0.1, -0.1, 0.05, 1]}) | ||
std_true = np.std(df_test["a"][:-1]) | ||
|
||
results = find_sensor_stuck_faults(df_test, columns=["a"], ti=0, plot_figures=False) | ||
assert results.size == 0 # Empty array, no fault detected | ||
|
||
results = find_sensor_stuck_faults( | ||
df_test, columns=["a"], ti=0, stddev_threshold=std_true * 2, plot_figures=False | ||
) | ||
assert (results == np.array([0, 1, 2, 3])).all() |