ScarletDeblendTask, several boolean flags are set for each parent source and each deblended source. These generally follow the prescription that if deblending fails for some specific reason, a flag matching that reason is set to
True; and the flags are left
However, deblend_blendConvergenceFailedFlag has unusual behavior. If no deblended children are produced at all (either due to some pathology in deblending or because we just don’t want to deblend this source), this flag is set to
False. Otherwise, if deblending is attempted and converges (as determined by _checkBlendConvergence), the flag is set to
True, and if it fails to converge the flag is set to
This disagrees with the documentation for this flag: “at least one source in the blend failed to converge”. It would make more sense if
deblend_blendConvergenceFailedFlag was set to
True only if deblended children were produced but the model did not converge within the desired tolerance. For all other cases - either no deblending was attempted, deblending failed completely and no children were produced, or deblending succeeded and converged - it makes sense to set this flag to
This can be implemented by making one specific change here:
parent.set(self.blendConvergenceFailedFlagKey, iterations > 0 and not converged).
Flag in the name is inconsistent with all the other flags. Naming it
deblend_blendConvergenceFailed would be more consistent (and concise).