LSST Applications  21.0.0-147-g0e635eb1+1acddb5be5,22.0.0+052faf71bd,22.0.0+1ea9a8b2b2,22.0.0+6312710a6c,22.0.0+729191ecac,22.0.0+7589c3a021,22.0.0+9f079a9461,22.0.1-1-g7d6de66+b8044ec9de,22.0.1-1-g87000a6+536b1ee016,22.0.1-1-g8e32f31+6312710a6c,22.0.1-10-gd060f87+016f7cdc03,22.0.1-12-g9c3108e+df145f6f68,22.0.1-16-g314fa6d+c825727ab8,22.0.1-19-g93a5c75+d23f2fb6d8,22.0.1-19-gb93eaa13+aab3ef7709,22.0.1-2-g8ef0a89+b8044ec9de,22.0.1-2-g92698f7+9f079a9461,22.0.1-2-ga9b0f51+052faf71bd,22.0.1-2-gac51dbf+052faf71bd,22.0.1-2-gb66926d+6312710a6c,22.0.1-2-gcb770ba+09e3807989,22.0.1-20-g32debb5+b8044ec9de,22.0.1-23-gc2439a9a+fb0756638e,22.0.1-3-g496fd5d+09117f784f,22.0.1-3-g59f966b+1e6ba2c031,22.0.1-3-g849a1b8+f8b568069f,22.0.1-3-gaaec9c0+c5c846a8b1,22.0.1-32-g5ddfab5d3+60ce4897b0,22.0.1-4-g037fbe1+64e601228d,22.0.1-4-g8623105+b8044ec9de,22.0.1-5-g096abc9+d18c45d440,22.0.1-5-g15c806e+57f5c03693,22.0.1-7-gba73697+57f5c03693,master-g6e05de7fdc+c1283a92b8,master-g72cdda8301+729191ecac,w.2021.39
LSST Data Management Base Package
Public Member Functions | Static Public Attributes | List of all members
lsst.meas.extensions.piff.piffPsfDeterminer.PiffPsfDeterminerTask Class Reference
Inheritance diagram for lsst.meas.extensions.piff.piffPsfDeterminer.PiffPsfDeterminerTask:
lsst.meas.algorithms.psfDeterminer.BasePsfDeterminerTask

Public Member Functions

def determinePsf (self, exposure, psfCandidateList, metadata=None, flagKey=None)
 
def determinePsf (self, exposure, psfCandidateList, metadata=None)
 

Static Public Attributes

 ConfigClass = PiffPsfDeterminerConfig
 
bool usesMatches = False
 

Detailed Description

A measurePsfTask PSF estimator using Piff as the implementation.

Definition at line 171 of file piffPsfDeterminer.py.

Member Function Documentation

◆ determinePsf() [1/2]

def lsst.meas.algorithms.psfDeterminer.BasePsfDeterminerTask.determinePsf (   self,
  exposure,
  psfCandidateList,
  metadata = None 
)
inherited
Determine a PSF model.

Parameters
----------
exposure : `lsst.afw.Exposure`
    Exposure containing the psf candidates.
psdCandidateList : `list` [`lsst.meas.algorithms.PsfCandidate`]
    A sequence of PSF candidates; typically obtained by
    detecting sources and then running them through a star
    selector.
metadata : `str`
    A place to save interesting items.

Returns
-------
psf : `lsst.afw.detection.Psf`
    The fit PSF.
cellSet : `lsst.afw.math.SpatialCellSet`
    The spatial cell set used to determine the PSF

Definition at line 78 of file psfDeterminer.py.

78  def determinePsf(self, exposure, psfCandidateList, metadata=None):
79  """Determine a PSF model.
80 
81  Parameters
82  ----------
83  exposure : `lsst.afw.Exposure`
84  Exposure containing the psf candidates.
85  psdCandidateList : `list` [`lsst.meas.algorithms.PsfCandidate`]
86  A sequence of PSF candidates; typically obtained by
87  detecting sources and then running them through a star
88  selector.
89  metadata : `str`
90  A place to save interesting items.
91 
92  Returns
93  -------
94  psf : `lsst.afw.detection.Psf`
95  The fit PSF.
96  cellSet : `lsst.afw.math.SpatialCellSet`
97  The spatial cell set used to determine the PSF
98  """
99  raise NotImplementedError("BasePsfDeterminerTask is abstract, subclasses must override this method")
100 
101 

◆ determinePsf() [2/2]

def lsst.meas.extensions.piff.piffPsfDeterminer.PiffPsfDeterminerTask.determinePsf (   self,
  exposure,
  psfCandidateList,
  metadata = None,
  flagKey = None 
)
Determine a Piff PSF model for an exposure given a list of PSF
candidates.

Parameters
----------
exposure : `lsst.afw.image.Exposure`
   Exposure containing the PSF candidates.
