Skip to content

Commit

Permalink
Update guide star selection to use include/exclude_ids
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanconn committed Dec 1, 2018
1 parent e776a9c commit 01b90e7
Showing 1 changed file with 59 additions and 23 deletions.
82 changes: 59 additions & 23 deletions proseco/guide.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@ def run_search_stages(self):
# cand_guides as the 'selected' stars.
return cand_guides
cand_guides['stage'] = -1

# Force include_id stars to be pre-selected
for include_id in self.include_ids:
cand_guides['stage'][cand_guides['id'] == include_id] = 0

n_guide = self.n_guide
for idx, stage in enumerate(GUIDE_CHAR.stages, 1):
already_selected = np.count_nonzero(cand_guides['stage'] != -1)
Expand Down Expand Up @@ -261,53 +266,84 @@ def get_initial_guide_candidates(self):
stars = self.stars
dark = self.dark

# 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) &
(np.abs(stars['row']) < CHAR.max_ccd_row) & # Max usable row
(np.abs(stars['col']) < CHAR.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
)
bare_min_cand = (
(stars['CLASS'] == 0) &
(np.abs(stars['row']) < CHAR.max_ccd_row) & # Max usable row
(np.abs(stars['col']) < CHAR.max_ccd_col)) # Max usable col

cand_guides = stars[bare_min_cand]
self.log('Filtering on CLASS, row/col')
self.log(f'Reduced star list from {len(stars)} to '
f'{len(cand_guides)} candidate guide stars')


cand_guides['force_include'] = False
for include_id in self.include_ids:
if include_id in self.exclude_ids:
raise ValueError(f'cannot include star id={include_id} that is in exclude_ids list')
if include_id not in cand_guides['id']:
raise ValueError(f'cannot include star id={include_id} that is not '
f'a valid guide star candidate in the ACA field of view')
cand_guides['force_include'][cand_guides['id'] == include_id] = True

# Mark stars that are off chip

# Mark stars that are off chip in candidates and full star list
offchip = (np.abs(stars['row']) > CCD['row_max']) | (np.abs(stars['col']) > CCD['col_max'])
stars['offchip'] = offchip
offchip = (np.abs(cand_guides['row']) > CCD['row_max']) | (np.abs(cand_guides['col']) > CCD['col_max'])
cand_guides['offchip'] = offchip

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

# Add a filter for stars that are too close to the chip edge including dither
r_dith_pad = self.dither.row
c_dith_pad = self.dither.col
row_max = CCD['row_max'] - (CCD['row_pad'] + CCD['window_pad'] + r_dith_pad)
col_max = CCD['col_max'] - (CCD['col_pad'] + CCD['window_pad'] + c_dith_pad)
outofbounds = (np.abs(stars['row']) > row_max) | (np.abs(stars['col']) > col_max)
outofbounds = (np.abs(cand_guides['row']) > row_max) | (np.abs(cand_guides['col']) > col_max)

cand_guides = stars[ok & ~outofbounds]
self.log('Filtering on CLASS, mag, row/col, '
'mag_err, ASPQ1/2, POS_ERR:')
self.log(f'Reduced star list from {len(stars)} to '

cand_guides = cand_guides[(ok & ~outofbounds) | cand_guides['force_include']]
self.log('Filtering on CLASS, mag, mag_err, ASPQ1/2, POS_ERR, out of bounds:')
self.log(f'Reduced star list from {np.count_nonzero(bare_min_cand)} to '
f'{len(cand_guides)} candidate guide stars')


bp, bp_rej = spoiled_by_bad_pixel(cand_guides, self.dither)
for rej in bp_rej:
rej['stage'] = 0
self.reject(rej)
cand_guides = cand_guides[~bp]
cand_guides = cand_guides[~bp | cand_guides['force_include']]
self.log('Filtering on candidates near bad (not just bright/hot) pixels')
self.log(f'Reduced star list from {len(bp)} to '
f'{len(cand_guides)} candidate guide stars')

for exclude_id in self.exclude_ids:
if exclude_id in cand_guides['id']:
self.reject({'id': exclude_id,
'stage': 0,
'type': 'exclude_id',
'text': f'Cut star {exclude_id} from candidates (in exclude_ids)'})
cand_guides = cand_guides[cand_guides['id'] != exclude_id]
self.log(f'Cut star {exclude_id} from candidates (in exclude_ids)')

bs = in_bad_star_list(cand_guides)
for idx in np.flatnonzero(bs):
self.reject({'id': cand_guides['id'][idx],
'stage': 0,
'type': 'bad star list',
'text': f'Cand {cand_guides["id"][idx]} in bad star list'})
cand_guides = cand_guides[~bs]
cand_guides = cand_guides[~bs | cand_guides['force_include']]
self.log('Filtering stars on bad star list')
self.log(f'Reduced star list from {len(bs)} to '
f'{len(cand_guides)} candidate guide stars')
Expand All @@ -318,7 +354,7 @@ def get_initial_guide_candidates(self):
for rej in box_rej:
rej['stage'] = 0
self.reject(rej)
cand_guides = cand_guides[~box_spoiled]
cand_guides = cand_guides[~box_spoiled | cand_guides['force_include']]
self.log('Filtering stars that have bright spoilers with centroids near/in 8x8')
self.log(f'Reduced star list from {len(box_spoiled)} to '
f'{len(cand_guides)} candidate guide stars')
Expand All @@ -328,7 +364,7 @@ def get_initial_guide_candidates(self):
for rej in fid_rej:
rej['stage'] = 0
self.reject(rej)
cand_guides = cand_guides[~fid_trap_spoilers]
cand_guides = cand_guides[~fid_trap_spoilers | cand_guides['force_include']]

# Get the brightest 2x2 in the dark map for each candidate and save value and location
imp_mag, imp_row, imp_col = get_imposter_mags(cand_guides, dark, self.dither)
Expand Down

0 comments on commit 01b90e7

Please sign in to comment.