Skip to content

Commit

Permalink
Use samplingSize in setting stamp size
Browse files Browse the repository at this point in the history
  • Loading branch information
arunkannawadi committed May 23, 2022
1 parent 2280a9d commit a2bd77a
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions python/lsst/meas/extensions/piff/piffPsfDeterminer.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ def determinePsf(
self.config.kernelSizeMin,
self.config.kernelSizeMax
))
self._validatePsfCandidates(psfCandidateList, kernelSize)
self._validatePsfCandidates(psfCandidateList, kernelSize, self.config.samplingSize)

stars = []
for candidate in psfCandidateList:
Expand Down Expand Up @@ -297,7 +297,8 @@ def determinePsf(
pointing = None

piffResult.fit(stars, wcs, pointing, logger=self.log)
psf = PiffPsf(kernelSize, kernelSize, piffResult)
drawSize = 2*np.floor(0.5*kernelSize/self.config.samplingSize) + 1
psf = PiffPsf(drawSize, drawSize, piffResult)

used_image_pos = [s.image_pos for s in piffResult.stars]
if flagKey:
Expand All @@ -316,7 +317,7 @@ def determinePsf(

return psf, None

def _validatePsfCandidates(self, psfCandidateList, kernelSize):
def _validatePsfCandidates(self, psfCandidateList, kernelSize, samplingSize):
"""Raise if psfCandidates are smaller than the configured kernelSize.
Parameters
Expand All @@ -325,6 +326,8 @@ def _validatePsfCandidates(self, psfCandidateList, kernelSize):
Sequence of psf candidates to check.
kernelSize : `int`
Size of image model to use in PIFF.
samplingSize : `float`
Resolution of the internal PSF model relative to the pixel size.
Raises
------
Expand All @@ -334,10 +337,11 @@ def _validatePsfCandidates(self, psfCandidateList, kernelSize):
"""
# We can assume all candidates have the same dimensions.
candidate = psfCandidateList[0]
if (candidate.getHeight() < kernelSize
or candidate.getWidth() < kernelSize):
raise RuntimeError("PSF candidates must be at least config.kernelSize="
f"{kernelSize} pixels per side; "
drawSize = 2*np.floor(0.5*kernelSize/samplingSize) + 1
if (candidate.getHeight() < drawSize
or candidate.getWidth() < drawSize):
raise RuntimeError("PSF candidates must be at least config.kernelSize*samplingSize="
f"{drawSize} pixels per side; "
f"found {candidate.getWidth()}x{candidate.getHeight()}.")


Expand Down

0 comments on commit a2bd77a

Please sign in to comment.