Skip to content

Commit

Permalink
fix maude_decom.filter_vcdu_jumps to handle VCDU rollover (and added …
Browse files Browse the repository at this point in the history
…test case)
  • Loading branch information
javierggt committed Dec 11, 2023
1 parent c9cd3d1 commit bcd2671
Show file tree
Hide file tree
Showing 2 changed files with 212 additions and 1 deletion.
9 changes: 8 additions & 1 deletion chandra_aca/maude_decom.py
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,14 @@ def filter_vcdu_jumps(vcdu_counters):
last_frame = -1 # for monotonicity check
selected = np.zeros(len(vcdu_counters), dtype=bool)
for i, vcdu_counter in enumerate(vcdu_counters):
if last_frame >= vcdu_counter:
# major frame counter rolls over at 2**17, and minor counter at 2**7
# The VCDU counter (which includes both) rolls over at 2**24 (16777216).
# The VCDU counter must increase or roll over (in which case it jumps by a large negative
# number) In the worse case, it rolls over _and_ 3600*4 frames are missing
if not (
last_frame < vcdu_counter
or (vcdu_counter - last_frame) <= -(16777215 - 3600 * 4)
):
last_frame = vcdu_counter
continue
last_frame = vcdu_counter
Expand Down
204 changes: 204 additions & 0 deletions chandra_aca/tests/test_maude_decom.py
Original file line number Diff line number Diff line change
Expand Up @@ -841,6 +841,210 @@ def test_filter_vcdu_jumps():
"inp": np.array([0, 1, 2, 3, 4, 5, 6, 7]),
"exp": np.array([0, 1, 2, 3, 4, 5, 6, 7]),
},
# VCDU roll over
{
"inp": np.array(
[
16777204,
16777205,
16777206,
16777207,
16777208,
16777209,
16777210,
16777211,
16777212,
16777213,
16777214,
16777215,
0,
1,
2,
3,
4,
5,
6,
7,
]
),
"exp": np.array(
[
16777204,
16777205,
16777206,
16777207,
16777208,
16777209,
16777210,
16777211,
16777212,
16777213,
16777214,
16777215,
0,
1,
2,
3,
4,
5,
6,
7,
]
),
},
# VCDU roll over and missing VCDUs
{
"inp": np.array(
[
16777204,
16777205,
16777206,
16777207,
16777208,
16777209,
16777210,
16777211,
16777212,
16777213,
16777214,
16777215,
14400,
14401,
14402,
14403,
14404,
14405,
14406,
14407,
]
),
"exp": np.array(
[
16777204,
16777205,
16777206,
16777207,
16777208,
16777209,
16777210,
16777211,
16777212,
16777213,
16777214,
16777215,
14400,
14401,
14402,
14403,
14404,
14405,
14406,
14407,
]
),
},
# VCDU roll over and missing VCDUs
{
"inp": np.array(
[
16762804,
16762805,
16762806,
16762807,
16762808,
16762809,
16762810,
16762811,
16762812,
16762813,
16762814,
16762815,
0,
1,
2,
3,
4,
5,
6,
7,
]
),
"exp": np.array(
[
16762804,
16762805,
16762806,
16762807,
16762808,
16762809,
16762810,
16762811,
16762812,
16762813,
16762814,
16762815,
0,
1,
2,
3,
4,
5,
6,
7,
]
),
},
# VCDU roll over and missing VCDUs
{
"inp": np.array(
[
16770004,
16770005,
16770006,
16770007,
16770008,
16770009,
16770010,
16770011,
16770012,
16770013,
16770014,
16770015,
7200,
7201,
7202,
7203,
7204,
7205,
7206,
7207,
]
),
"exp": np.array(
[
16770004,
16770005,
16770006,
16770007,
16770008,
16770009,
16770010,
16770011,
16770012,
16770013,
16770014,
16770015,
7200,
7201,
7202,
7203,
7204,
7205,
7206,
7207,
]
),
},
]

for case in filter_vcdu_test_cases:
Expand Down

0 comments on commit bcd2671

Please sign in to comment.