Skip to content

Commit

Permalink
Merge pull request #254 from sot/bright_tweak
Browse files Browse the repository at this point in the history
Remove really bright stars from early stages and modify offset thresholds
  • Loading branch information
taldcroft authored Feb 19, 2019
2 parents 69c7f5e + 1f2196b commit 367fe96
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 11 deletions.
25 changes: 19 additions & 6 deletions proseco/characteristics_guide.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
stages = [{"Stage": 1,
"SigErrMultiplier": 3,
"ASPQ1Lim": 0,
"MagLimit": [5.9, 10.2],
"MagLimit": [6.2, 10.2],
"DoBminusVcheck": 1,
"Spoiler": {
"BgPixThresh": 25,
Expand All @@ -53,7 +53,7 @@
{"Stage": 2,
"SigErrMultiplier": 2,
"ASPQ1Lim": 0,
"MagLimit": [5.9, 10.2],
"MagLimit": [6.2, 10.2],
"DoBminusVcheck": 1,
"Spoiler": {
"BgPixThresh": 25,
Expand All @@ -65,7 +65,7 @@
{"Stage": 3,
"SigErrMultiplier": 1,
"ASPQ1Lim": 10,
"MagLimit": [5.9, 10.3],
"MagLimit": [6.1, 10.3],
"DoBminusVcheck": 1,
"Spoiler": {
"BgPixThresh": 25,
Expand All @@ -77,14 +77,14 @@
{"Stage": 4,
"SigErrMultiplier": 0,
"ASPQ1Lim": 20,
"MagLimit": [5.9, 10.3],
"MagLimit": [6.0, 10.3],
"DoBminusVcheck": 1,
"Spoiler": {
"BgPixThresh": 25,
"RegionFrac": .05,
},
"Imposter": {
"CentroidOffsetLim": 2.5,
"CentroidOffsetLim": 2.0,
}},
{"Stage": 5,
"SigErrMultiplier": 0,
Expand All @@ -96,12 +96,25 @@
"RegionFrac": .05,
},
"Imposter": {
"CentroidOffsetLim": 4.5,
"CentroidOffsetLim": 3.5,
}},
{"Stage": 6,
"SigErrMultiplier": 0,
"ASPQ1Lim": 20,
"MagLimit": [5.6, 10.3],
"DoBminusVcheck": 0,
"Spoiler": {
"BgPixThresh": 25,
"RegionFrac": .05,
},
"Imposter": {
"CentroidOffsetLim": 4.0,
},
}
]



# Guide cluster checks.
# Index is the "n_minus" value, so n - 0 stars need minimum 2500 max separation
# n - 1 stars require 1000 arcsec separation.
Expand Down
28 changes: 23 additions & 5 deletions proseco/guide.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,20 +234,38 @@ def search_stage(self, stage):

n_sigma = stage['SigErrMultiplier']

# And for bright stars, use a local mag_err that is lower bounded at 0.1
# for the mag selection.
mag_err = cand_guides['mag_err']
bright = cand_guides['mag'] < 7.0
mag_err[bright] = mag_err[bright].clip(0.1)
# Also set any color=0.7 stars to have lower bound mag err of 0.5
bad_color = np.isclose(cand_guides['COLOR1'], 0.7)
mag_err[bad_color] = mag_err[bad_color].clip(0.5)

# Check reasonable mag
bright_lim = stage['MagLimit'][0]
faint_lim = stage['MagLimit'][1]
bad_mag = (((cand_guides['mag'] - n_sigma * cand_guides['mag_err']) < bright_lim) |
((cand_guides['mag'] + n_sigma * cand_guides['mag_err']) > faint_lim))
# Confirm that the star mag is not outside the limits when padded by error.
# For the bright end of the check, set a lower bound to always use at least 1
# mag_err, but do not bother with this bound at the faint end of the check.
# Also explicitly confirm that the star is not within 2 * mag_err of the hard
# bright limit (which is basically 5.8, but if bright lim set to less than 5.8
# in the stage, take that).
bad_mag = (
((cand_guides['mag'] - max(n_sigma, 1) * mag_err) < bright_lim) |
((cand_guides['mag'] + n_sigma * mag_err) > faint_lim) |
((cand_guides['mag'] - 2 * mag_err) < min(bright_lim, 5.8)))
for idx in np.flatnonzero(bad_mag):
self.reject({'id': cand_guides['id'][idx],
'type': 'mag outside range',
'stage': stage['Stage'],
'bright_lim': bright_lim,
'faint_lim': faint_lim,
'cand_mag': cand_guides['mag'][idx],
'cand_mag_err_times_sigma': n_sigma * cand_guides['mag_err'][idx],
'text': f'Cand {cand_guides["id"][idx]} rejected with mag outside range for stage'})
'cand_mag_err_times_sigma': n_sigma * mag_err[idx],
'text': (f'Cand {cand_guides["id"][idx]} rejected with '
'mag outside range for stage')})
cand_guides[scol][bad_mag] += GUIDE.errs['mag range']
ok = ok & ~bad_mag

Expand Down Expand Up @@ -349,7 +367,7 @@ def get_candidates_mask(self, stars):
"""
ok = ((stars['CLASS'] == 0) &
(stars['mag'] > 5.9) &
(stars['mag'] > 5.8) &
(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
Expand Down

0 comments on commit 367fe96

Please sign in to comment.