Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
aeri_quality_control
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
aeri
aeri_quality_control
Commits
04bbe979
Commit
04bbe979
authored
8 years ago
by
Coda Phillips
Browse files
Options
Downloads
Patches
Plain Diff
Add some tests and checks
parent
3dd58491
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
scene_checks.py
+55
-1
55 additions, 1 deletion
scene_checks.py
state_checks.py
+50
-1
50 additions, 1 deletion
state_checks.py
test.py
+31
-0
31 additions, 0 deletions
test.py
util.py
+42
-2
42 additions, 2 deletions
util.py
with
178 additions
and
4 deletions
scene_checks.py
+
55
−
1
View file @
04bbe979
from
util
import
BaseCheckList
from
util
import
BaseCheckList
,
invalidate_records
import
pandas
as
pd
import
numpy
as
np
def
hatch_check
(
frame
,
parameters
):
"""
Check that the hatch is open on sky views
"""
if
not
np
.
in1d
([
'
hatchOpen
'
,
'
sceneMirrorPosition
'
],
frame
.
columns
).
all
():
return
frame
frame
[
'
hatch_check
'
]
=
((
frame
.
hatchOpen
!=
1
)
&
(
~
frame
.
sceneMirrorPosition
.
isin
([
ord
(
'
H
'
),
ord
(
'
A
'
)])))
*
1
return
frame
def
safing_check
(
frame
,
parameters
):
"""
Check that the mirror doesn
'
t safe during a calibration view and contaminate other records
"""
if
not
np
.
in1d
([
'
hatchOpen
'
,
'
sceneMirrorPosition
'
],
frame
.
columns
).
all
():
return
frame
hatch_closing
=
((
frame
.
hatchOpen
==
1
)
&
((
frame
.
hatchOpen
==
-
3
).
diff
(
-
1
)
==
1
)).
shift
(
1
)
frame
[
'
safing_check
'
]
=
hatch_closing
&
frame
.
sceneMirrorPosition
.
isin
([
ord
(
'
H
'
),
ord
(
'
A
'
)])
frame
=
invalidate_records
(
frame
,
'
safing_check
'
)
return
frame
def
encoder_check
(
frame
,
parameters
):
return
frame
class
CheckList
(
BaseCheckList
):
checks
=
[
hatch_check
,
safing_check
,
encoder_check
]
#### TESTS #####
def
test_hatch_check
():
frame
=
pd
.
DataFrame
({
'
hatchOpen
'
:[
1
,
1
,
0
],
'
sceneMirrorPosition
'
:[
ord
(
'
H
'
),
ord
(
'
A
'
),
ord
(
'
S
'
)]
})
assert
hatch_check
(
frame
,
{})[
'
hatch_check
'
].
values
.
tolist
()
==
[
0
,
0
,
1
]
frame
=
pd
.
DataFrame
({
'
hatchOpen
'
:[
1
,
0
,
1
],
'
sceneMirrorPosition
'
:[
ord
(
'
H
'
),
ord
(
'
A
'
),
ord
(
'
S
'
)]
})
assert
hatch_check
(
frame
,
{})[
'
hatch_check
'
].
values
.
tolist
()
==
[
0
,
0
,
0
]
def
test_safing_check
():
frame
=
pd
.
DataFrame
({
'
hatchOpen
'
:[
0
,
0
,
0
],
'
sceneMirrorPosition
'
:[
ord
(
'
H
'
),
ord
(
'
A
'
),
ord
(
'
S
'
)]
})
assert
safing_check
(
frame
,
{})[
'
safing_check
'
].
values
.
tolist
()
==
[
0
,
0
,
0
]
frame
=
pd
.
DataFrame
({
'
hatchOpen
'
:[
1
,
-
3
,
0
,
0
],
'
sceneMirrorPosition
'
:[
ord
(
'
S
'
),
ord
(
'
H
'
),
ord
(
'
A
'
),
ord
(
'
S
'
)]
})
assert
safing_check
(
frame
,
{})[
'
safing_check
'
].
values
.
tolist
()
==
[
1
,
1
,
0
,
1
]
This diff is collapsed.
Click to expand it.
state_checks.py
+
50
−
1
View file @
04bbe979
from
util
import
BaseCheckList
from
util
import
BaseCheckList
,
invalidate_records
import
pandas
as
pd
import
numpy
as
np
def
detector_check
(
frame
,
parameters
):
"""
Check that the detector temp is in range
"""
if
'
detectorTemp
'
not
in
frame
.
columns
:
return
frame
frame
[
'
detector_check
'
]
=
(
frame
[
'
detectorTemp
'
]
>
90
)
*
1
frame
=
invalidate_records
(
frame
,
'
detector_check
'
)
return
frame
def
hbb_thermistor_check
(
frame
,
parameters
):
"""
Check that all HBB thermistor temps are in range
"""
if
not
np
.
in1d
([
'
HBBbottomTemp
'
,
'
HBBapexTemp
'
,
'
HBBtopTemp
'
],
frame
.
columns
).
all
():
return
frame
frame
[
'
hbb_thermistor_check
'
]
=
(
(
abs
(
frame
[
'
HBBbottomTemp
'
]
-
333
)
>
2
)
|
(
abs
(
frame
[
'
HBBapexTemp
'
]
-
333
)
>
2
)
|
(
abs
(
frame
[
'
HBBtopTemp
'
]
-
333
)
>
2
)
)
*
1
frame
=
invalidate_records
(
frame
,
'
hbb_thermistor_check
'
)
return
frame
def
hbb_stable_check
(
frame
,
parameters
):
...
...
@@ -11,3 +31,32 @@ def hbb_stable_check(frame, parameters):
class
CheckList
(
BaseCheckList
):
checks
=
[
detector_check
,
hbb_thermistor_check
,
hbb_stable_check
]
#### TESTS ####
def
test_hbb_thermistor_check
():
frame
=
hbb_thermistor_check
(
pd
.
DataFrame
({
'
HBBbottomTemp
'
:[
300
,
333
,
336
],
'
HBBapexTemp
'
:[
300
,
333
,
336
],
'
HBBtopTemp
'
:[
300
,
333
,
336
],
'
sceneMirrorPosition
'
:[
ord
(
'
H
'
),
ord
(
'
A
'
),
ord
(
'
S
'
)]
}),
{})
assert
all
(
frame
[
'
hbb_thermistor_check
'
]
==
[
1
,
0
,
1
])
def
test_hbb_thermistor_check2
():
frame
=
hbb_thermistor_check
(
pd
.
DataFrame
({
'
HBBbottomTemp
'
:[
300
,
333
,
333
],
'
HBBapexTemp
'
:[
300
,
333
,
333
],
'
HBBtopTemp
'
:[
300
,
333
,
333
],
'
sceneMirrorPosition
'
:[
ord
(
'
H
'
),
ord
(
'
A
'
),
ord
(
'
S
'
)]
}),
{})
assert
all
(
frame
[
'
hbb_thermistor_check
'
]
==
[
1
,
0
,
1
])
def
test_detector_check
():
frame
=
detector_check
(
pd
.
DataFrame
({
'
detectorTemp
'
:[
50
,
100
],
'
sceneMirrorPosition
'
:[
ord
(
'
H
'
),
ord
(
'
A
'
)]
}),
{})
assert
all
(
frame
[
'
detector_check
'
]
==
[
0
,
1
])
This diff is collapsed.
Click to expand it.
test.py
+
31
−
0
View file @
04bbe979
from
main
import
check_frame
from
util
import
invalidate_record
,
invalidate_records
import
pandas
as
pd
...
...
@@ -9,3 +10,33 @@ def test_it_works():
qc_frame
=
check_frame
(
random_dataframe
,
{})
assert
'
qc_percent
'
in
qc_frame
.
columns
print
(
qc_frame
)
def
test_invalidate_record
():
invalidated
=
invalidate_record
(
three_scenes
.
copy
(),
2
,
'
test
'
,
.
5
)
assert
invalidated
.
iloc
[
2
].
test
==
.
5
assert
pd
.
np
.
isnan
(
invalidated
.
iloc
[
3
].
test
)
assert
pd
.
np
.
isnan
(
invalidated
.
iloc
[
1
].
test
)
tricky_index
=
three_scenes
.
copy
()
tricky_index
.
index
=
tricky_index
.
index
-
1
invalidated
=
invalidate_record
(
tricky_index
,
2
,
'
test
'
,
.
5
)
assert
invalidated
.
iloc
[
2
].
test
==
.
5
,
invalidated
.
test
assert
pd
.
np
.
isnan
(
invalidated
.
iloc
[
3
].
test
)
assert
pd
.
np
.
isnan
(
invalidated
.
iloc
[
1
].
test
)
corrupt_cal
=
three_scenes
.
copy
()
invalidated
=
invalidate_record
(
corrupt_cal
,
3
,
'
test
'
,
.
5
)
assert
invalidated
.
iloc
[
2
].
test
==
.
5
,
invalidated
.
test
assert
invalidated
.
iloc
[
5
].
test
==
.
5
,
invalidated
.
test
def
test_invalidate_records
():
corrupt_cal
=
three_scenes
.
copy
()
corrupt_cal
[
'
test
'
]
=
0
corrupt_cal
[
'
test
'
][
3
]
=
1
invalidated
=
invalidate_records
(
corrupt_cal
,
'
test
'
)
assert
invalidated
.
iloc
[
2
].
test
==
1
,
invalidated
.
test
assert
invalidated
.
iloc
[
5
].
test
==
1
,
invalidated
.
test
three_scenes
=
pd
.
DataFrame
({
'
sceneMirrorPosition
'
:
list
(
map
(
ord
,
'
HASAHSAHSAH
'
))})
This diff is collapsed.
Click to expand it.
util.py
+
42
−
2
View file @
04bbe979
from
itertools
import
takewhile
import
numpy
as
np
import
pandas
as
pd
def
invalidate_record
(
frame
,
record
,
reason
):
pass
def
invalidate_records
(
frame
,
check_name
):
for
index
,
percent
in
frame
.
ix
[
frame
[
check_name
]
>
0
,
check_name
].
iteritems
():
invalidate_record
(
frame
,
index
,
check_name
,
percent
)
return
frame
def
invalidate_record
(
frame
,
index
,
check_name
,
value
):
frame
.
ix
[
frame
.
index
[
index
],
check_name
]
=
value
corrupt_view
=
frame
.
iloc
[
index
].
sceneMirrorPosition
if
corrupt_view
in
[
ord
(
'
H
'
),
ord
(
'
A
'
)]:
# Corrupt calibration view, must also invalidate neighboring scenes
_idx
=
index
+
1
while
_idx
<
len
(
frame
):
if
frame
.
sceneMirrorPosition
.
iloc
[
_idx
]
==
corrupt_view
:
# Made one cycle
break
elif
frame
.
sceneMirrorPosition
.
iloc
[
_idx
]
in
[
ord
(
'
H
'
),
ord
(
'
A
'
)]:
# Skip opposite calibration views
_idx
+=
1
continue
else
:
# Invalidate non-calibration views
frame
.
ix
[
frame
.
index
[
_idx
],
check_name
]
=
value
_idx
+=
1
_idx
=
index
-
1
while
_idx
>=
0
:
if
frame
.
sceneMirrorPosition
.
iloc
[
_idx
]
==
corrupt_view
:
# Made one cycle
break
elif
frame
.
sceneMirrorPosition
.
iloc
[
_idx
]
in
[
ord
(
'
H
'
),
ord
(
'
A
'
)]:
# Skip opposite calibration views
_idx
-=
1
continue
else
:
# Invalidate non-calibration views
frame
.
ix
[
frame
.
index
[
_idx
],
check_name
]
=
value
_idx
-=
1
return
frame
class
BaseCheckList
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment