Solve a two-pixel example first
Suppose the background is known and removed. The target puts eighty percent of its light in the left pixel and twenty percent in the right. The neighbor does the opposite. The measured counts are nine hundred on the left and six hundred on the right. Ignore noise for this first calculation.
Adding the equations gives fifteen hundred photoelectrons in total. Substitution gives a target flux of one thousand and a neighbor flux of five hundred. Both pixels contain light from both stars, yet their different proportions make separation possible.
Organize every pixel into one table
A vector is a list of pixel measurements. The unknown list contains the two stellar fluxes and a constant sky. Each row of a matrix lists the target profile fraction, the neighbor fraction and one. Multiplication predicts the mean in every pixel.
With noise, no single answer generally matches all pixels exactly. Subtract the prediction from each measurement to form a residual. Give less reliable pixels less weight, and minimize the weighted sum of squared residuals. This is weighted least squares.
Find the flux and its uncertainty
Differentiate the squared residual sum with respect to each unknown: ask whether a tiny change would reduce it further. At a minimum all three derivatives vanish. Arranging those conditions gives the normal equations. The superscript exchanges matrix rows and columns.
If the three spatial patterns are independently distinguishable, the matrix is invertible and the equations have a unique solution. Its inverse also gives a covariance matrix. Diagonal entries are variances of individual estimates; other entries describe how estimates fluctuate together.
The browser supplies the true generating variances as weights and fixes both centroids and the Gaussian width. This is an ideal experiment with those inputs known. A real measurement must estimate them, and its uncertainty must account for their errors.
Reading: Photutils 3.1.1, PSF photometry · Photutils 3.1.1, Aperture photometry
Similar patches carry less separating information
Return to two pixels. If both stars put half their light in each, transferring flux from one star to the other changes no predicted pixel. The total is measurable but the separate fluxes are not identifiable.
Near that limit, a solution exists but small noise changes can cause large shifts between the two fitted fluxes. One estimate rises as the other falls. The larger uncertainty reflects missing information in the image. More printed decimal places cannot supply it.
Inspect the residual image as well. A ring or a directional pattern can reveal a poor profile; a positive side and a negative side can indicate a position error. Those patterns call for a better model or calibration. Improving the profile or position calibration addresses the source of those patterns.
| Quantity | Saved result |
|---|---|
| Injected target | |
| Corrected aperture estimate | |
| Two-star fit | |
| Fit standard deviation | |
| Corrected neighbor leakage |
Radius 2.8 pixels, Gaussian width 1.2 pixels, separation 3.2 pixels, neighbor / mean-target flux ratio 0.8, sky 90 electrons per pixel and read noise 4 electrons. Seed 444 and variability phase 1.2 radians fix this exposure. Reproduce it with node scripts/astronomy/ac02/default-benchmark.ts. Autoplay changes phase and noise, so later readings fluctuate.
Inject stars and measure how many return
Injection recovery provides a case where the answer is known. Generate a star with a specified flux, add background and noise, and run the measurement procedure. Repeated trials separately test average bias, interval coverage and the fraction exceeding a declared threshold.
The saved experiment has eight cells with two hundred trials each. A recovery requires fitted flux above five fitted standard deviations. The target position is supplied, so this is conditional recovery at a known position. It omits blind-search localization, false detections and multiple comparisons.
For an injected flux of three hundred fifty electrons, a neighbor at one point four pixels gives twenty recoveries out of two hundred. At seven pixels, the same experiment gives one hundred ninety-two. Crowding can sharply reduce faint-source recovery even when average fitted flux remains near the truth. The saved output also reports bias and root-mean-square error for every cell.