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

DM-26862: Add focal-plane outlier rejection and focal-plane residual fits to fgcm #18

Merged
merged 13 commits into from Oct 9, 2020

Conversation

erykoff
Copy link
Collaborator

@erykoff erykoff commented Oct 1, 2020

Also fix reference star outlier rejection bugs (in that outlier reference stars were not being rejected for all computations).

if ignoreRef:
obsFlag &= ~obsFlagDict[flagName]
else:
obsFlag &= ~obsFlagDict[flagName]
Copy link

Choose a reason for hiding this comment

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

Why the if/else here? Is it correct to call this a "reset" if you are performing &=? (I'm likely missing something here since I have made no attempt to dig deeply into all the nuances of your flagging...).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've added additional comments on the meanings of the FLAGs. And the reset is done by arr &= ~flag (notice the ~ (not) there), which will set any values in arr that have a bit set to 0. It's not intuitive, but it is provable.

Copy link

Choose a reason for hiding this comment

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

Ok, cool. I'm also wondering the if/else here has any meaning (the same operation is executed in either case...flagName gets set based on the if/else ignoreRef just above).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's not quite the same operation, the ignoreRef is passed on below which leads to different numbers being processed. But point taken!

hi,=np.where(objRARad > np.pi)
objRARad[hi] -= 2*np.pi
# hi,=np.where(objRARad > np.pi)
# objRARad[hi] -= 2*np.pi
Copy link

Choose a reason for hiding this comment

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

Not the most helpful "FIXME" description 😉 (and I couldn't help but noticed you just deleted in fgcm/fgcmParameters.py).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've improved the FIXME, which is helpful for me most of all. Thanks for flagging this!

Copy link

Choose a reason for hiding this comment

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

It's future-you I'm thinking about (and maybe me if I continue to fail to resist the temptation of looking into the changes in this repo!)

@@ -177,7 +177,7 @@ def computeSuperStarFlats(self, doPlots=True, doNotUseSubCCD=False, onlyObsErr=F
# with x/y, new sub-ccd

# we will need the ccd offset signs
self._computeCCDOffsetSigns(goodObs)
# self._computeCCDOffsetSigns(goodObs)
Copy link

Choose a reason for hiding this comment

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

Delete commented out code (and the comment says you need it!)?

# If we are in the initial cycle, we can do outlier rejection now.
if self.initialCycle:
self.fgcmStars.performFocalPlaneOutlierCuts(self.fgcmPars, reset=True, ignoreRef=True)
self.fgcmStars.performFocalPlaneOutlierCuts(self.fgcmPars, reset=True, ignoreRef=False)
Copy link

Choose a reason for hiding this comment

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

I find this puzzling...why are both calls required? I suppose I'm thinking that reset implies that any flags set are being wiped out and then "reset"...so wouldn't the second call just override anything that happened in the first? My naive expectation would be that you only call this once (either ignoring reference stars or not...)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

These two calls reset and set different flags. I've improved the comments to make this clearer, but I want to make sure that if a star has a bad reference magnitude it doesn't necessarily mean that it's a bad star.

@@ -1559,6 +1563,72 @@ def performSuperStarOutlierCuts(self, fgcmPars, reset=False):
# I had considered it might be necessary to flag bad exposures
# at this point, but I don't think that's the case.

def performFocalPlaneOutlierCuts(self, fgcmPars, reset=False, ignoreRef=False):
"""
Do focal plane outlier cuts per exposure.
Copy link

Choose a reason for hiding this comment

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

Short description goes on same line as """.

I see that's pervasive (and I'm not going to insist!), but FYI from the dev guide (https://developer.lsst.io/python/numpydoc.html#basic-format-of-docstrings):

The docstring’s summary sentence occurs on the same line as the opening """.

fgcm/fgcmGray.py Outdated
pars[0, 0] = 1.0

FGrayGO = 10.**(EGrayGO / (-2.5))
FGrayErrGO = (np.log(10.) / 2.5) * np.sqrt(EGrayErr2GO) * FGrayGO
Copy link

Choose a reason for hiding this comment

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

Extra () around -2.5 and spaces between * & /.

fgcm/fgcmGray.py Outdated
fit = pars.flatten()
fit[0] = (np.sum(EGrayGO[i1a]/EGrayErr2GO[i1a]) /
np.sum(1./EGrayErr2GO[i1a]))
fit[0] = 10.**(fit[0]/(-2.5))
Copy link

Choose a reason for hiding this comment

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

Extra ()


Parameters
----------
fgcmStars : `fgcmStars`
Copy link

Choose a reason for hiding this comment

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

Did you stall out while writing documenting? 😉

@erykoff erykoff merged commit 1f68fb7 into lsst-dev Oct 9, 2020
@erykoff erykoff deleted the tickets/DM-26862 branch October 9, 2020 21:15
erykoff added a commit that referenced this pull request Sep 1, 2021
Fix the computation of E_gray with reference stars.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants