22 from __future__
import absolute_import, division, print_function
24 __all__ = [
"clipImage",
"getDistortedWcs",
"resetFilters",
"defineFilter",
25 "defineFiltersFromPolicy",
"CalibNoThrow"]
27 from past.builtins
import basestring
28 from builtins
import object
33 from .maskedImage
import MaskedImage, makeMaskedImage
34 from .mask
import Mask
35 from .tanWcs
import TanWcs
36 from .distortedTanWcs
import DistortedTanWcs
37 from .filter
import Filter, FilterProperty
38 from .calib
import Calib
42 """Clip an image to lie between minClip and maxclip (None to ignore)"""
43 if isinstance(im, MaskedImage):
48 if minClip
is not None:
51 afwDetect.setImageFromFootprintList(
52 mi.getImage(), ds.getFootprints(), minClip)
54 if maxClip
is not None:
56 afwDetect.setImageFromFootprintList(
57 mi.getImage(), ds.getFootprints(), maxClip)
61 """!Get a WCS from an exposureInfo, with distortion terms if possible
63 If the WCS in the exposure is a pure TAN WCS and distortion information is available
64 in the exposure's Detector, then return a DistortedTanWcs that combines the
65 distortion information with the pure TAN WCS.
66 Otherwise return the WCS in the exposureInfo without modification.
68 This function is intended as a temporary workaround until ISR puts a WCS with distortion information
71 @param[in] exposureInfo exposure information (an lsst.afw.image.ExposureInfo),
72 e.g. from exposure.getInfo()
73 @param[in] log an lsst.log.Log or None; if specified then a warning is logged if:
74 - the exposureInfo's WCS has no distortion and cannot be cast to a TanWcs
75 - the expousureInfo's detector has no TAN_PIXELS transform (distortion information)
76 @throw RuntimeError if exposureInfo has no WCS.
78 if not exposureInfo.hasWcs():
79 raise RuntimeError(
"exposure must have a WCS")
80 wcs = exposureInfo.getWcs()
81 if not wcs.hasDistortion()
and exposureInfo.hasDetector():
84 if not isinstance(wcs, TanWcs):
86 log.warn(
"Could not create a DistortedTanWcs:"
87 "exposure's Wcs is a %r isntead of a TanWcs" % (wcs,))
90 detector = exposureInfo.getDetector()
91 if not detector.hasTransform(TAN_PIXELS):
94 "Could not create a DistortedTanWcs: exposure has no Detector")
97 pixelsToTanPixels = detector.getTransform(TAN_PIXELS)
98 return DistortedTanWcs(wcs, pixelsToTanPixels)
103 """Reset registry of filters and filter properties"""
105 FilterProperty.reset()
109 """Define a filter and its properties in the filter registry"""
112 if isinstance(alias, basestring):
113 Filter.defineAlias(name, alias)
116 Filter.defineAlias(name, a)
120 """Process a Policy and define the filters"""
124 FilterProperty.reset()
129 "afw",
"FilterDictionary.paf",
"policy")
130 defPolicy = pexPolicy.Policy.createPolicy(
131 policyFile, policyFile.getRepositoryPath(),
True)
133 filterPolicy.mergeDefaults(defPolicy.getDictionary())
135 for p
in filterPolicy.getArray(
"Filter"):
137 if p.exists(
"alias"):
138 for a
in p.getArray(
"alias"):
139 Filter.defineAlias(p.get(
"name"), a)
143 """A class intended to be used with python's with statement, to return NaNs for negative fluxes
144 instead of raising exceptions (exceptions may be raised for other purposes).
148 ax.plot([exposure.getCalib().getMagnitude(a) for a in candAmps], zGood[:,k], 'b+')
153 Calib.setThrowOnNegativeFlux(
False)
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.
MaskedImage< ImagePixelT, MaskPixelT, VariancePixelT > * makeMaskedImage(typename std::shared_ptr< Image< ImagePixelT >> image, typename std::shared_ptr< Mask< MaskPixelT >> mask=Mask< MaskPixelT >(), typename std::shared_ptr< Image< VariancePixelT >> variance=Image< VariancePixelT >())
A function to return a MaskedImage of the correct type (cf.
def getDistortedWcs
Get a WCS from an exposureInfo, with distortion terms if possible.
def defineFiltersFromPolicy
Describe the properties of a Filter (e.g.