Skip to content

DM-52156: Add defect reason extension to defects#436

Open
czwa wants to merge 7 commits intomainfrom
tickets/DM-52156
Open

DM-52156: Add defect reason extension to defects#436
czwa wants to merge 7 commits intomainfrom
tickets/DM-52156

Conversation

@czwa
Copy link
Copy Markdown
Contributor

@czwa czwa commented Nov 11, 2025

No description provided.

@czwa czwa requested a review from erykoff November 11, 2025 21:08
Comment thread python/lsst/ip/isr/defects.py Outdated
self._defects.append(self._check_value(value))
self._normalize()
if reason:
self._defectsUnnormalized.append((self._check_value(value), reason))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If no reason is given then they don't go into the unnormalized defects? Maybe it should default to reason UNKNOWN or something?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

So a defectsUnnormalized is a tuple? I think that is potentially confusing. Is it possible to define a DefectWithReason here ... or maybe a continueClass in meas_algorithms to extend Defect ... https://github.com/lsst/meas_algorithms/blob/main/python/lsst/meas/algorithms/interp.py. This could give a .reason attribute that defaults to either "UNKNOWN" or None; otherwise behaves like a defect (with a bbox) which will simplify things.
Thinking this through I think that a new DefectWithReason type class may be appropriate, could be here or in meas_algorithms.

Comment thread python/lsst/ip/isr/defects.py Outdated

return values[:n]

def getReasonDict(self):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I would prefer if there were too methods here ... getReasonToBitMapping() and getBitToReasonMapping() or something like that?
Also this doesn't have a docstring.

Comment thread tests/test_defects.py Outdated
# Tests masking with reason is working properly
ccdImage = afwImage.MaskedImageF(250, 225)
# test 1. test mask according to a given reason
reason = 'HOT_PIXEL'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we have a standard list of defect reasons we want to define? And should they be HOT or HOT_PIXEL (isn't pixel implied?)

Comment thread tests/test_defects.py Outdated
with self.assertRaises(RuntimeError):
defects.maskPixelsReason(ccdImage.mask, reason)

# test 2. test mask plane with reasons is set properly
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What's the story here?

aferte added 7 commits April 6, 2026 13:56
Some notes.

Support defect reason and masking helper.

Add check defects unnormalized are existent.

Add unit test defects reason.

Support definition of mask plane by reason.

Linting.

Add unit test.

Comment out reason per mask plane.

Add followup ticket number.
@aferte aferte force-pushed the tickets/DM-52156 branch from 9334827 to dbd852b Compare April 6, 2026 21:32
@aferte aferte requested a review from erykoff April 6, 2026 21:33
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.

3 participants