Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More dynamic background (dyn_bgd_n_faint) test fixes #218

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.2.2
rev: v0.8.0
hooks:
# Run the linter.
- id: ruff
Expand Down
17 changes: 11 additions & 6 deletions sparkles/tests/test_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,11 +364,12 @@ def test_guide_count_er5(aca_review_table):

@pytest.mark.parametrize("aca_review_table", (ACAReviewTable, ACACheckTable))
def test_guide_count_or(aca_review_table):
"""Test the check that an OR has enough fractional guide stars by guide_count"""
"""Test the check that an OR has enough fractional guide stars by guide_count.
Test uses old dyn_bgd_n_faint=0 default."""
stars = StarsTable.empty()
stars.add_fake_constellation(n_stars=5, mag=[7.0, 7.0, 10.3, 10.3, 10.3])
aca = get_aca_catalog(
**mod_std_info(n_fid=3, n_guide=5, obsid=1),
**mod_std_info(n_fid=3, n_guide=5, obsid=1, dyn_bgd_n_faint=0),
stars=stars,
dark=DARK40,
raise_exc=True,
Expand Down Expand Up @@ -426,13 +427,14 @@ def test_too_many_bright_stars(aca_review_table):
@pytest.mark.parametrize("aca_review_table", (ACAReviewTable, ACACheckTable))
def test_low_guide_count(aca_review_table):
"""Test that a 3.5 to 4.0 guide_count observation gets a critical warning
on guide_count if man_angle_next > 5 (no creep-away)."""
on guide_count if man_angle_next > 5 (no creep-away). Test uses old
dyn_bgd_n_faint=0 default."""
# Set a scenario with guide_count in the 3.5 to 4.0 range and confirm a
# critical warning.
stars = StarsTable.empty()
stars.add_fake_constellation(n_stars=5, mag=[7.0, 7.0, 7.0, 10.2, 10.3])
aca = get_aca_catalog(
**mod_std_info(n_fid=3, n_guide=5, obsid=1),
**mod_std_info(n_fid=3, n_guide=5, obsid=1, dyn_bgd_n_faint=0),
stars=stars,
dark=DARK40,
raise_exc=True,
Expand All @@ -451,14 +453,17 @@ def test_low_guide_count(aca_review_table):
@pytest.mark.parametrize("aca_review_table", (ACAReviewTable, ACACheckTable))
def test_low_guide_count_creep_away(aca_review_table):
"""Test that a 3.5 to 4.0 guide_count observation does not get a critical warning
on guide_count if man_angle_next <= 5 (creep-away)."""
on guide_count if man_angle_next <= 5 (creep-away). Test uses old dyn_bgd_n_faint=0
default."""
# Set a scenario with guide_count in the 3.5 to 4.0 range but with
# a creep away (maneuver angle <= 5), and confirm that is just a warning
# (not critical).
stars = StarsTable.empty()
stars.add_fake_constellation(n_stars=5, mag=[7.0, 7.0, 7.0, 10.2, 10.3])
aca = get_aca_catalog(
**mod_std_info(n_fid=3, n_guide=5, obsid=1, man_angle_next=5.0),
**mod_std_info(
n_fid=3, n_guide=5, obsid=1, man_angle_next=5.0, dyn_bgd_n_faint=0
),
stars=stars,
dark=DARK40,
raise_exc=True,
Expand Down
27 changes: 20 additions & 7 deletions sparkles/tests/test_review.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ def test_t_ccd_effective_message():


def test_review_catalog(proseco_agasc_1p7, tmpdir):
aca = get_aca_catalog(**KWARGS_48464)
"""Test review process and roll options work on reference obsid from KWARGS_48464.
Uses old dyn_bgd_n_faint=0 default."""
aca = get_aca_catalog(**KWARGS_48464, dyn_bgd_n_faint=0)
acar = aca.get_review_table()
acar.run_aca_review()
assert acar.messages == [
Expand Down Expand Up @@ -268,6 +270,8 @@ def test_uniform_roll_options(proseco_agasc_1p7):
the 'uniq_ids' algorithm and falling through to a 'uniform' search.

See https://github.com/sot/sparkles/issues/138 for context.

Test uses old dyn_bgd_n_faint=0 default.
"""
kwargs = {
"att": [-0.25019352, -0.90540872, -0.21768747, 0.26504794],
Expand All @@ -284,7 +288,7 @@ def test_uniform_roll_options(proseco_agasc_1p7):
"t_ccd_guide": -9.8,
}

aca = get_aca_catalog(**kwargs)
aca = get_aca_catalog(**kwargs, dyn_bgd_n_faint=0)
acar = aca.get_review_table()
acar.run_aca_review(
roll_level="critical", roll_args={"max_roll_dev": 2.5, "d_roll": 0.25}
Expand Down Expand Up @@ -329,7 +333,9 @@ def test_catch_exception_from_method():


def test_run_aca_review_function(proseco_agasc_1p7, tmpdir):
aca = get_aca_catalog(**KWARGS_48464)
"""Test the run_aca_review function. Test uses old dyn_bgd_n_faint=0 default."""

aca = get_aca_catalog(**KWARGS_48464, dyn_bgd_n_faint=0)
acar = aca.get_review_table()
acars = [acar]

Expand Down Expand Up @@ -372,24 +378,31 @@ def test_run_aca_review_dyn_bgd_n_faint(proseco_agasc_1p7, tmpdir):

assert exc is None
assert acar.dyn_bgd_n_faint == 2
assert np.isclose(acar.guide_count, 5, atol=0.1)
assert np.isclose(acar.guide_count, 6.7, atol=0.1)

# Assert same warnings as test_run_aca_review_function but with a different
# guide count and new info message
assert acar.messages == [
{"text": "Using dyn_bgd_n_faint=2 (call_args val=0)", "category": "info"},
{
"category": "warning",
"text": "Guide star imposter offset 2.6, limit 2.5 arcsec",
"idx": 4,
},
{
"category": "warning",
"text": "Guide star imposter offset 2.7, limit 2.5 arcsec",
"idx": 6,
},
{
"category": "warning",
"text": "Guide star imposter offset 2.7, limit 2.5 arcsec",
"idx": 8,
},
{"category": "warning", "text": "P2: 3.33 less than 4.0 for ER"},
{
"category": "critical",
"text": "ER count of 9th (8.9 for -9.9C) mag guide stars 1.91 < 3.0",
},
{"category": "critical", "text": "ER count of guide stars 5.00 < 6.0"},
{"category": "caution", "text": "ER with 5 guides but 8 were requested"},
]


Expand Down