LSST Applications g0b6bd0c080+a72a5dd7e6,g1182afd7b4+2a019aa3bb,g17e5ecfddb+2b8207f7de,g1d67935e3f+06cf436103,g38293774b4+ac198e9f13,g396055baef+6a2097e274,g3b44f30a73+6611e0205b,g480783c3b1+98f8679e14,g48ccf36440+89c08d0516,g4b93dc025c+98f8679e14,g5c4744a4d9+a302e8c7f0,g613e996a0d+e1c447f2e0,g6c8d09e9e7+25247a063c,g7271f0639c+98f8679e14,g7a9cd813b8+124095ede6,g9d27549199+a302e8c7f0,ga1cf026fa3+ac198e9f13,ga32aa97882+7403ac30ac,ga786bb30fb+7a139211af,gaa63f70f4e+9994eb9896,gabf319e997+ade567573c,gba47b54d5d+94dc90c3ea,gbec6a3398f+06cf436103,gc6308e37c7+07dd123edb,gc655b1545f+ade567573c,gcc9029db3c+ab229f5caf,gd01420fc67+06cf436103,gd877ba84e5+06cf436103,gdb4cecd868+6f279b5b48,ge2d134c3d5+cc4dbb2e3f,ge448b5faa6+86d1ceac1d,gecc7e12556+98f8679e14,gf3ee170dca+25247a063c,gf4ac96e456+ade567573c,gf9f5ea5b4d+ac198e9f13,gff490e6085+8c2580be5c,w.2022.27
LSST Data Management Base Package
Classes | Functions
lsst.meas.extensions.piff.piffPsfDeterminer Namespace Reference

Classes

class  PiffPsfDeterminerConfig
 
class  PiffPsfDeterminerTask
 

Functions

def getGoodPixels (maskedImage, zeroWeightMaskBits)
 
def computeWeight (maskedImage, maxSNR, good)
 
def applyMaxSNR (imArr, weightArr, good, maxSNR)
 

Function Documentation

◆ applyMaxSNR()

def lsst.meas.extensions.piff.piffPsfDeterminer.applyMaxSNR (   imArr,
  weightArr,
  good,
  maxSNR 
)
Rescale weight of bright stars to cap the computed SNR.

Parameters
----------
imArr : `ndarray`
    Signal (image) array of stamp.
weightArr : `ndarray`
    Weight map array.  May be rescaled in place.
good : `ndarray`
    Index array of pixels to use when computing SNR.
maxSNR : `float`
    Threshold for adjusting variance plane implementing maximum SNR.

Definition at line 185 of file piffPsfDeterminer.py.

185def applyMaxSNR(imArr, weightArr, good, maxSNR):
186 """Rescale weight of bright stars to cap the computed SNR.
187
188 Parameters
189 ----------
190 imArr : `ndarray`
191 Signal (image) array of stamp.
192 weightArr : `ndarray`
193 Weight map array. May be rescaled in place.
194 good : `ndarray`
195 Index array of pixels to use when computing SNR.
196 maxSNR : `float`
197 Threshold for adjusting variance plane implementing maximum SNR.
198 """
199 # We define the SNR value following Piff. Here's the comment from that
200 # code base explaining the calculation.
201 #
202 # The S/N value that we use will be the weighted total flux where the
203 # weight function is the star's profile itself. This is the maximum S/N
204 # value that any flux measurement can possibly produce, which will be
205 # closer to an in-practice S/N than using all the pixels equally.
206 #
207 # F = Sum_i w_i I_i^2
208 # var(F) = Sum_i w_i^2 I_i^2 var(I_i)
209 # = Sum_i w_i I_i^2 <--- Assumes var(I_i) = 1/w_i
210 #
211 # S/N = F / sqrt(var(F))
212 #
213 # Note that if the image is pure noise, this will produce a "signal" of
214 #
215 # F_noise = Sum_i w_i 1/w_i = Npix
216 #
217 # So for a more accurate estimate of the S/N of the actual star itself, one
218 # should subtract off Npix from the measured F.
219 #
220 # The final formula then is:
221 #
222 # F = Sum_i w_i I_i^2
223 # S/N = (F-Npix) / sqrt(F)
224 F = np.sum(weightArr[good]*imArr[good]**2, dtype=float)
225 Npix = np.sum(good)
226 SNR = 0.0 if F < Npix else (F-Npix)/np.sqrt(F)
227 # rescale weight of bright stars. Essentially makes an error floor.
228 if SNR > maxSNR:
229 factor = (maxSNR / SNR)**2
230 weightArr[good] *= factor
231
232
def applyMaxSNR(imArr, weightArr, good, maxSNR)

◆ computeWeight()

def lsst.meas.extensions.piff.piffPsfDeterminer.computeWeight (   maskedImage,
  maxSNR,
  good 
)
Derive a weight map without Poisson variance component due to signal.

Parameters
----------
maskedImage : `afw.image.MaskedImage`
    PSF candidate postage stamp
maxSNR : `float`
    Maximum SNR applying variance floor.
good : `ndarray`
    Index array indicating good pixels.

Returns
-------
weightArr : `ndarry`
    Array to use for weight.

Definition at line 153 of file piffPsfDeterminer.py.

153def computeWeight(maskedImage, maxSNR, good):
154 """Derive a weight map without Poisson variance component due to signal.
155
156 Parameters
157 ----------
158 maskedImage : `afw.image.MaskedImage`
159 PSF candidate postage stamp
160 maxSNR : `float`
161 Maximum SNR applying variance floor.
162 good : `ndarray`
163 Index array indicating good pixels.
164
165 Returns
166 -------
167 weightArr : `ndarry`
168 Array to use for weight.
169 """
170 imArr = maskedImage.image.array
171 varArr = maskedImage.variance.array
172
173 # Fit a straight line to variance vs (sky-subtracted) signal.
174 # The evaluate that line at zero signal to get an estimate of the
175 # signal-free variance.
176 fit = np.polyfit(imArr[good], varArr[good], deg=1)
177 # fit is [1/gain, sky_var]
178 weightArr = np.zeros_like(imArr, dtype=float)
179 weightArr[good] = 1./fit[1]
180
181 applyMaxSNR(imArr, weightArr, good, maxSNR)
182 return weightArr
183
184
def computeWeight(maskedImage, maxSNR, good)

◆ getGoodPixels()

def lsst.meas.extensions.piff.piffPsfDeterminer.getGoodPixels (   maskedImage,
  zeroWeightMaskBits 
)
Compute an index array indicating good pixels to use.

Parameters
----------
maskedImage : `afw.image.MaskedImage`
    PSF candidate postage stamp
zeroWeightMaskBits : `List[str]`
    List of mask bits for which to set pixel weights to zero.

Returns
-------
good : `ndarray`
    Index array indicating good pixels.

Definition at line 126 of file piffPsfDeterminer.py.

126def getGoodPixels(maskedImage, zeroWeightMaskBits):
127 """Compute an index array indicating good pixels to use.
128
129 Parameters
130 ----------
131 maskedImage : `afw.image.MaskedImage`
132 PSF candidate postage stamp
133 zeroWeightMaskBits : `List[str]`
134 List of mask bits for which to set pixel weights to zero.
135
136 Returns
137 -------
138 good : `ndarray`
139 Index array indicating good pixels.
140 """
141 imArr = maskedImage.image.array
142 varArr = maskedImage.variance.array
143 bitmask = maskedImage.mask.getPlaneBitMask(zeroWeightMaskBits)
144 good = (
145 (varArr != 0)
146 & (np.isfinite(varArr))
147 & (np.isfinite(imArr))
148 & ((maskedImage.mask.array & bitmask) == 0)
149 )
150 return good
151
152
def getGoodPixels(maskedImage, zeroWeightMaskBits)