1 from __future__
import absolute_import, division
28 from .
import imageLib
as afwImage
31 """Clip an image to lie between minClip and maxclip (None to ignore)"""
33 if re.search(
"::MaskedImage<", im.__repr__()):
38 if minClip
is not None:
42 if maxClip
is not None:
47 """!Get a WCS from an exposureInfo, with distortion terms if possible
49 If the WCS in the exposure is a pure TAN WCS and distortion information is available
50 in the exposure's Detector, then return a DistortedTanWcs that combines the
51 distortion information with the pure TAN WCS.
52 Otherwise return the WCS in the exposureInfo without modification.
54 This function is intended as a temporary workaround until ISR puts a WCS with distortion information
57 @param[in] exposureInfo exposure information (an lsst.afw.image.ExposureInfo),
58 e.g. from exposure.getInfo()
59 @param[in] log an lsst.pex.logging.Log or None; if specified then a warning is logged if:
60 - the exposureInfo's WCS has no distortion and cannot be cast to a TanWcs
61 - the expousureInfo's detector has no TAN_PIXELS transform (distortion information)
62 @throw RuntimeError if exposureInfo has no WCS.
64 if not exposureInfo.hasWcs():
65 raise RuntimeError(
"exposure must have a WCS")
66 wcs = exposureInfo.getWcs()
67 if not wcs.hasDistortion()
and exposureInfo.hasDetector():
70 detector = exposureInfo.getDetector()
72 pixelsToTanPixels = detector.getTransform(TAN_PIXELS)
73 tanWcs = afwImage.TanWcs.cast(wcs)
74 except Exception
as e:
76 log.warn(
"Could not create a DistortedTanWcs: %s" % (e,))
82 """Reset registry of filters and filter properties"""
83 afwImage.Filter.reset()
84 afwImage.FilterProperty.reset()
87 """Define a filter and its properties in the filter registry"""
89 afwImage.Filter.define(prop)
90 if isinstance(alias, basestring):
91 afwImage.Filter.defineAlias(name, alias)
94 afwImage.Filter.defineAlias(name, a)
97 """Process a Policy and define the filters"""
100 afwImage.Filter.reset()
101 afwImage.FilterProperty.reset()
106 defPolicy = pexPolicy.Policy.createPolicy(policyFile, policyFile.getRepositoryPath(),
True)
108 filterPolicy.mergeDefaults(defPolicy.getDictionary())
110 for p
in filterPolicy.getArray(
"Filter"):
112 if p.exists(
"alias"):
113 for a
in p.getArray(
"alias"):
114 afwImage.Filter.defineAlias(p.get(
"name"), a)
117 """A class intended to be used with python's with statement, to return NaNs for negative fluxes
118 instead of raising exceptions (exceptions may be raised for other purposes).
122 ax.plot([exposure.getCalib().getMagnitude(a) for a in candAmps], zGood[:,k], 'b+')
126 afwImage.Calib.setThrowOnNegativeFlux(
False)
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())
a representation of a default Policy file that is stored as a file in the installation directory of a...
A Threshold is used to pass a threshold value to detection algorithms.
def getDistortedWcs
Get a WCS from an exposureInfo, with distortion terms if possible.
def defineFiltersFromPolicy
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.
Combination of a TAN WCS and a distortion model.