41def computePsfImage(psfModels, position, bands, useKernelImage=True):
42 """Get a multiband PSF image
43
44 The PSF Kernel Image is computed for each band
45 and combined into a (filter, y, x) array.
46
47 Parameters
48 ----------
50 The list of PSFs in each band.
51 position : `Point2D` or `tuple`
52 Coordinates to evaluate the PSF.
53 bands: `list` or `str`
54 List of names for each band
55 Returns
56 -------
57 psfs: `np.ndarray`
58 The multiband PSF image.
59 """
60 psfs = []
61
62 if not isinstance(position, Point2D):
63 position = Point2D(position[0], position[1])
64
65 for bidx, psfModel in enumerate(psfModels):
66 try:
67 if useKernelImage:
68 psf = psfModel.computeKernelImage(position)
69 else:
70 psf = psfModel.computeImage(position)
71 psfs.append(psf)
72 except InvalidParameterError:
73
74
75
76
77
78 msg = "Failed to compute PSF at {} in band {}"
79 raise IncompleteDataError(msg.format(position, bands[bidx])) from None
80
81 left = np.min([psf.getBBox().getMinX() for psf in psfs])
82 bottom = np.min([psf.getBBox().getMinY() for psf in psfs])
83 right = np.max([psf.getBBox().getMaxX() for psf in psfs])
84 top = np.max([psf.getBBox().getMaxY() for psf in psfs])
85 bbox = Box2I(Point2I(left, bottom), Point2I(right, top))
86 psfs = np.array([projectImage(psf, bbox).array for psf in psfs])
87 return psfs
88
89
A polymorphic base class for representing an image's Point Spread Function.