LSSTApplications  11.0-13-gbb96280,12.1.rc1,12.1.rc1+1,12.1.rc1+2,12.1.rc1+5,12.1.rc1+8,12.1.rc1-1-g06d7636+1,12.1.rc1-1-g253890b+5,12.1.rc1-1-g3d31b68+7,12.1.rc1-1-g3db6b75+1,12.1.rc1-1-g5c1385a+3,12.1.rc1-1-g83b2247,12.1.rc1-1-g90cb4cf+6,12.1.rc1-1-g91da24b+3,12.1.rc1-2-g3521f8a,12.1.rc1-2-g39433dd+4,12.1.rc1-2-g486411b+2,12.1.rc1-2-g4c2be76,12.1.rc1-2-gc9c0491,12.1.rc1-2-gda2cd4f+6,12.1.rc1-3-g3391c73+2,12.1.rc1-3-g8c1bd6c+1,12.1.rc1-3-gcf4b6cb+2,12.1.rc1-4-g057223e+1,12.1.rc1-4-g19ed13b+2,12.1.rc1-4-g30492a7
LSSTDataManagementBasePackage
warpAndPsfMatch.py
Go to the documentation of this file.
1 #
2 # LSST Data Management System
3 # Copyright 2008, 2009, 2010, 2011, 2012 LSST Corporation.
4 #
5 # This product includes software developed by the
6 # LSST Project (http://www.lsst.org/).
7 #
8 # This program is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
12 #
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the LSST License Statement and
19 # the GNU General Public License along with this program. If not,
20 # see <http://www.lsstcorp.org/LegalNotices/>.
21 #
22 import lsst.pex.config as pexConfig
23 import lsst.afw.math as afwMath
24 import lsst.pipe.base as pipeBase
25 from lsst.ip.diffim import ModelPsfMatchTask
26 
27 __all__ = ["WarpAndPsfMatchTask"]
28 
29 class WarpAndPsfMatchConfig(pexConfig.Config):
30  """Config for WarpAndPsfMatchTask
31  """
32  psfMatch = pexConfig.ConfigurableField(
33  target = ModelPsfMatchTask,
34  doc = "PSF matching model to model task",
35  )
36  warp = pexConfig.ConfigField(
37  dtype = afwMath.Warper.ConfigClass,
38  doc = "warper configuration",
39  )
40 
41 
42 class WarpAndPsfMatchTask(pipeBase.Task):
43  """A task to warp and PSF-match an exposure
44  """
45  ConfigClass = WarpAndPsfMatchConfig
46 
47  def __init__(self, *args, **kwargs):
48  pipeBase.Task.__init__(self, *args, **kwargs)
49  self.makeSubtask("psfMatch")
50  self.warper = afwMath.Warper.fromConfig(self.config.warp)
51 
52  def run(self, exposure, wcs, modelPsf=None, maxBBox=None, destBBox=None):
53  """PSF-match exposure (if modelPsf is not None) and warp
54 
55  Note that PSF-matching is performed before warping, which is incorrect:
56  a position-dependent warping (as is used in the general case) will
57  re-introduce a position-dependent PSF. However, this is easier, and
58  sufficient for now (until we are able to warp PSFs to determine the
59  correct target PSF).
60 
61  @param[in,out] exposure: exposure to preprocess; PSF matching is done in place
62  @param[in] wcs: desired WCS of temporary images
63  @param[in] modelPsf: target PSF to which to match (or None)
64  @param maxBBox: maximum allowed parent bbox of warped exposure (an afwGeom.Box2I or None);
65  if None then the warped exposure will be just big enough to contain all warped pixels;
66  if provided then the warped exposure may be smaller, and so missing some warped pixels;
67  ignored if destBBox is not None
68  @param destBBox: exact parent bbox of warped exposure (an afwGeom.Box2I or None);
69  if None then maxBBox is used to determine the bbox, otherwise maxBBox is ignored
70 
71  @return a pipe_base Struct containing:
72  - exposure: processed exposure
73  """
74  if modelPsf is not None:
75  exposure = self.psfMatch.run(exposure, modelPsf).psfMatchedExposure
76  with self.timer("warp"):
77  exposure = self.warper.warpExposure(wcs, exposure, maxBBox=maxBBox, destBBox=destBBox)
78  return pipeBase.Struct(
79  exposure = exposure,
80  )