Physics-grounded colour calibration. SASpro detects stars in the
plate-solved frame, matches each one to a Gaia DR3 XP calibrated spectrum
(or a Pickles library template as fallback), integrates its spectrum through the
telescope's filter/sensor/light-pollution curves to predict the expected
R/G, B/G ratios, measures them in the image, fits a correction
model, and applies it.
The window is the settings for your optical chain and one button. Pick the chain once (it is remembered), make the image you want calibrated the active view, and press Calibrate. SASpro finds the stars, looks up their spectra, measures them, fits the correction and applies it, then shows a one-line summary and every chart beside the settings. On a 12 Mpx frame that takes about 6–10 seconds; the first run of a session is the slower one, because SIMBAD is checked and the curve files are read once.
The image needs a plate solution. If it has none, Calibrate offers to run the plate solver first. Undo reverts the calibration like any other edit, so trying a different white reference is just Undo and Calibrate again.
The White Reference picks the SED that defines “neutral
grey” (default G2V, the Sun; Vega / A0V is the usual
alternative). The calibrated colours are relative to it: a star with this
spectrum comes out R = G = B (§2.5).
Then the actual optical chain: R Filter, G Filter,
B Filter, Sensor (QE) and up to two LP/Cut Filter curves
(e.g. an IR-cut and a light-pollution filter). (None) is a
flat-unity curve. These are read from the shipped sasp_data.fits
plus a per-user usercustomcurves.fits, and every choice is
remembered.
(0.2, 10] px. The stars are found once, and the
photometry later measures these same stars. (The old two-step window found
them all over again in Step 2.)RADECSYS and EPOCH
keywords are normalized first).B−V (§2.3). Gaia-matched stars get
synthetic Johnson B/V/R from their XP spectrum via
gaiaxpy.generate(system=JKC) (cached), and a letter class from
the synthetic B−V where SIMBAD had none.The line above the charts gives the number of stars used, split into Gaia XP
spectra and Pickles templates, the time the run took, the model chosen
(slope-only / affine / quadratic) and the net R and B scalings at
x = 1. Four charts follow.
The residuals, before and after (top row). Both panels plot the
fractional residual (measured_ratio / expected_ratio) − 1
on the y-axis against the expected ratio on the x-axis. Red circles are
the R/G channel, blue squares are B/G. The shaded bands
behind each colour are the Q1–Q3 interquartile range — the
central half of the scatter.
The stars (bottom row) show the quality of what the field gave you.
B−V inference (SIMBAD or Gaia
synthetic) because no spectral type was published. A healthy
astrophotography field is bell-shaped around F / G / K with tails to A
and M; a histogram that's all one letter usually means the SIMBAD query
failed or the field is pathologically narrow (star cluster, galactic
plane crowding). Blue dominating is good; a lot of orange means SASpro
had to fall back to colour-only typing for most of the field. With
dozens of types, every few bars are labelled.Click Open SASP Viewer (under the filter lists) to launch a standalone window that plots any stellar SED through any R/G/B filter set, any sensor QE, and up to two LP/cut filters. It doesn't touch the image — it's a free-form exploration of what your optical chain actually sees, and it's where you get a feel for why one filter choice gives you deeper red stars than another, or why that bargain CMOS sensor can't tell a late K from an M.
The dropdowns across the top are the same vocabulary as the main dialog: Star Template (any Pickles SED from O supergiants through late M dwarfs), R / G / B Filter, two optional LP/Cut Filter slots, and Sensor (QE). Change any dropdown and press Plot to redraw.
One figure, two y-axes:
T_filter × QE × LP₁ × LP₂
alone, independent of the star. These are the instrument; the gold
curves are what the instrument does to the star. If the dashed curves
look clean and symmetric but the gold curves are chopped off at one
side, the sensor's QE is choking that end of the band.R→SII: 3.42 | G→OIII: 4.11).
These are system magnitudes you can sanity-check against a known
calibrated star; a large asymmetry (one channel much fainter than the
others for a G2V) is a clue that your filter balance is off.M5V, leave an
ordinary R+G+B+IR-cut chain selected: the gold B response is a flat
line against the floor while R has a tall peak. That's why red giants
look blue-starved before any colour correction.Not in the window: the Run Gradient Extraction button and its
method combo (poly2, poly3, rbf)
were always hidden, and the one-click window leaves them out. The code path
remains (run_gradient_extraction). It uses the same
spectra and photometry to measure a per-channel spectrophotometric
gradient and remove it — see §2.7.
The result pane shows three side-by-side panels, one per channel, each a
divergent red/blue heatmap of the fitted gradient surface in
magnitudes. Panel titles report the peak magnitude for that channel so
you can tell at a glance how aggressive the correction was — a 0.03 mag
peak is a cosmetic tweak, a 0.3 mag peak was clamped (§2.7) because the fit
tried to go further. Yellow dots overlay the star positions used for
that channel's fit after sigma-clipping; sparse corners mean the surface is
extrapolating there and should be treated with caution. The three channels
usually show similar shape (same corner darker, same edge brighter)
with different amplitudes — that's a real optical gradient. If the
three channels show unrelated patterns, the fit is chasing noise and
poly2 is probably the right method to retry with.
RGB only; no narrowband. The core idea: use each star's real spectrum as a photometric standard. SIMBAD + Pickles can approximate the spectrum from a type label; Gaia XP gives you the actual observed spectrum of that star. SFCC uses XP where it has it and falls back to a hierarchical Pickles match where it doesn't.
gaiaxpy, the
Pickles 1998 stellar flux library, SIMBAD (CDS Strasbourg), and
SEP (Source Extractor as a Python library). The calibration pipeline,
the three-model fit, the pivot-at-median application, and all SASpro-specific
heuristics below are implemented in SASpro.SEP runs on the mean of the three channels. Rather than fixing a detection threshold:
If no rung reaches 1200 the lowest σ is kept so there's still something
to work with. Detections are filtered by flux-radius to (0.2, 10] px
to drop galaxies/plate flaws. Only sep.extract is retried per rung
— the one-off background estimation runs once.
The search lands on the same σ as stepping down the ladder from the top, in two or three SEP passes instead of up to seven: detection counts only grow as σ drops, so the answer is the σ that reaches 1200 while the next stricter one does not, and a quick count of image peaks picks where to start. SEP's deblender draws random numbers, so the same frame used to come back with slightly different star sizes (and so aperture radii) from one run to the next; the generator is now reseeded before every pass, and the same image always gives the same stars and the same calibration.
The optical chain combines multiplicatively on a shared 3000–11000 Å 1-Å grid:
For each star, the expected integrated flux through channel c
is
The λ makes it a photon count: a sensor counts photons,
each of energy hc/λ. (Until 2026-11-28 the integrals were
energy; once the white reference divides out, the difference is about
1 %.)
where f_star(λ) is either the Gaia XP calibrated
spectrum (interpolated onto the grid) or the matched Pickles SED. Integrals are
cached per (source_id, system_key) in an SQLite store so repeat
runs are instant — system_key is an MD5 over the wavelength
grid and the three throughputs so any filter change triggers a recompute.
Reference integrals S_ref_c are the same formula applied to the
chosen white reference (default G2V).
SIMBAD spectral type (e.g. K2III, B8/9V,
M6/8III) is matched against the available Pickles extensions by
letter class, subclass, and luminosity — exact match first, then the
nearest subclass in the same luminosity class. With no luminosity class, dwarfs
come first (V, then IV, III, II, I); with no subclass, the middle of the
library's subclasses for that letter. Pickles range names count as their
midpoint (B57V is B6). Until 2026-11-28 ties went alphabetically, so
a bare G or K became the supergiant G0I or
K01II. When SIMBAD gives no type but SIMBAD or Gaia-synthetic
Johnson magnitudes are available, the letter is inferred from B−V:
and the match runs again on the letter alone (so a B−V-only star picks,
say, the main-sequence K5V rather than K5III).
The stars found at detection are measured where they were found (they are
not detected a second time), capped to the brightest 500. For each kept star the aperture radii scale
with the SEP semi-major axis a:
Each channel's background-subtracted flux comes from an annulus-estimated pedestal:
Photometry runs for all stars in one pass; stars with any non-positive channel are dropped. The result is the two measured ratios per star compared against the predicted ratios from §2.2:
SASpro then fits three models independently for the R and B channels and keeps the best per channel. The slope-only solution is closed-form:
and affine / quadratic are standard least-squares and polynomial fits:
Each is scored by the fractional-residual RMS:
and the winner minimises the sum over both channels:
A fractional loss is used, not absolute, because stars span orders of magnitude in flux and residuals should be measured relative to the expected value. Quadratic is only entered when there are ≥ 6 valid stars.
The winning polynomial p_c maps a measured ratio to the
star's expected ratio through the system. An expected ratio is not a
colour: through Antlia R/G/B × IMX492 a G2V star expects R/G 0.76,
B/G 1.04. The corrected ratio is therefore the expected ratio relative to the
white reference's, and a pixel with ratio x
(x_R = I_R/I_G, x_B = I_B/I_G) gets the gain
Before 2026-11-28 the gain was the clipped polynomial itself and the reference integrals were never used: a star's ratio was multiplied by its own expected ratio, a colour-dependent stretch, and the White Reference choice made no difference. Measured against each star's colour relative to G2V through the full system (87 Gaia XP stars on ngc1333), the output went from R/G 0.87, B/G 0.83 to 0.98 and 0.97.
And applied with a pivot at the channel median rather than at zero, so the overall channel brightness is preserved and only the colour balance moves:
Green is the reference channel and is left unchanged. The clip at
[0.25, 4] on the polynomial prevents extreme ratios on bright or dark pixels
from driving runaway gains (e.g. a saturated red core where G→0).
In ratio space, with G normalised to 1, each star gives a measurement vector and a target vector:
SASpro solves this by least-squares row-by-row (per output channel), then
forces the G row to [0, 1, 0] so green maps to itself
exactly and the matrix stays near-identity. 3σ-MAD clipping on residuals
removes outliers, and the solution is rejected if any of:
κ(M) > 50,|M_ii| > 3 for any diagonal entry, or|M_ij| > 1.5 for any off-diagonal entry.Applied per pixel in ratio space with G held fixed, then a per-pixel
negative fix (shift up by min(channels)) and a
luminance-pivoted ceiling compression keep the output in gamut without
hard-clipping any one channel.
Removes a spatially-varying colour gradient per channel using the same star catalogue. For each star and channel the differential magnitude is computed (no annulus — raw aperture only, since the gradient is the pedestal we're after), then field-median-subtracted so only the spatial variation remains:
A 2.5σ-MAD clip removes outliers, then a 2D surface
(poly2, poly3, or RBF with a thin-plate-spline
kernel) is fit per channel, re-centred, and clamped to ±0.3
mag so a bad fit can't blow up the image. The correction is multiplicative in
flux:
At least 10 stars are required post-clipping, and at least 5 per channel to proceed with the fit.
The current pipeline trusts the manufacturer's published QE curve. That
curve is a room-temperature bare-die measurement; a real system's response is
the product of sensor QE, cover glass, AR coatings, telescope
throughput, atmosphere and airmass. With Gaia DR4's ~10× denser XP
coverage, the plan is to drop the QE combobox entirely and solve the
effective system response R(λ) directly from the
stellar population — the same approach Gaia uses internally for its own
photometric calibration (Carrasco et al. 2021, Riello et al. 2021). Filters
stay as inputs; QE becomes a solved output, with the matrix of star / channel
observations providing the overconstrained system.