Skip to content

DM-51156: Add max pixel value when psf candidate is done. #1138

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion python/lsst/pipe/tasks/calibrateImage.py
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,11 @@ def __init__(self, initial_stars_schema=None, **kwargs):
self.makeSubtask("psf_repair")
self.makeSubtask("psf_subtract_background")
self.psf_schema = afwTable.SourceTable.makeMinimalSchema()
self.psf_schema.addField(
'psf_max_value',
type=np.float32,
doc="PSF max value.",
)
afwTable.CoordKey.addErrorFields(self.psf_schema)
self.makeSubtask("psf_detection", schema=self.psf_schema)
self.makeSubtask("psf_source_measurement", schema=self.psf_schema)
Expand All @@ -607,14 +612,18 @@ def __init__(self, initial_stars_schema=None, **kwargs):
"calib_astrometry_used",
# TODO DM-39203: these can be removed once apcorr is gone.
"apcorr_slot_CalibFlux_used", "apcorr_base_GaussianFlux_used",
"apcorr_base_PsfFlux_used")
"apcorr_base_PsfFlux_used",)
for field in self.psf_fields:
item = self.psf_schema.find(field)
initial_stars_schema.addField(item.getField())
id_type = self.psf_schema["id"].asField().getTypeString()
psfmaxvaluetype = self.psf_schema['psf_max_value'].asField().getTypeString()
initial_stars_schema.addField("psf_id",
type=id_type,
doc="id of this source in psf_stars; 0 if there is no match.")
initial_stars_schema.addField("psf_max_value",
type=psfmaxvaluetype,
doc="PSF max value.")

afwTable.CoordKey.addErrorFields(initial_stars_schema)
self.makeSubtask("star_detection", schema=initial_stars_schema)
Expand Down Expand Up @@ -1242,6 +1251,7 @@ def _match_psf_stars(self, psf_stars, stars):
result[idx_stars] = psf_stars[field][idx_psf_stars]
stars[field] = result
stars['psf_id'][idx_stars] = psf_stars['id'][idx_psf_stars]
stars['psf_max_value'][idx_stars] = psf_stars['psf_max_value'][idx_psf_stars]

def _fit_astrometry(self, exposure, stars):
"""Fit an astrometric model to the data and return the reference
Expand Down
7 changes: 6 additions & 1 deletion python/lsst/pipe/tasks/characterizeImage.py
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,12 @@ def detectMeasureAndEstimatePsf(self, exposure, idGenerator, background):

if background is None:
background = BackgroundList()

self.schema.addField(
'psf_max_value',
type=np.float32,
doc="PSF max value.",
doReplace=True,
)
sourceIdFactory = idGenerator.make_table_id_factory()
table = SourceTable.make(self.schema, sourceIdFactory)
table.setMetadata(self.algMetadata)
Expand Down
13 changes: 13 additions & 0 deletions python/lsst/pipe/tasks/finalizeCharacterization.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,12 @@ def _make_output_schema_mapper(self, input_schema):
size=10,
doc="Color used in PSF fit."
)
output_schema.addField(
'psf_max_value',
type=np.float32,
doc="PSF max value.",
doReplace=True,
)

alias_map = input_schema.getAliasMap()
alias_map_output = afwTable.AliasMap()
Expand Down Expand Up @@ -477,6 +483,12 @@ def _make_selection_schema_mapper(self, input_schema):
size=10,
doc="Color used in PSF fit."
)
selection_schema.addField(
'psf_max_value',
type=np.float32,
doc="PSF max value.",
doReplace=True,
)

return mapper, selection_schema

Expand Down Expand Up @@ -700,6 +712,7 @@ def compute_psf_and_ap_corr_map(self, visit, detector, exposure, src,
# Select the psf candidates from the selection catalog
try:
psf_selection_result = self.make_psf_candidates.run(selected_src, exposure=exposure)
_ = self.make_psf_candidates.run(measured_src, exposure=exposure)
except Exception as e:
self.log.exception('Failed to make PSF candidates for visit %d, detector %d: %s',
visit, detector, e)
Expand Down