Skip to content

Commit

Permalink
Merge pull request #403 from sot/dyn-bgd-n-faint-default
Browse files Browse the repository at this point in the history
Change dyn_bgd_n_faint default to 2 and fix faint force-include bug
  • Loading branch information
jeanconn authored Nov 1, 2024
2 parents 9072c82 + 0db6f1d commit 23db6ec
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 11 deletions.
2 changes: 1 addition & 1 deletion proseco/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def get_aca_catalog(*args, **kwargs):
:param target_offset: (y, z) target offset including dynamical offset
(2-element sequence (y, z), deg)
:param dyn_bgd_n_faint: number of faint stars to apply the dynamic background
temperature bonus ``dyn_bgd_dt_ccd`` (default=0)
temperature bonus ``dyn_bgd_dt_ccd`` (default=2)
:param dyn_bgd_dt_ccd: dynamic background T_ccd temperature bonus (default=-4.0, degC)
:param stars: table of AGASC stars (will be fetched from agasc if None)
:param include_ids_acq: list of AGASC IDs of stars to include in acq catalog
Expand Down
2 changes: 1 addition & 1 deletion proseco/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ class ACACatalogTable(BaseCatalogTable):
sim_offset = MetaAttribute()
focus_offset = MetaAttribute()
target_offset = MetaAttribute(default=(0.0, 0.0))
dyn_bgd_n_faint = MetaAttribute(default=0)
dyn_bgd_n_faint = MetaAttribute(default=2)
dyn_bgd_dt_ccd = MetaAttribute(default=-4.0)
stars = MetaAttribute(pickle=False)
include_ids_acq = IntListMetaAttribute(default=[])
Expand Down
16 changes: 11 additions & 5 deletions proseco/guide.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,26 +376,32 @@ def drop_excess_bonus_stars(self, guides):
For dyn bgd with dyn_bgd_n_faint > 0, candidates fainter then the
nominal faint limit can be selected. However, only at most
dyn_bgd_n_faint of these bonus faint stars are allowed in the final
catalog.
catalog (unless more are force-included).
This method removes faint bonus stars (in-place within ``guides``) in
excess of the allowed dyn_bgd_n_faint number. It is assumed that the
catalog order is by star preference ('stage', 'mag'), so bonus stars
that come first are kept.
Force included stars are not removed.
:param guides: Table of guide stars
"""
n_bonus = 0
idx = 0
# Compute the non-bonus faint_mag_limit
faint_mag_limit = snr_mag_for_t_ccd(
self.t_ccd, ref_mag=GUIDE.ref_faint_mag, ref_t_ccd=GUIDE.ref_faint_mag_t_ccd
)
n_faint = 0
idxs_drop = []
for idx in range(len(guides)):
if guides["mag"][idx] > faint_mag_limit:
n_bonus += 1
if n_bonus > self.dyn_bgd_n_faint:
n_faint += 1
# If we have more than the allowed number of faint bonus stars
# and the star is not force-included, mark it for removal.
if (
n_faint > self.dyn_bgd_n_faint
and guides["id"][idx] not in self.include_ids
):
idxs_drop.append(idx)
if idxs_drop:
guides.remove_rows(idxs_drop)
Expand Down
2 changes: 2 additions & 0 deletions proseco/tests/test_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ def test_get_aca_catalog_20603_with_supplement():
kwargs = dict(
obsid=20603,
exclude_ids_acq=[40113544],
dyn_bgd_n_faint=0,
n_fid=2,
n_guide=6,
n_acq=7,
Expand All @@ -90,6 +91,7 @@ def test_get_aca_catalog_20603(proseco_agasc_1p7):
aca = get_aca_catalog(
20603,
exclude_ids_acq=[40113544],
dyn_bgd_n_faint=0,
n_fid=2,
n_guide=6,
n_acq=7,
Expand Down
15 changes: 11 additions & 4 deletions proseco/tests/test_guide.py
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,9 @@ def test_guides_include_close():
# Force include the faint 4 stars that are also close together
include_ids = [21, 22, 23, 24]
cat2 = get_guide_catalog(
**mod_std_info(n_guide=5), stars=stars, include_ids_guide=include_ids
**mod_std_info(n_guide=5),
stars=stars,
include_ids_guide=include_ids,
)

# Run the cluster checks and confirm all 3 fail
Expand Down Expand Up @@ -785,14 +787,19 @@ def test_guide_faint_mag_limit():
mag=[7.0] * 4 + [GUIDE.ref_faint_mag - 0.001], n_stars=5, id=ids
)

# Select stars at 0.1 degC colder than reference temperature, expect 5 stars selected
# Select stars at 0.1 degC colder than reference temperature, use previous default of
# dyn_bgd_n_faint=0 for this test, expect 5 stars selected
guides = get_guide_catalog(
**mod_std_info(t_ccd=GUIDE.ref_faint_mag_t_ccd - 0.1), stars=stars, dark=DARK40
**mod_std_info(t_ccd=GUIDE.ref_faint_mag_t_ccd - 0.1, dyn_bgd_n_faint=0),
stars=stars,
dark=DARK40,
)
assert np.all(guides["id"] == ids)

# Select stars at 0.1 degC warmer than reference temperature, expect 4 stars selected
guides = get_guide_catalog(
**mod_std_info(t_ccd=GUIDE.ref_faint_mag_t_ccd + 0.1), stars=stars, dark=DARK40
**mod_std_info(t_ccd=GUIDE.ref_faint_mag_t_ccd + 0.1, dyn_bgd_n_faint=0),
stars=stars,
dark=DARK40,
)
assert np.all(guides["id"] == [1, 2, 3, 4])

0 comments on commit 23db6ec

Please sign in to comment.