22 __all__ = [
"MultibandExposure"]
27 from .
import Exposure, ExposureF
28 from ..image.multiband
import MultibandImage, MultibandTripleBase
29 from ..image.multiband
import tripleFromSingles, tripleFromArrays, makeTripleFromKwargs
30 from ..maskedImage
import MaskedImage
34 """MultibandExposure class 36 This class acts as a container for multiple `afw.Exposure` objects. 37 All exposures must have the same bounding box, and the associated 38 images must all have the same data type. 40 See `MultibandTripleBase` for parameter definitions. 42 def __init__(self, filters, image, mask, variance, psfs=None):
43 super().
__init__(filters, image, mask, variance)
45 for psf, exposure
in zip(psfs, self.
singles):
50 """Construct a MultibandImage from a collection of single band images 52 see `tripleFromExposures` for a description of parameters 57 def fromArrays(filters, image, mask, variance, bbox=None):
58 """Construct a MultibandExposure from a collection of arrays 60 see `tripleFromArrays` for a description of parameters 62 return tripleFromArrays(MultibandExposure, filters, image, mask, variance, bbox)
65 def fromKwargs(filters, filterKwargs, singleType=ExposureF, **kwargs):
66 """Build a MultibandImage from a set of keyword arguments 68 see `makeTripleFromKwargs` for a description of parameters 72 def _buildSingles(self, image=None, mask=None, variance=None):
73 """Make a new list of single band objects 78 List of `Image` objects that represent the image in each band. 80 List of `Mask` objects that represent the mask in each band. 82 List of `Image` objects that represent the variance in each band. 87 Tuple of `MaskedImage` objects for each band, 88 where the `image`, `mask`, and `variance` of each `single` 89 point to the multiband objects. 99 dtype = image.array.dtype
101 maskedImage =
MaskedImage(image=image[f], mask=mask[f], variance=variance[f], dtype=dtype)
102 single = Exposure(maskedImage, dtype=dtype)
103 singles.append(single)
104 return tuple(singles)
107 def fromButler(butler, filters, filterKwargs, *args, **kwargs):
108 """Load a multiband exposure from a butler 110 Because each band is stored in a separate exposure file, 111 this method can be used to load all of the exposures for 117 Butler connection to use to load the single band 119 filters: `list` or `str` 120 List of filter names for each band 122 Keyword arguments to pass to the Butler 123 that are different for each filter. 124 The keys are the names of the arguments and the values 125 should also be dictionaries, with filter names as keys 126 and the value of the argument for the given filter as values. 128 Arguments to the Butler. 130 Keyword arguments to pass to the Butler 131 that are the same in all bands. 135 result: `MultibandExposure` 136 The new `MultibandExposure` created by combining all of the 137 single band exposures. 142 if filterKwargs
is not None:
143 for key, value
in filterKwargs:
144 kwargs[key] = value[f]
145 exposures.append(butler.get(*args, filter=f, **kwargs))
146 return MultibandExposure.fromExposures(filters, exposures)
149 """Get a multiband PSF image 151 The PSF Kernel Image is computed for each band 152 and combined into a (filter, y, x) array and stored 154 The result is not cached, so if the same PSF is expected 155 to be used multiple times it is a good idea to store the 156 result in another variable. 160 position: `Point2D` or `tuple` 161 Coordinates to evaluate the PSF. If `position` is `None` 162 then `Psf.getAveragePosition()` is used. 166 self._psfImage: array 167 The multiband PSF image. 171 if not isinstance(position, Point2D)
and position
is not None:
172 position =
Point2D(position[0], position[1])
175 psfs.append(single.getPsf().computeKernelImage().array)
177 psfs.append(single.getPsf().computeKernelImage(position).array)
178 psfs = np.array(psfs)
183 """Get a multiband PSF image 185 The PSF Kernel Image is computed for each band 186 and combined into a (filter, y, x) array and stored 188 The result is not cached, so if the same PSF is expected 189 to be used multiple times it is a good idea to store the 190 result in another variable. 194 position: `Point2D` or `tuple` 195 Coordinates to evaluate the PSF. If `position` is `None` 196 then `Psf.getAveragePosition()` is used. 200 self._psfImage: array 201 The multiband PSF image. 205 if not isinstance(position, Point2D)
and position
is not None:
206 position =
Point2D(position[0], position[1])
209 psfs.append(single.getPsf().computeImage().array)
211 psfs.append(single.getPsf().computeImage(position).array)
212 psfs = np.array(psfs)
def computePsfKernelImage(self, position=None)
def fromButler(butler, filters, filterKwargs, args, kwargs)
def makeTripleFromKwargs(cls, filters, filterKwargs, singleType, kwargs)
def fromExposures(filters, singles)
def fromKwargs(filters, filterKwargs, singleType=ExposureF, kwargs)
def __init__(self, filters, image, mask, variance, psfs=None)
def fromArrays(filters, image, mask, variance, bbox=None)
def tripleFromSingles(cls, filters, singles)
def computePsfImage(self, position=None)
def tripleFromArrays(cls, filters, image, mask, variance, bbox=None)