-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
79 additions
and
6 deletions.
There are no files selected for viewing
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
9 changes: 9 additions & 0 deletions
9
tests/inputs/bad_bpms/LHCB1/Measurements/example/bad_bpms_iforest_x.tfs
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,9 @@ | ||
* NAME FEATURE VALUE AVG SCORE | ||
$ %s %s %le %le %le | ||
BPM.20R5.B1 AMPX 0.2739793273915 0.1983870023371 -0.08321628370052 | ||
BPM.22R5.B1 AMPX 0.1645414911027 0.1983870023371 -0.1192688174725 | ||
BPM.34R7.B1 AMPX 0.1608806519601 0.1983870023371 -0.1121605330153 | ||
BPM.27R8.B1 AMPX 0.1164325835062 0.1983870023371 -0.08355632185117 | ||
BPMS.2L5.B1 NOISE_SCALED 0.0006165859078803 0.0009016042719894 -0.1390448828672 | ||
BPMW.5L7.B1 AMPX 0.1645414911027 0.2062029479469 -0.2122963397363 | ||
BPMSW.1L8.B1 NOISE_SCALED 0.001344342784781 0.0009016042719894 -0.1248972948542 |
9 changes: 9 additions & 0 deletions
9
tests/inputs/bad_bpms/LHCB1/Measurements/example/bad_bpms_iforest_y.tfs
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,9 @@ | ||
* NAME FEATURE VALUE AVG SCORE | ||
$ %s %s %le %le %le | ||
BPM.34R2.B1 AMPY 0.1684687445507 0.2816166477169 -0.07696353786083 | ||
BPM.28R3.B1 AMPY 0.2274634866394 0.2816166477169 -0.07844693271801 | ||
BPM.15R7.B1 AMPY 0.1987839789693 0.2816166477169 -0.08603128649899 | ||
BPM.19L8.B1 NOISE_SCALED 0.000701003563438 0.0006483937620229 -0.120787110444 | ||
BPMWI.4L2.B1 NOISE_SCALED 0.001066794573165 0.000649595233316 -0.1719495412989 | ||
BPMS.2R5.B1 NOISE_SCALED 0.0007888325396217 0.000649595233316 -0.1308678268808 | ||
BPMS.2R1.B1 TUNEY 0.3219851293843 0.3219858241878 -0.13606497737 |
4 changes: 4 additions & 0 deletions
4
tests/inputs/bad_bpms/LHCB1/Measurements/example/example.sdds.bad_bpms_x
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,4 @@ | ||
BPMSI.A4R6.B1 not found in model | ||
BPMSI.B4R6.B1 not found in model | ||
BPMSE.4L6.B1 Spiky BPM, found spike higher than 20.0 | ||
BPMSX.4L8.B1 Detected from SVD, single peak value is greater then 0.925 |
8 changes: 8 additions & 0 deletions
8
tests/inputs/bad_bpms/LHCB1/Measurements/example/example.sdds.bad_bpms_y
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,8 @@ | ||
BPMSI.A4R6.B1 not found in model | ||
BPMSI.B4R6.B1 not found in model | ||
BPM.31L5.B1 Flat BPM, the difference between min/max is smaller than 1e-05 | ||
BPMSX.A4L6.B1 Flat BPM, the difference between min/max is smaller than 1e-05 | ||
BPM.31L5.B1 Found an exact zero | ||
BPMSX.A4L6.B1 Found an exact zero | ||
BPMSE.4L6.B1 Detected from SVD, single peak value is greater then 0.925 | ||
BPMWI.A5L4.B1 Detected from SVD, single peak value is greater then 0.925 |
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,41 @@ | ||
import pytest | ||
import tfs | ||
|
||
from tests.conftest import INPUTS, assert_tfsdataframe_equal | ||
from omc3.scripts.bad_bpms_summary import NAME, SOURCE, bad_bpms_summary, IFOREST, HARPY | ||
import logging | ||
|
||
|
||
@pytest.mark.extended | ||
def test_bad_bpms_summary(tmp_path, caplog): | ||
|
||
outfile = tmp_path / "bad_bpms_summary.tfs" | ||
with caplog.at_level(logging.INFO): | ||
df_eval = bad_bpms_summary( | ||
root=INPUTS, | ||
outfile=outfile, | ||
dates=["bad_bpms"], | ||
accel_glob="LHCB1", | ||
print_percentage=50, | ||
) | ||
|
||
# Test Data has been written | ||
assert df_eval is not None | ||
assert_tfsdataframe_equal(df_eval, tfs.read(outfile)) | ||
|
||
# Test some random BPMs | ||
not_in_model = ["BPMSI.A4R6.B1", ] | ||
for bpm in not_in_model: | ||
assert bpm not in df_eval[NAME].tolist() | ||
|
||
iforest_bpms = ["BPM.27R8.B1", "BPMS.2R1.B1"] | ||
df_iforest = df_eval[df_eval[SOURCE] == IFOREST] | ||
for bpm in iforest_bpms: | ||
assert bpm in df_iforest[NAME].tolist() | ||
assert bpm in caplog.text | ||
|
||
harpy_bpms = ["BPMSE.4L6.B1", "BPM.31L5.B1"] | ||
df_harpy = df_eval[df_eval[SOURCE] == HARPY] | ||
for bpm in harpy_bpms: | ||
assert bpm in df_harpy[NAME].tolist() | ||
assert bpm in caplog.text |