LSSTApplications  10.0+286,10.0+36,10.0+46,10.0-2-g4f67435,10.1+152,10.1+37,11.0,11.0+1,11.0-1-g47edd16,11.0-1-g60db491,11.0-1-g7418c06,11.0-2-g04d2804,11.0-2-g68503cd,11.0-2-g818369d,11.0-2-gb8b8ce7
LSSTDataManagementBasePackage
Classes | Functions
lsst.afw.image.utils Namespace Reference

Classes

class  CalibNoThrow
 

Functions

def clipImage
 
def getDistortedWcs
 Get a WCS from an exposureInfo, with distortion terms if possible. More...
 
def resetFilters
 
def defineFilter
 
def defineFiltersFromPolicy
 

Function Documentation

def lsst.afw.image.utils.clipImage (   im,
  minClip,
  maxClip 
)
Clip an image to lie between minClip and maxclip (None to ignore)

Definition at line 30 of file utils.py.

30 
31 def clipImage(im, minClip, maxClip):
32  """Clip an image to lie between minClip and maxclip (None to ignore)"""
33 
34  if re.search("::MaskedImage<", im.__repr__()):
35  mi = im
36  else:
37  mi = afwImage.makeMaskedImage(im, afwImage.MaskU(im.getDimensions()))
38 
39  if minClip is not None:
40  ds = afwDetect.FootprintSet(mi, afwDetect.Threshold(-minClip, afwDetect.Threshold.VALUE, False))
41  afwDetect.setImageFromFootprintList(mi.getImage(), ds.getFootprints(), minClip)
42 
43  if maxClip is not None:
45  afwDetect.setImageFromFootprintList(mi.getImage(), ds.getFootprints(), maxClip)
MaskedImage< ImagePixelT, MaskPixelT, VariancePixelT > * makeMaskedImage(typename Image< ImagePixelT >::Ptr image, typename Mask< MaskPixelT >::Ptr mask=typename Mask< MaskPixelT >::Ptr(), typename Image< VariancePixelT >::Ptr variance=typename Image< VariancePixelT >::Ptr())
Definition: MaskedImage.h:1067
A Threshold is used to pass a threshold value to detection algorithms.
Definition: Threshold.h:44
ImageT::Pixel setImageFromFootprintList(ImageT *image, std::vector< boost::shared_ptr< Footprint >> const &footprints, typename ImageT::Pixel const value)
Set all image pixels in a set of Footprints to a given value.
A set of Footprints, associated with a MaskedImage.
Definition: FootprintSet.h:53
def lsst.afw.image.utils.defineFilter (   name,
  lambdaEff,
  alias = [],
  force = False 
)
Define a filter and its properties in the filter registry

Definition at line 86 of file utils.py.

86 
87 def defineFilter(name, lambdaEff, alias=[], force=False):
88  """Define a filter and its properties in the filter registry"""
89  prop = afwImage.FilterProperty(name, lambdaEff, force)
90  afwImage.Filter.define(prop)
91  if isinstance(alias, basestring):
92  afwImage.Filter.defineAlias(name, alias)
93  else:
94  for a in alias:
95  afwImage.Filter.defineAlias(name, a)
def lsst.afw.image.utils.defineFiltersFromPolicy (   filterPolicy,
  reset = False 
)
Process a Policy and define the filters

Definition at line 96 of file utils.py.

96 
97 def defineFiltersFromPolicy(filterPolicy, reset=False):
98  """Process a Policy and define the filters"""
99 
100  if reset:
101  afwImage.Filter.reset()
102  afwImage.FilterProperty.reset()
103  #
104  # Process the Policy and define the filters
105  #
106  policyFile = pexPolicy.DefaultPolicyFile("afw", "FilterDictionary.paf", "policy")
107  defPolicy = pexPolicy.Policy.createPolicy(policyFile, policyFile.getRepositoryPath(), True)
108 
109  filterPolicy.mergeDefaults(defPolicy.getDictionary())
110 
111  for p in filterPolicy.getArray("Filter"):
112  afwImage.Filter.define(afwImage.FilterProperty(p.get("name"), p))
113  if p.exists("alias"):
114  for a in p.getArray("alias"):
115  afwImage.Filter.defineAlias(p.get("name"), a)
a representation of a default Policy file that is stored as a file in the installation directory of a...
def defineFiltersFromPolicy
Definition: utils.py:96
def lsst.afw.image.utils.getDistortedWcs (   exposureInfo,
  log = None 
)

Get a WCS from an exposureInfo, with distortion terms if possible.

If the WCS in the exposure is a pure TAN WCS and distortion information is available in the exposure's Detector, then return a DistortedTanWcs that combines the distortion information with the pure TAN WCS. Otherwise return the WCS in the exposureInfo without modification.

This function is intended as a temporary workaround until ISR puts a WCS with distortion information into its exposures.

Parameters
[in]exposureInfoexposure information (an lsst.afw.image.ExposureInfo), e.g. from exposure.getInfo()
[in]logan lsst.pex.logging.Log or None; if specified then a warning is logged if:
  • the exposureInfo's WCS has no distortion and cannot be cast to a TanWcs
  • the expousureInfo's detector has no TAN_PIXELS transform (distortion information)
Exceptions
RuntimeErrorif exposureInfo has no WCS.

Definition at line 46 of file utils.py.

46 
47 def getDistortedWcs(exposureInfo, log=None):
48  """!Get a WCS from an exposureInfo, with distortion terms if possible
49 
50  If the WCS in the exposure is a pure TAN WCS and distortion information is available
51  in the exposure's Detector, then return a DistortedTanWcs that combines the
52  distortion information with the pure TAN WCS.
53  Otherwise return the WCS in the exposureInfo without modification.
54 
55  This function is intended as a temporary workaround until ISR puts a WCS with distortion information
56  into its exposures.
57 
58  @param[in] exposureInfo exposure information (an lsst.afw.image.ExposureInfo),
59  e.g. from exposure.getInfo()
60  @param[in] log an lsst.pex.logging.Log or None; if specified then a warning is logged if:
61  - the exposureInfo's WCS has no distortion and cannot be cast to a TanWcs
62  - the expousureInfo's detector has no TAN_PIXELS transform (distortion information)
63  @throw RuntimeError if exposureInfo has no WCS.
64  """
65  if not exposureInfo.hasWcs():
66  raise RuntimeError("exposure must have a WCS")
67  wcs = exposureInfo.getWcs()
68  if not wcs.hasDistortion() and exposureInfo.hasDetector():
69  # warn but continue if TAN_PIXELS not present or the initial WCS is not a TanWcs;
70  # other errors indicate a bug that should raise an exception
71  detector = exposureInfo.getDetector()
72  try:
73  pixelsToTanPixels = detector.getTransform(TAN_PIXELS)
74  tanWcs = afwImage.TanWcs.cast(wcs)
75  except Exception as e:
76  if log:
77  log.warn("Could not create a DistortedTanWcs: %s" % (e,))
78  else:
79  wcs = afwImage.DistortedTanWcs(tanWcs, pixelsToTanPixels)
80  return wcs
def getDistortedWcs
Get a WCS from an exposureInfo, with distortion terms if possible.
Definition: utils.py:46
Combination of a TAN WCS and a distortion model.
def lsst.afw.image.utils.resetFilters ( )
Reset registry of filters and filter properties

Definition at line 81 of file utils.py.

81 
82 def resetFilters():
83  """Reset registry of filters and filter properties"""
84  afwImage.Filter.reset()
85  afwImage.FilterProperty.reset()