-
Notifications
You must be signed in to change notification settings - Fork 13
DM-48966: Prototype an adaptive threshold detection scheme for initial PSF modeling #446
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
Conversation
ec0e85f to
3df15ed
Compare
| _DefaultName = "adaptiveThresholdDetection" | ||
|
|
||
| def __init__(self, *args, **kwargs): | ||
| pipeBase.Task.__init__(self, *args, **kwargs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can just drop the whole __init__ definition; it's doing nothing here.
| }, | ||
| doc="Maximum number of peaks per band. If the current band for the exposure " | ||
| "is not included as a key in this dict, the value associated with the " | ||
| "\"fallback\" key will be used.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of escaping quotes, Just use single-quotes, either inside or outside. That's why Python supports both.
| pipeBase.Task.__init__(self, *args, **kwargs) | ||
|
|
||
| def run(self, table, exposure, initialThreshold=None, initialThresholdMultiplier=2.0, | ||
| doReEstimageBackgroud=True, backgroundToPhotometricRatio=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo: doReEstimageBackgroud
There's a commit on the u/jbosch/DM-48966 branch that you can probably cherry-pick to fix this.
| return brightDetectedMask | ||
|
|
||
|
|
||
| class AdaptiveThresholdDetectionConfig(Config): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we want to move this task and its config to a new module; leaving it here just increases the confusion about "dynamic" vs. "adaptive" detection. There's a commit on the u/jbosch/DM-48966 branch that you can cherry-pick to do this.
| adaptiveDetectionTask = SourceDetectionTask(config=adaptiveDetectionConfig) | ||
|
|
||
| maxNumNegFactor = 1.0 | ||
| while inAdaptiveDetection: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This loop would be better rewritten as a for loop over the maximum iteration count range, with break statements replacing inAdaptiveDetection=False assignments (I don't think you need that variable at all). This was done on the u/jbosch/DM-48966 branch, too, but only after the changes to make the task substitutable for SourceDetectionTask (which we don't want to do after all), so I'm not sure it will cherry-pick; might be better to just use it as a reference.
This aims at adaptively adjusting the detection threshold for PSF modelling such that a single pipeline run is able to accommodate a large variety of "scenes" (from sparsely populated, through very crowded fields, and possible extended nebulosity). It can be turned off (i.e. revert to previous behaviour) by setting the following configs in pipe_tasks's CalibrateImageTask: -c calibrateImage:do_adaptive_threshold_detection=False -c calibrateImage:psf_detection.reEstimateBackground=True -c calibrateImage:star_detection.reEstimateBackground=True
It may be desirable to limit selected sources to only those with a certain error budget on the centroids (e.g. for astrometric calibration sources).
Namely, allow for a minimum magnitude (maximum brightness) as well as a maximum total number of loaded reference objects. This can be useful for memory considerations, particularly for very crowded fields.
It doesn't make sense to subtract a local background from sources that were explicitly placed to represent areas of background.
This is desired for the dynamic detection (particulalry when dealing with crowded fields).
If the detection mask ends up as a single, or few many-peaked footprints, then all subsequent processing will fall over. Impose a limit to the maximum number of peaks in a given footprint for the detection mask. If this condition is not met, iteravely increase the detection threshold until it does. This is meant to be a no-op for most "typical" scenes and observing conditions, but can help avoid a total downstream meltdown in certain cases (e.g. very crowded regions).
3df15ed to
5c954e3
Compare
No description provided.