LSST Applications  21.0.0-172-gfb10e10a+18fedfabac,22.0.0+297cba6710,22.0.0+80564b0ff1,22.0.0+8d77f4f51a,22.0.0+a28f4c53b1,22.0.0+dcf3732eb2,22.0.1-1-g7d6de66+2a20fdde0d,22.0.1-1-g8e32f31+297cba6710,22.0.1-1-geca5380+7fa3b7d9b6,22.0.1-12-g44dc1dc+2a20fdde0d,22.0.1-15-g6a90155+515f58c32b,22.0.1-16-g9282f48+790f5f2caa,22.0.1-2-g92698f7+dcf3732eb2,22.0.1-2-ga9b0f51+7fa3b7d9b6,22.0.1-2-gd1925c9+bf4f0e694f,22.0.1-24-g1ad7a390+a9625a72a8,22.0.1-25-g5bf6245+3ad8ecd50b,22.0.1-25-gb120d7b+8b5510f75f,22.0.1-27-g97737f7+2a20fdde0d,22.0.1-32-gf62ce7b1+aa4237961e,22.0.1-4-g0b3f228+2a20fdde0d,22.0.1-4-g243d05b+871c1b8305,22.0.1-4-g3a563be+32dcf1063f,22.0.1-4-g44f2e3d+9e4ab0f4fa,22.0.1-42-gca6935d93+ba5e5ca3eb,22.0.1-5-g15c806e+85460ae5f3,22.0.1-5-g58711c4+611d128589,22.0.1-5-g75bb458+99c117b92f,22.0.1-6-g1c63a23+7fa3b7d9b6,22.0.1-6-g50866e6+84ff5a128b,22.0.1-6-g8d3140d+720564cf76,22.0.1-6-gd805d02+cc5644f571,22.0.1-8-ge5750ce+85460ae5f3,master-g6e05de7fdc+babf819c66,master-g99da0e417a+8d77f4f51a,w.2021.48
LSST Data Management Base Package
Classes | Functions
lsst.meas.extensions.piff.piffPsfDeterminer Namespace Reference

Classes

class  PiffPsfDeterminerConfig
 
class  PiffPsfDeterminerTask
 

Functions

def computeWeight (maskedImage, maxSNR)
 
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 100 of file piffPsfDeterminer.py.

100 def applyMaxSNR(imArr, weightArr, good, maxSNR):
101  """Rescale weight of bright stars to cap the computed SNR.
102 
103  Parameters
104  ----------
105  imArr : `ndarray`
106  Signal (image) array of stamp.
107  weightArr : `ndarray`
108  Weight map array. May be rescaled in place.
109  good : `ndarray`
110  Index array of pixels to use when computing SNR.
111  maxSNR : `float`
112  Threshold for adjusting variance plane implementing maximum SNR.
113  """
114  # We define the SNR value following Piff. Here's the comment from that
115  # code base explaining the calculation.
116  #
117  # The S/N value that we use will be the weighted total flux where the
118  # weight function is the star's profile itself. This is the maximum S/N
119  # value that any flux measurement can possibly produce, which will be
120  # closer to an in-practice S/N than using all the pixels equally.
121  #
122  # F = Sum_i w_i I_i^2
123  # var(F) = Sum_i w_i^2 I_i^2 var(I_i)
124  # = Sum_i w_i I_i^2 <--- Assumes var(I_i) = 1/w_i
125  #
126  # S/N = F / sqrt(var(F))
127  #
128  # Note that if the image is pure noise, this will produce a "signal" of
129  #
130  # F_noise = Sum_i w_i 1/w_i = Npix
131  #
132  # So for a more accurate estimate of the S/N of the actual star itself, one
133  # should subtract off Npix from the measured F.
134  #
135  # The final formula then is:
136  #
137  # F = Sum_i w_i I_i^2
138  # S/N = (F-Npix) / sqrt(F)
139  F = np.sum(weightArr[good]*imArr[good]**2, dtype=float)
140  Npix = np.sum(good)
141  SNR = 0.0 if F < Npix else (F-Npix)/np.sqrt(F)
142  # rescale weight of bright stars. Essentially makes an error floor.
143  if SNR > maxSNR:
144  factor = (maxSNR / SNR)**2
145  weightArr[good] *= factor
146 
147 
def applyMaxSNR(imArr, weightArr, good, maxSNR)

◆ computeWeight()

def lsst.meas.extensions.piff.piffPsfDeterminer.computeWeight (   maskedImage,
  maxSNR 
)
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.

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

Definition at line 69 of file piffPsfDeterminer.py.

69 def computeWeight(maskedImage, maxSNR):
70  """Derive a weight map without Poisson variance component due to signal.
71 
72  Parameters
73  ----------
74  maskedImage : `afw.image.MaskedImage`
75  PSF candidate postage stamp
76  maxSNR : `float`
77  Maximum SNR applying variance floor.
78 
79  Returns
80  -------
81  weightArr : `ndarry`
82  Array to use for weight.
83  """
84  imArr = maskedImage.image.array
85  varArr = maskedImage.variance.array
86  good = (varArr != 0) & np.isfinite(varArr) & np.isfinite(imArr)
87 
88  # Fit a straight line to variance vs (sky-subtracted) signal.
89  # The evaluate that line at zero signal to get an estimate of the
90  # signal-free variance.
91  fit = np.polyfit(imArr[good], varArr[good], deg=1)
92  # fit is [1/gain, sky_var]
93  weightArr = np.zeros_like(imArr, dtype=float)
94  weightArr[good] = 1./fit[1]
95 
96  applyMaxSNR(imArr, weightArr, good, maxSNR)
97  return weightArr
98 
99