Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove really bright stars from early stages and modify offset thresholds #254

Merged
merged 7 commits into from
Feb 19, 2019

Conversation

jeanconn
Copy link
Contributor

@jeanconn jeanconn commented Jan 30, 2019

Remove really bright stars from early stages and modify offset thresholds.

@jeanconn
Copy link
Contributor Author

I figure we have no time to test this, but just thought I'd float the idea.

@jeanconn
Copy link
Contributor Author

jeanconn commented Feb 6, 2019

This was a quick-n-dirty approach if we decided to rush it for the quick release. It might also be the most straightforward way to go for a 4.4 release, but I'm not sure if we want to do anything with setting a lower bound on mag_err for bright stars (as a code change).

Additionally, the current stages set the sigma multiplier to zero in the last two stages; it seems to me that might not be prudent in general (which I think would still allow a 5.9 mag star with mag_err 0.99 to be selected in the last stage). Changing the sigma multiplier I think could change too many catalogs (not by much, but probably not worth evaluating in detail). Thus it could make sense to set the bright limit to 6.8 (5.8 plus max allowed mag_err of 1.0) in the last two stages. That would still keep scope of the change isolated to bright stars.

@taldcroft
Copy link
Member

See the notebook proseco/mag-err-bright-stars-proseco.ipynb.

@taldcroft
Copy link
Member

From the analysis I did, I think this PR appears reasonable. The action now is to do some moderately large-scale validation to assess the impact, which is basically unknowable a-priori at least to my brain.

@jeanconn
Copy link
Contributor Author

jeanconn commented Feb 7, 2019

Thanks! After I finish with my first round review of the bright star data (with your notebook etc), I'll also see if we may want to just set SigmaMultiplier to 1 in the last stages. Will review impact of all the choices on a hopefully-sufficiently-large validation set.

proseco/guide.py Outdated Show resolved Hide resolved
# 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)
Copy link
Contributor Author

@jeanconn jeanconn Feb 8, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also figure that there's really no big issue in just bounding the effective mag_err itself for this specific check. So when combined with the stages and the SigErrMultipliers, this is effectively:

Stage 1: limit 6.2, multiplier 3, brightest possible star 6.5
Stage 2: limit 6.2, multiplier 2, brightest possible star 6.4
Stage 3: limit 6.1, multiplier 1, brightest possible star 6.2
Stage 4: limit 6.0, multiplier 1, brightest possible star 6.1
Stage 5: limit 5.9, multiplier 1, brightest possible star 6.0
Stage 6: limit 5.6, multiplier 1, brightest possible star 5.8 (the 2 multiplier applies at extreme end so this is 2 * 0.1 + 5.6

proseco/guide.py Outdated Show resolved Hide resolved
@taldcroft
Copy link
Member

I read through the comments and understand most of the words but to be honest I have no insight into what is really happening. So from the perspective of "how well should this work" you are mostly flying solo. The validation will need to be carefully thought through and presented.

@jeanconn
Copy link
Contributor Author

jeanconn commented Feb 8, 2019

Understood. Though part of the problem is that "how well should this work" validation will just show that my changes effect the change I've intended, not that the change is reasonable! For example, I'll be able to show that there are fewer aca_preview errors, but not that the catalogs are "better". Selected catalogs will be "worse" via the guide_count metric (which knows nothing about error) as bright stars will be skipped.

I could make this more complicated by penalizing bright stars more when selecting a final catalog, but I think that doesn't really win us much.

I am also considering adding more error on this bounds check to stars with color=0.7 that can be selected in the last stage. proseco.core sets the lower bound on mag_err to 0.3 for color=1.5 stars but there's nothing for color=0.7 stars.

@jeanconn jeanconn changed the base branch from 4.3.x to master February 11, 2019 03:09
@jeanconn
Copy link
Contributor Author

In validation what I see so far is, as expected, these bright stars are either bumped to later stages or not selected at all. Comparing aca_preview validation warnings as a first go test, this means a small number of ERs no longer have enough bright stars. This was also expected and I think that is acceptable and is not worth separate handling of ERs (we could for example allow these bright stars for ERs but not for ORs).

@taldcroft
Copy link
Member

@jeanconn - excellent!

@jeanconn
Copy link
Contributor Author

Not sure how big a validation set to use for final sign-off, and still want to look at how much of a hit we see in guide_count overall.

@taldcroft
Copy link
Member

taldcroft commented Feb 11, 2019

6 months is probably fine. For the first 19 years we were basically selecting right down to 5.8, right? So it's good to recognize this issue and do better when possible, but it isn't a critical from a safing perspective. At some level we just have to ask for the 1 in 50 chance where it is too bright, is the rest of the catalog good enough?

@jeanconn
Copy link
Contributor Author

jeanconn commented Feb 11, 2019

It looks like this code moves (~1 in 20) or removes (~a separate 1 in 20) a bright star in 1 in 10 catalogs. For the ones where it has been removed and the catalog isn't good enough via guide count, I had separately wondered about extending the "try a different combination of candidates" code, but will plan to finish up this PR and validation and look at that separately if there's time.

@jeanconn jeanconn changed the title Remove really bright stars from early stages Remove really bright stars from early stages and modify offset thresholds Feb 13, 2019
@jeanconn
Copy link
Contributor Author

jeanconn commented Feb 13, 2019

I made more changes at once than you will probably like in ea4fa05 @taldcroft , but I think fundamentally when we are playing with the stages it doesn't make that much sense to test independently anyway.

If you would prefer that I just bump the stage 6 to 5.8 I can go that way too... I just figured that the offsets are big effect (that plot of mag vs stage really helped me see that) and we are looking to cap them a bit anyway.

@taldcroft
Copy link
Member

Looks good!

{"Stage": 6,
"SigErrMultiplier": 0,
"ASPQ1Lim": 20,
"MagLimit": [5.6, 10.3],
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting to 5.6 is a hack that should allow stars up to 2 * 0.1 away to be selected (5.8 brightest). Not sure where to put that in comments in the config file.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why doesn't the SigErrMultiplier apply here?

Putting the comment at this line in code seems fine. I would also add a comment at the top of the stages referencing some TWiki page or section where you document all the notebooks and analysis that bears on these params.

Copy link
Contributor Author

@jeanconn jeanconn Feb 13, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regarding SigErrMultiplier, that's due to a bunch of compromises here when I thought we didn't want to let scope creep including the hacks at:

((cand_guides['mag'] - max(n_sigma, 1) * mag_err) < bright_lim) |

and

((cand_guides['mag'] - 2 * mag_err) < min(bright_lim, 5.8))

But it might make more sense to get rid of half of those compromises and not care if SigErrMultiplier is 1 for all of the later stages (which can change the spoiler status).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ugh, though if we just set SigErrMultiplier to 1 without other changes, there's also the issue that we end up with significant catalog diffs due to it not selecting faint stars (for example a 10.25 mag star with mag_err 0.06 now could be more than 1 mag_err fainter than the 10.3 limit of the stage...).

Or could just try to redo this so it makes sense.

@jeanconn
Copy link
Contributor Author

For this I'm rerunning validation with the new stages and will then review (and may tweak thresholds again based on that review). Then I think this will just need some updated tests and improved comments.

@jeanconn jeanconn self-assigned this Feb 14, 2019
In the "select stars for this stage by mag" code, these changes
1). Set a lower bound of 0.1 mags on the effective mag error of
stars brighter than 7.0 mag
2). Set a lower bound of 1 on the multiplier used with the effective
mag error.
3). Explicitly exclude stars that are within 2 sigma of 5.8
@jeanconn
Copy link
Contributor Author

From a review of the observations that had "available" bright stars between 5.8 and 6.0, it looks like these modified centroid offset thresholds still don't bring in those stars even with t_ccd_guide of 0. I think the offset thresholds could actually be more restrictive, like stage 4 = 1.5, stage 5 = 1.75 , but this is a bigger calibration effort, so my thought is to go with these PR suggestions for now.

@@ -349,7 +367,7 @@ def get_candidates_mask(self, stars):

"""
ok = ((stars['CLASS'] == 0) &
(stars['mag'] > 5.9) &
(stars['mag'] > 5.8) &
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, had this fix local but neglected to push before your approval @taldcroft .

@jeanconn
Copy link
Contributor Author

@jeanconn
Copy link
Contributor Author

And some review of just the change to the imposter thresholds of the stages

https://nbviewer.jupyter.org/url/cxc.harvard.edu/mta/ASPECT/proseco/validation-4.4/bright_star_with_offsets_PR_validation.ipynb

All looks good to and expected to me.

@taldcroft taldcroft merged commit 367fe96 into master Feb 19, 2019
@taldcroft taldcroft deleted the bright_tweak branch February 19, 2019 17:02
@taldcroft
Copy link
Member

Was this passing tests for you? I am seeing a fail now in master on test_dense_star_field_regress that appears to be from this PR. I'm not surprised that changing the bright selection would affect this catalog, but I normally expect that you would indicate if tests weren't passing.

@taldcroft
Copy link
Member

This also breaks test_imposters_on_guide in sparkles.

@taldcroft
Copy link
Member

To be clear, it doesn't appear there are any problems in the code, just tests that need adjustment because of different star selection.

@jeanconn
Copy link
Contributor Author

I thought tests were passing at some point when I rebased off 4.4 but will clean up. I had also expected to actually add some tests for this PR and #258 but will see how time goes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants