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-42472: Add minimum valid annulus fraction as a configuration parameter in StackBrightStarsTask #879

Merged
merged 2 commits into from
Jan 19, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 24 additions & 0 deletions python/lsst/pipe/tasks/extended_psf.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,11 @@ class StackBrightStarsConfig(Config):
doc="Magnitude limit, in Gaia G; all stars brighter than this value will be stacked",
default=18,
)
minValidAnnulusFraction = Field[float](
doc="Minimum number of valid pixels that must fall within the annulus for the bright star to be "
"included in the generation of a PSF.",
default=0.0,
)


class StackBrightStarsTask(Task):
Expand All @@ -376,6 +381,24 @@ def _set_up_stacking(self, example_stamp):
stats_flags = stringToStatisticsProperty(self.config.stacking_statistic)
return stats_control, stats_flags

def removeInvalidStamps(self, read_stars):
"""Remove stamps that do not have enough valid pixels in the annulus.

Parameters
----------
read_stars : `list` of `lsst.pipe.tasks.processBrightStars.BrightStarStamp`
List of bright star stamps to be stacked.
"""
# finding stamps that do not have enough valid pixels in the annulus
Copy link
Contributor

Choose a reason for hiding this comment

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

I would re-word this in the imperative, i.e.:

Find stamps that do not have enough valid pixels in the annulus

inValidStamps = []
Copy link
Contributor

Choose a reason for hiding this comment

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

This should just be: invalidStamps (i.e., lowercase V)

for stamp in read_stars:
if stamp.validAnnulusFraction < self.config.minValidAnnulusFraction:
inValidStamps.append(stamp)
# removing stamps that do not have enough valid pixels in the annulus
Copy link
Contributor

Choose a reason for hiding this comment

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

Similarly:

Remove stamps that do not have enough valid pixels in the annulus

if len(inValidStamps):
for inValidStamp in inValidStamps:
Copy link
Contributor

Choose a reason for hiding this comment

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

And lowercase V here also.

read_stars._stamps.remove(inValidStamp)

def run(self, bss_ref_list, region_name=None):
"""Read input bright star stamps and stack them together.

Expand Down Expand Up @@ -424,6 +447,7 @@ def run(self, bss_ref_list, region_name=None):
all_stars = None
for bss_ref in bss_ref_list:
read_stars = bss_ref.get(parameters={"bbox": bbox})
self.removeInvalidStamps(read_stars)
if self.config.do_mag_cut:
read_stars = read_stars.selectByMag(magMax=self.config.mag_limit)
if all_stars:
Expand Down