Skip to content

Commit 23db6ec

Browse files
authored
Merge pull request #403 from sot/dyn-bgd-n-faint-default
Change dyn_bgd_n_faint default to 2 and fix faint force-include bug
2 parents 9072c82 + 0db6f1d commit 23db6ec

File tree

5 files changed

+26
-11
lines changed

5 files changed

+26
-11
lines changed

proseco/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def get_aca_catalog(*args, **kwargs):
6262
:param target_offset: (y, z) target offset including dynamical offset
6363
(2-element sequence (y, z), deg)
6464
:param dyn_bgd_n_faint: number of faint stars to apply the dynamic background
65-
temperature bonus ``dyn_bgd_dt_ccd`` (default=0)
65+
temperature bonus ``dyn_bgd_dt_ccd`` (default=2)
6666
:param dyn_bgd_dt_ccd: dynamic background T_ccd temperature bonus (default=-4.0, degC)
6767
:param stars: table of AGASC stars (will be fetched from agasc if None)
6868
:param include_ids_acq: list of AGASC IDs of stars to include in acq catalog

proseco/core.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,7 @@ class ACACatalogTable(BaseCatalogTable):
602602
sim_offset = MetaAttribute()
603603
focus_offset = MetaAttribute()
604604
target_offset = MetaAttribute(default=(0.0, 0.0))
605-
dyn_bgd_n_faint = MetaAttribute(default=0)
605+
dyn_bgd_n_faint = MetaAttribute(default=2)
606606
dyn_bgd_dt_ccd = MetaAttribute(default=-4.0)
607607
stars = MetaAttribute(pickle=False)
608608
include_ids_acq = IntListMetaAttribute(default=[])

proseco/guide.py

+11-5
Original file line numberDiff line numberDiff line change
@@ -376,26 +376,32 @@ def drop_excess_bonus_stars(self, guides):
376376
For dyn bgd with dyn_bgd_n_faint > 0, candidates fainter then the
377377
nominal faint limit can be selected. However, only at most
378378
dyn_bgd_n_faint of these bonus faint stars are allowed in the final
379-
catalog.
379+
catalog (unless more are force-included).
380380
381381
This method removes faint bonus stars (in-place within ``guides``) in
382382
excess of the allowed dyn_bgd_n_faint number. It is assumed that the
383383
catalog order is by star preference ('stage', 'mag'), so bonus stars
384384
that come first are kept.
385385
386+
Force included stars are not removed.
387+
386388
:param guides: Table of guide stars
387389
"""
388-
n_bonus = 0
389-
idx = 0
390390
# Compute the non-bonus faint_mag_limit
391391
faint_mag_limit = snr_mag_for_t_ccd(
392392
self.t_ccd, ref_mag=GUIDE.ref_faint_mag, ref_t_ccd=GUIDE.ref_faint_mag_t_ccd
393393
)
394+
n_faint = 0
394395
idxs_drop = []
395396
for idx in range(len(guides)):
396397
if guides["mag"][idx] > faint_mag_limit:
397-
n_bonus += 1
398-
if n_bonus > self.dyn_bgd_n_faint:
398+
n_faint += 1
399+
# If we have more than the allowed number of faint bonus stars
400+
# and the star is not force-included, mark it for removal.
401+
if (
402+
n_faint > self.dyn_bgd_n_faint
403+
and guides["id"][idx] not in self.include_ids
404+
):
399405
idxs_drop.append(idx)
400406
if idxs_drop:
401407
guides.remove_rows(idxs_drop)

proseco/tests/test_catalog.py

+2
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ def test_get_aca_catalog_20603_with_supplement():
6666
kwargs = dict(
6767
obsid=20603,
6868
exclude_ids_acq=[40113544],
69+
dyn_bgd_n_faint=0,
6970
n_fid=2,
7071
n_guide=6,
7172
n_acq=7,
@@ -90,6 +91,7 @@ def test_get_aca_catalog_20603(proseco_agasc_1p7):
9091
aca = get_aca_catalog(
9192
20603,
9293
exclude_ids_acq=[40113544],
94+
dyn_bgd_n_faint=0,
9395
n_fid=2,
9496
n_guide=6,
9597
n_acq=7,

proseco/tests/test_guide.py

+11-4
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,9 @@ def test_guides_include_close():
654654
# Force include the faint 4 stars that are also close together
655655
include_ids = [21, 22, 23, 24]
656656
cat2 = get_guide_catalog(
657-
**mod_std_info(n_guide=5), stars=stars, include_ids_guide=include_ids
657+
**mod_std_info(n_guide=5),
658+
stars=stars,
659+
include_ids_guide=include_ids,
658660
)
659661

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

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

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

0 commit comments

Comments
 (0)