diff --git a/proseco/__init__.py b/proseco/__init__.py index bdd753b..34fa071 100644 --- a/proseco/__init__.py +++ b/proseco/__init__.py @@ -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 diff --git a/proseco/core.py b/proseco/core.py index 2b2d726..19ba8ec 100644 --- a/proseco/core.py +++ b/proseco/core.py @@ -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=[]) diff --git a/proseco/guide.py b/proseco/guide.py index 6460bb0..a67ca5d 100644 --- a/proseco/guide.py +++ b/proseco/guide.py @@ -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) diff --git a/proseco/tests/test_catalog.py b/proseco/tests/test_catalog.py index 723f52a..160b0d2 100644 --- a/proseco/tests/test_catalog.py +++ b/proseco/tests/test_catalog.py @@ -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, @@ -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, diff --git a/proseco/tests/test_guide.py b/proseco/tests/test_guide.py index dc0bd2d..d0988c7 100644 --- a/proseco/tests/test_guide.py +++ b/proseco/tests/test_guide.py @@ -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 @@ -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])