lsst.meas.algorithms  14.0-21-ge7d40960+8
psfDeterminer.py
Go to the documentation of this file.
1 #
2 # LSST Data Management System
3 #
4 # Copyright 2008-2017 AURA/LSST.
5 #
6 # This product includes software developed by the
7 # LSST Project (http://www.lsst.org/).
8 #
9 # This program is free software: you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation, either version 3 of the License, or
12 # (at your option) any later version.
13 #
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
18 #
19 # You should have received a copy of the LSST License Statement and
20 # the GNU General Public License along with this program. If not,
21 # see <https://www.lsstcorp.org/LegalNotices/>.
22 #
23 from __future__ import absolute_import, division, print_function
24 
25 __all__ = ["BasePsfDeterminerConfig", "BasePsfDeterminerTask", "psfDeterminerRegistry"]
26 
27 import abc
28 
29 import lsst.pipe.base as pipeBase
30 import lsst.pex.config as pexConfig
31 from future.utils import with_metaclass
32 
33 
34 class BasePsfDeterminerConfig(pexConfig.Config):
35  """Configuration that is likely to be shared by all PSF determiners
36 
37  This is fairly sparse; more fields can be moved here once it is clear they are universal.
38  """
39  kernelSize = pexConfig.Field(
40  doc="radius of the kernel to create, relative to the square root of the stellar quadrupole moments",
41  dtype=float,
42  default=10.0,
43  )
44  kernelSizeMin = pexConfig.Field(
45  doc="Minimum radius of the kernel",
46  dtype=int,
47  default=25,
48  )
49  kernelSizeMax = pexConfig.Field(
50  doc="Maximum radius of the kernel",
51  dtype=int,
52  default=45,
53  )
54 
55 
56 class BasePsfDeterminerTask(with_metaclass(abc.ABCMeta, pipeBase.Task)):
57  """!Base class for PSF determiners
58 
59  Register all PSF determiners with the psfDeterminerRegistry using:
60  psfDeterminerRegistry.register(name, class)
61  """
62 
63  usesMatches = False # Does the PSF determiner use the "matches" argument in the "run method? Few do.
64  ConfigClass = BasePsfDeterminerConfig
65  _DefaultName = "psfDeterminer"
66 
67  def __init__(self, config, schema=None, **kwds):
68  """Construct a PSF Determiner
69 
70  @param[in] config an instance of pexConfig.Config that configures this algorithm
71  @param[in,out] schema an instance of afw.table.Schema used for sources; passing a
72  schema allows the determiner to reserve a flag field to mark stars
73  used in PSF measurement, but some PSF determiners ignore this argument
74  """
75  pipeBase.Task.__init__(self, config=config, **kwds)
76 
77  @abc.abstractmethod
78  def determinePsf(exposure, psfCandidateList, metadata=None):
79  """Determine a PSF model
80 
81  @param[in] exposure exposure containing the psf candidates (lsst.afw.image.Exposure)
82  @param[in] psfCandidateList: a sequence of PSF candidates (each an
83  lsst.meas.algorithms.PsfCandidate); typically obtained by
84  detecting sources and then running them through a star selector
85  @param[in,out] metadata a place to save interesting items
86 
87  @return
88  - psf: the fit PSF; a subclass of lsst.afw.detection.Psf
89  - cellSet: the spatial cell set used to determine the PSF (lsst.afw.math.SpatialCellSet)
90  """
91  raise NotImplementedError("BasePsfDeterminerTask is abstract, subclasses must override this method")
92 
93 
94 psfDeterminerRegistry = pexConfig.makeRegistry(
95  doc="A registry of PSF determiners (subclasses of BasePsfDeterminerTask)",
96 )
def determinePsf(exposure, psfCandidateList, metadata=None)