---
title: "One pixel can contain light from two stars"
description: "Derive a weighted two-star fit from a two-pixel example, then test blending, uncertainty and injection recovery."
canonical_url: "https://sandboxphysics.com/stories/stellar-photometry/separating-stars/"
language: "en"
page_type: "story"
alternate_languages:
  zh-CN: "https://sandboxphysics.com/zh/stories/stellar-photometry/separating-stars/"
last_modified: "2026-10-28"
---

[Measure starlight in a crowded sky](https://sandboxphysics.com/stories/stellar-photometry/)

AC02 · L2

# One pixel can contain light from two stars

Sandbox Physics · 2026-10-28

Two stars can share pixels and still have separately measurable brightnesses. Their light must land in different proportions across the image. Each pixel then contributes an equation for the unknown fluxes.

## Before you begin

Read From one photoelectron to an aperture of pixels. You can solve two simultaneous linear equations. Matrices below are tables that organize many such equations.

## 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.

$$
0.8F_{\mathrm t}+0.2F_{\mathrm n}=900,\qquad0.2F_{\mathrm t}+0.8F_{\mathrm n}=600
$$

These are photoelectrons in one exposure. Different proportions provide independent information.

$$
F_{\mathrm t}+F_{\mathrm n}=1500,\qquad F_{\mathrm t}=1000,\quad F_{\mathrm n}=500
$$

Of the nine hundred electrons in the left pixel, eight hundred come from the target and one hundred from its neighbor.

## Organize every pixel into one table

A vector $\boldsymbol y$ is a list of pixel measurements. The unknown list $\boldsymbol f=(F_{\mathrm t},F_{\mathrm n},B)^{\mathsf T}$ contains the two stellar fluxes and a constant sky. Each row of a matrix $A$ 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.

$$
\boldsymbol y=A\boldsymbol f+\boldsymbol\epsilon,\quad A_{i\cdot}=(P_{i\mathrm t},P_{i\mathrm n},1),\quad\chi^2=\sum_i\frac{(y_i-(A\boldsymbol f)_i)^2}{v_i}
$$

The pixels are independent and their variances are supplied. The diagonal weight matrix contains their inverse variances.

## 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 $\mathsf T$ 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.

$$
A^{\mathsf T}WA\widehat{\boldsymbol f}=A^{\mathsf T}W\boldsymbol y,\qquad\widehat{\boldsymbol f}=(A^{\mathsf T}WA)^{-1}A^{\mathsf T}W\boldsymbol y
$$

The three-parameter model requires solving a three-by-three system.

$$
\operatorname{Cov}(\widehat{\boldsymbol f})=(A^{\mathsf T}WA)^{-1}
$$

This assumes a correct linear model and true inverse-variance weights. It includes the statistical cost of fitting the constant sky.

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.

One frozen simulated exposure at the Lab defaults. All entries are photoelectrons per exposure.

| Quantity | Saved result |
| --- | --- |
| Injected target | $6670\,\mathrm e^{-}$ |
| Corrected aperture estimate | $8320\,\mathrm e^{-}$ |
| Two-star fit | $6760\,\mathrm e^{-}$ |
| Fit standard deviation | $104\,\mathrm e^{-}$ |
| Corrected neighbor leakage | $1550\,\mathrm e^{-}$ |

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.

## Exercises and explanations

1. Can a longer exposure separate two perfectly coincident stars with identical profiles?

   Read the explanation

   The total becomes better measured, but the two spatial patterns remain identical. Separate fluxes require another source of information, such as color, different variability or independent positions.

2. Why fit a constant sky as well as both stellar fluxes?

   Read the explanation

   Sky adds a constant to all pixels. Omitting it forces the stellar fluxes to absorb part of that light. Fitting it handles the constant component, with an accompanying statistical correlation between parameters.

3. Do twenty recoveries out of two hundred imply ten-percent completeness for all real surveys?

   Read the explanation

   Only for this flux, separation, known position and ideal profile model. A survey needs injections across its actual backgrounds, brightnesses, colors and source-finding procedure.

## Try the prediction

### [Approach the separation limit](https://sandboxphysics.com/labs/crowded-star-photometry/)

1. Hold neighbor brightness and blur fixed while reducing star separation.
2. Compare the cyan-minus-white residual with the quoted fit error. The white target also varies, so remove that true variation before judging random scatter.
3. Export a record and reconstruct its predicted pixels from the two profiles and constant sky.

[Previous: From one photoelectron to an aperture of pixels](https://sandboxphysics.com/stories/stellar-photometry/counting-photons/) [Next: Extract TESS brightness from twelve pixels](https://sandboxphysics.com/stories/stellar-photometry/tess-pixels/)

## Sources and calculation scope

1. [Photutils 3.1.1, Aperture photometry](https://photutils.readthedocs.io/en/3.1.1/user_guide/aperture.html)

   Fractional aperture weighting, background subtraction and error propagation. The browser uses its own documented midpoint area quadrature.

2. [Photutils 3.1.1, PSF photometry](https://photutils.readthedocs.io/en/3.1.1/user_guide/psf.html)

   Source grouping, fitted fluxes and the role of an accurate point-spread function. The teaching fit fixes both centroids and the Gaussian width.