psfCandidateList : `list` of `lsst.meas.algorithms.PsfCandidate`
   A sequence of PSF candidates typically obtained by detecting sources
   and then running them through a star selector.
metadata : `lsst.daf.base import PropertyList` or `None`, optional
   A home for interesting tidbits of information.
flagKey : `str` or `None`, optional
   Schema key used to mark sources actually used in PSF determination.

Returns
-------
psf : `lsst.meas.extensions.piff.PiffPsf`
   The measured PSF model.
psfCellSet : `None`
   Unused by this PsfDeterminer.

Definition at line 177 of file piffPsfDeterminer.py.

179  ):
180  """Determine a Piff PSF model for an exposure given a list of PSF
181  candidates.
182 
183  Parameters
184  ----------
185  exposure : `lsst.afw.image.Exposure`
186  Exposure containing the PSF candidates.
187  psfCandidateList : `list` of `lsst.meas.algorithms.PsfCandidate`
188  A sequence of PSF candidates typically obtained by detecting sources
189  and then running them through a star selector.
190  metadata : `lsst.daf.base import PropertyList` or `None`, optional
191  A home for interesting tidbits of information.
192  flagKey : `str` or `None`, optional
193  Schema key used to mark sources actually used in PSF determination.
194 
195  Returns
196  -------
197  psf : `lsst.meas.extensions.piff.PiffPsf`
198  The measured PSF model.
199  psfCellSet : `None`
200  Unused by this PsfDeterminer.
201  """
202  stars = []
203  for candidate in psfCandidateList:
204  cmi = candidate.getMaskedImage()
205  weight = computeWeight(cmi, self.config.maxSNR)
206 
207  bbox = cmi.getBBox()
208  bds = galsim.BoundsI(
209  galsim.PositionI(*bbox.getMin()),
210  galsim.PositionI(*bbox.getMax())
211  )
212  gsImage = galsim.Image(bds, scale=1.0, dtype=float)
213  gsImage.array[:] = cmi.image.array
214  gsWeight = galsim.Image(bds, scale=1.0, dtype=float)
215  gsWeight.array[:] = weight
216 
217  source = candidate.getSource()
218  image_pos = galsim.PositionD(source.getX(), source.getY())
219 
220  data = piff.StarData(
221  gsImage,
222  image_pos,
223  weight=gsWeight
224  )
225  stars.append(piff.Star(data, None))
226 
227  kernelSize = int(np.clip(
228  self.config.kernelSize,
229  self.config.kernelSizeMin,
230  self.config.kernelSizeMax
231  ))
232 
233  piffConfig = {
234  'type': "Simple",
235  'model': {
236  'type': 'PixelGrid',
237  'scale': self.config.samplingSize,
238  'size': kernelSize
239  },
240  'interp': {
241  'type': 'BasisPolynomial',
242  'order': self.config.spatialOrder
243  },
244  'outliers': {
245  'type': 'Chisq',
246  'nsigma': self.config.outlierNSigma,
247  'max_remove': self.config.outlierMaxRemove
248  }
249  }
250 
251  piffResult = piff.PSF.process(piffConfig)
252  # Run on a single CCD, and in image coords rather than sky coords.
253  wcs = {0: galsim.PixelScale(1.0)}
254  pointing = None
255 
256  piffResult.fit(stars, wcs, pointing, logger=self.log)
257  psf = PiffPsf(kernelSize, kernelSize, piffResult)
258 
259  used_image_pos = [s.image_pos for s in piffResult.stars]
260  if flagKey:
261  for candidate in psfCandidateList:
262  source = candidate.getSource()
263  posd = galsim.PositionD(source.getX(), source.getY())
264  if posd in used_image_pos:
265  source.set(flagKey, True)
266 
267  if metadata is not None:
268  metadata.set("spatialFitChi2", piffResult.chisq)
269  metadata.set("numAvailStars", len(stars))
270  metadata.set("numGoodStars", len(piffResult.stars))
271  metadata.set("avgX", np.mean([p.x for p in piffResult.stars]))
272  metadata.set("avgY", np.mean([p.y for p in piffResult.stars]))
273 
274  return psf, None
275 
276 
277 measAlg.psfDeterminerRegistry.register("piff", PiffPsfDeterminerTask)

Member Data Documentation

◆ ConfigClass

lsst.meas.extensions.piff.piffPsfDeterminer.PiffPsfDeterminerTask.ConfigClass = PiffPsfDeterminerConfig
static

Definition at line 174 of file piffPsfDeterminer.py.

◆ usesMatches

bool lsst.meas.algorithms.psfDeterminer.BasePsfDeterminerTask.usesMatches = False
staticinherited

Definition at line 70 of file psfDeterminer.py.


The documentation for this class was generated from the following file: