Skip to content

Commit

Permalink
Factor out spatial filter from candidates filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
taldcroft committed Dec 29, 2018
1 parent 086407e commit f334a55
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 19 deletions.
34 changes: 24 additions & 10 deletions proseco/acq.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,30 +258,44 @@ def get_obs_info(self):
'detector', 'sim_offset', 'focus_offset')
return {key: getattr(self, key) for key in keys}

def get_acq_candidates(self, stars, max_candidates=20):
"""
Get candidates for acquisition stars from ``stars`` table.
@staticmethod
def get_candidates_filter(stars):
"""Get base filter for acceptable candidates.
This allows for candidates right up to the useful part of the CCD.
The p_acq will be accordingly penalized.
This does not include spatial filtering.
:param stars: list of stars in the field
:param max_candidates: maximum candidate acq stars
:param stars: StarsTable
:returns: bool mask of acceptable stars
:returns: Table of candidates, indices of rejected stars
"""
ok = ((stars['CLASS'] == 0) &
(stars['mag'] > 5.9) &
(stars['mag'] < 11.0) &
(~np.isclose(stars['COLOR1'], 0.7)) &
(np.abs(stars['row']) < ACA.max_ccd_row) & # Max usable row
(np.abs(stars['col']) < ACA.max_ccd_col) & # Max usable col
(stars['mag_err'] < 1.0) & # Mag err < 1.0 mag
(stars['ASPQ1'] < 40) & # Less than 2 arcsec offset from nearby spoiler
(stars['ASPQ2'] == 0) & # Proper motion less than 0.5 arcsec/yr
(stars['POS_ERR'] < 3000) & # Position error < 3.0 arcsec
((stars['VAR'] == -9999) | (stars['VAR'] == 5)) # Not known to vary > 0.2 mag
)
return ok

def get_acq_candidates(self, stars, max_candidates=20):
"""
Get candidates for acquisition stars from ``stars`` table.
This allows for candidates right up to the useful part of the CCD.
The p_acq will be accordingly penalized.
:param stars: list of stars in the field
:param max_candidates: maximum candidate acq stars
:returns: Table of candidates, indices of rejected stars
"""
ok = (self.get_candidates_filter(stars) &
(np.abs(stars['row']) < ACA.max_ccd_row) & # Max usable row
(np.abs(stars['col']) < ACA.max_ccd_col) # Max usable col
)

bads = ~ok
cand_acqs = stars[ok]
Expand Down
32 changes: 23 additions & 9 deletions proseco/guide.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,27 @@ def process_include_ids(self, cand_guides, stars):

super().process_include_ids(cand_guides, stars[ok])

@staticmethod
def get_candidates_filter(stars):
"""Get base filter for acceptable candidates.
This does not include spatial filtering.
:param stars: StarsTable
:returns: bool mask of acceptable stars
"""
ok = ((stars['CLASS'] == 0) &
(stars['mag'] > 5.9) &
(stars['mag'] < 10.3) &
(stars['mag_err'] < 1.0) & # Mag err < 1.0 mag
(stars['ASPQ1'] < 20) & # Less than 1 arcsec offset from nearby spoiler
(stars['ASPQ2'] == 0) & # Proper motion less than 0.5 arcsec/yr
(stars['POS_ERR'] < 3000) & # Position error < 3.0 arcsec
((stars['VAR'] == -9999) | (stars['VAR'] == 5)) # Not known to vary > 0.2 mag
)
return ok

def get_initial_guide_candidates(self):
"""
Create a candidate list from the available stars in the field.
Expand All @@ -297,16 +318,9 @@ def get_initial_guide_candidates(self):

# Use the primary selection filter from acq, but allow bad color
# and limit to brighter stars
ok = ((stars['CLASS'] == 0) &
(stars['mag'] > 5.9) &
(stars['mag'] < 10.3) &
ok = (self.get_candidates_filter(stars) &
(np.abs(stars['row']) < ACA.max_ccd_row) & # Max usable row
(np.abs(stars['col']) < ACA.max_ccd_col) & # Max usable col
(stars['mag_err'] < 1.0) & # Mag err < 1.0 mag
(stars['ASPQ1'] < 20) & # Less than 1 arcsec offset from nearby spoiler
(stars['ASPQ2'] == 0) & # Proper motion less than 0.5 arcsec/yr
(stars['POS_ERR'] < 3000) & # Position error < 3.0 arcsec
((stars['VAR'] == -9999) | (stars['VAR'] == 5)) # Not known to vary > 0.2 mag
(np.abs(stars['col']) < ACA.max_ccd_col) # Max usable col
)

# Mark stars that are off chip
Expand Down

0 comments on commit f334a55

Please sign in to comment.