The maths

All the maths the tool does, in fourteen short steps.

Ektos is a blink and stereo comparator: it shows the same patch of sky at two dates and measures what moved. This page goes through the formulas behind those measurements, one by one. Each step first says what the formula is for; then come the formula itself, the meaning of its symbols, and a small figure you can play with.

The formulas are taken straight from the tool’s code; each step names the file they live in. The numbers are the measurements in the repository’s README.

A · earlier epoch B · later epoch live or selected 14 steps · the sliders are yours

01

Where does a point of sky land on the plate?

The sky is like the inside of a sphere, but a plate is flat. This formula moves a point on the sphere onto a flat surface that touches the sphere at the centre of the plate. The tool keeps every position on this plane, in arcseconds.

ξ=cosδsinΔαcosc η=cosδ0sinδ−sinδ0cosδcosΔαcosc cosc=sinδ0sinδ+cosδ0cosδcosΔα
α,δRight ascension and declination of the point: its longitude and latitude on the sky.
α0,δ0The centre of the plate.
Δαα−α0
ξ,ηDistance from the centre on the plate, to the east and to the north. The formula gives radians; multiply by 206 264.8 to get arcseconds.
cThe angle between the point and the centre of the plate.

In the code: geom.py · tan_project, engine.js · tanProject

Side view, schematic. The observer sits at the centre of the sphere; the line through the star hits the plate. Away from the centre, the distance on the plate (tan θ) grows faster than the distance on the sphere (θ). A real plate is so small that the difference cannot be measured; the number at the bottom of the figure shows this.
02

Sky level and noise of one exposure

In every exposure the sky itself glows a little, and every pixel is a little noisy. We have to measure both without being fooled by the stars. So we use the median instead of the mean: the value in the middle when the pixels are sorted. Pixels that are far off are thrown away, and the calculation is repeated.

m=med(v)σ=1.4826·med(|v−m|) |v−m|<3σ
vThe pixel values in the window of the exposure.
mThe sky level. It is subtracted from every pixel.
σThe noise of one pixel. Later steps use it as a weight.
medThe median. A few bright pixels shift the mean, but they cannot shift the median.
1.4826For bell-shaped noise, the number that turns the median of the deviations into a standard deviation.
3σThe second line is the clipping rule: only pixels closer than 3σ to the sky level stay, and m and σ are computed again. Five rounds.

In the code: frames.py · background

Schematic: 2401 synthetic pixels (49 × 49); the calculation really runs on this page. Pixels with stars in them make the tail on the right. The mean moves towards the tail; the median stays where it is. In each round the amber band (±3σ) gets a little narrower, and the pixels outside it are thrown away.
03

Putting an exposure on the common grid

Each exposure looks at the sky at a different angle. To compare them, we move them all onto one grid with north up. First we find which pixel of the exposure each grid point falls on. Then we work out the value at that point from the four nearest pixels.

(ξη)=M(xy)+c(xy)=M−1(ξ−cξη−cη) v=(1−fx)(1−fy)v00+fx(1−fy)v10 +(1−fx)fyv01+fxfyv11
x,yColumn and row in the exposure’s own pixels.
MA 2 × 2 table of numbers. It holds how many arcseconds one pixel covers on the sky and how far the exposure is turned.
cWhere pixel (0, 0) of the exposure sits on the plate.
fx,fyThe fractional distance of the point from the centre of the first of its four neighbours: between 0 and 1.
v00…v11The values of the four neighbouring pixels. A closer neighbour gets a bigger share; the four shares add up to 1.

M and c are found for each exposure separately, by fitting a linear map to 25 points taken from the file’s own coordinate information. The step of the common grid is 3.075″, half a SPHEREx pixel.

In the code: cube.py · fetch_exposure, frames.py · reproject, engine.js · reproject

Schematic. The tilted squares on the left are the exposure’s own pixels; the small plus signs are the points of the common grid. The amber point visits the grid points in turn; on the right you see its four neighbours and the share of each.
04

Stacking the exposures

A single exposure is noisy. When we average the exposures of one visit, the noise drops and faint sources appear. A clean exposure gets a big say, a noisy one a small say. A flash that shows up in only one exposure, such as a cosmic-ray hit, is left out of the average.

x¯=∑iwixi∑iwiwi=1σi2 σx¯=1∑iwi(σi=σ⇒σx¯=σN) |xi−med(x)|>max(8σi,2|med(x)|)
xiThe value of the same grid point in exposure i.
σi,wiThe pixel noise of that exposure (step 2) and its weight. Twice the noise means a quarter of the say.
x¯The value in the stack.
σx¯The error of the value in the stack. If all exposures have the same noise it is σ/√N: four times the exposures, half the noise.
med(x)The median of that point over all the exposures. The third line is the rejection rule: a value that meets it is thrown out.

The rejection rule works only when there are at least three exposures. The threshold is wide on purpose: a point source falls on a different part of a pixel in each exposure and its flux changes with wavelength, so a tight threshold would also remove real sources.

In the code: frames.py · combine, engine.js · combine

Schematic: 64 synthetic exposures; the stack is computed on this page with the rule above. The noise follows the 1/√N curve; the faint source at lower left only shows once there are enough exposures. The first exposure has a cosmic-ray hit (amber corners): it stays with one or two exposures and is rejected as soon as there is a third.
05

How bright is a point source?

The light of a star does not fall on one pixel; it spreads over the neighbouring pixels in a known shape, called the PSF. To find the brightness we ask: how much of this shape, plus how much flat sky, explains the pixels best? The first number in the answer is the flux.

di≈FPi+SPi=12πs2exp(−ri22s2) F=n∑Pidi−∑Pi∑din∑Pi2−(∑Pi)2σF=σnn∑Pi2−(∑Pi)2 F[µJy]=F[MJy/sr]×Ω4.2545×1010×1012
diThe value of pixel i in the 7 × 7 pixel box around the source.
PiThe value of the PSF at that pixel: a Gaussian peak whose total light is 1.
ri,sThe distance of the pixel from the source, and the width of the peak. s = FWHM / 2.3548; the FWHM (full width at half maximum) is written in the header of each exposure.
F,SThe two numbers we look for: the flux of the source and the sky level.
n,σThe number of pixels in the box, and the noise of one pixel (step 2).
σFThe formal error of the flux: it counts pixel noise only.
ΩThe area one pixel covers on the sky, in square arcseconds; it is in the header (about 38). 4.2545 × 10¹⁰ is the number of square arcseconds in one steradian; 10¹² turns MJy into µJy.

This is nothing more than fitting a straight line to points: P on the horizontal axis, d on the vertical axis. The slope of the line is the flux, and the place where it meets the axis is the sky level. If there is another known source nearby, it gets a column of its own and everything is solved together. The Gaussian peak is an approximation: it is good enough for positions and relative fluxes, and leaves a systematic error in absolute fluxes.

In the code: phot.py · forced_flux, engine.js · forcedFlux

Schematic: the 7 × 7 pixel box of a single exposure. The noise is fixed; you choose the flux of the source. On the right each pixel is one point, and the slope of the amber line is the measured flux. Even at zero flux the slope is not exactly zero: that is the noise, and the error bar tells you so.
06

Where exactly is a source?

The position is the centre of gravity of the light. The two engines find it in different ways, and we say so openly. The Python engine fits a Gaussian peak to the image. The browser engine slides a window onto the source, step by step.

Python Gi=Aexp(−(xi−x0)2+(yi−y0)22s2)+B χ2=∑i(Gi−ziσi)2→min Browser gi=exp(−(xi−xc)2+(yi−yc)22s2) Δx=2∑igizi(xi−xc)∑igizixc←xc+Δx
zi,σiThe value and the error of pixel i of the stack; the pixel sits at (x, y).
x0,y0The position we look for. A is the height of the peak, B the background, s the width. All five are varied together until χ² is as small as possible.
χ2The misfit: the sum of the squared differences between model and pixels, in units of the error.
xc,ycThe current centre of the window. The same formula is used for y.
giThe weight of the window: a pixel near the centre counts a lot, a far one counts little.
ΔxThe correction in one step. It stops when this falls below 0.01″, after 12 steps at most. The 2 in front is there because a window as wide as the source halves the offset that is measured.

HonestlyThe two methods do not have to give exactly the same answer for the same source. On WISE 0855, after the filter of step 7, the browser finds (−62.34″, +5.11″) and Python finds (−62.35″, +5.13″): a difference of 0.03″.

In the code: phot.py · fit_centroid, engine.js · centroid

The browser engine’s method on a synthetic source; the calculation runs on this page. The amber ring is the window, the plus sign is the true place of the source. In each step the window moves towards the centre of gravity of the light; the bars on the right show the size of the step.
07

Removing ordinary stars by their colour

A cold dwarf is bright at 4–5 µm and almost invisible at 3–3.8 µm. Ordinary stars show in both images, and the ratio of their brightness in the two is nearly the same for all of them. If we multiply the short-wavelength image by this ratio and subtract it from the long-wavelength image, the stars cancel and the cold object stays.

R=W2s−k·W1sk=medjW2sjW1sj σR=σW2s2+k2σW1s2
W2sThe stack of the 4.0–5.0 µm window.
W1sThe stack of the 3.0–3.8 µm window.
kThe median flux ratio of the field’s own stars. Stars closer than 12″ to the target are left out.
jThe reference stars in the field.
R,σRThe image that is left, and its error. The position (step 6) is measured on this image.
WISE 0855, October–December 2025
k = 0.655 · 13 stars
April–May 2026
k = 0.593 · 10 stars

Why it is needed: today WISE 0855 sits 4–8″ from a fixed background star. Positions measured with the filter agree with the blind prediction within 1σ; without it, blended with the star, the measurement is off by 6σ in the worst epoch.

In the code: package.py · star_colour, analysis.py · spherex_epochs, engine.js · coldFilter

Schematic. The ratio of each of thirteen stars is a tick on the axis below; their median is 0.655. Move the slider to the median: the stars fade, and the cold source inside the amber corners stays. The stars do not vanish completely, because their colours are not exactly the same. If k gets too large the stars turn into dark holes.
08

The motion model: a straight path plus a yearly wobble

A nearby object does two things on the sky: it moves along a straight line and, because Earth goes around the Sun, it draws a small wobble once a year. The model is the sum of the two. It has five unknowns, and we find all five together as the values that fit the measured positions best.

ξ(t)=ξ0+μξ(t−t0)+ϖPα(t) η(t)=η0+μη(t−t0)+ϖPδ(t) Pα=Xsinα−Ycosα Pδ=Xcosαsinδ+Ysinαsinδ−Zcosδ Least squares p^=(ATWA)−1ATWyχ2=∑i(riσi)2 σp=diag[(ATWA)−1]·max(1,χ2ν)ν=2n−5
ξ0,η0Where the object is at time t₀ (east and north on the plate).
μξ,μηProper motion: how many arcseconds the object moves in a year.
ϖParallax: the size of the yearly wobble, in arcseconds.
Pα,PδThe parallax factors: on that day, which way and how far the object appears shifted because of where Earth is.
X,Y,ZWhere Earth is on that day, in astronomical units (our mean distance from the Sun is 1). α and δ are the place of the object on the sky.
p^,yThe best values of the five unknowns, and the measured positions (two numbers per epoch).
A,WA is the table that says how much each measurement depends on each unknown; W holds the weights, 1/σ².
ri,χ2Measured minus model, and the total misfit.
νDegrees of freedom: the number of measurements minus the number of unknowns (n is the number of epochs). If the measurements scatter more than their errors allow, χ²/ν is larger than 1 and the errors are made larger by that ratio.
WISE 0855μα ″/yrμδ ″/yrϖ ″χ² / ν
WISE + SPHEREx−8.125 ± 0.009+0.686 ± 0.0120.502 ± 0.03866 / 47
Published−8.118 ± 0.008+0.680 ± 0.0070.439 ± 0.002

The WISE detections that belong to the target are selected with the proper motion only; the parallax plays no part in the selection. So the parallax that comes out of the fit cannot have been put in by the selection.

In the code: geom.py · parallax_factors, propagate; motion.py · fit5; engine.js · parallaxFactors

Real measurements: WISE 0855, 23 WISE epochs (red) and 3 SPHEREx epochs (blue). The vertical axis is the wobble left in the east–west direction after the straight motion is removed. The slider changes the parallax; the other four unknowns are fitted again each time. The curve at the bottom shows the misfit (χ²): the best parallax is where it is lowest.
09

From parallax to distance and speed

The smaller the wobble, the farther away the object is. Once we know the distance, we can also turn the motion on the sky into a real speed.

d=1ϖvt=4.74μd
ϖParallax, in arcseconds (step 8).
dDistance, in parsecs (pc). An object with a parallax of exactly 1″ is 1 pc away.
μTotal proper motion, in arcseconds per year.
vtTangential speed: the speed across the line of sight, in km/s.
4.74The speed, in km/s, of an object that covers 1 astronomical unit in a year.
WISE 0855, measured parallax
0.502 ± 0.038″ → ≈ 2.0 pc
published
0.439″ → 2.28 pc
tangential speed, catalogue values
≈ 88 km/s

The honest statement: 0.50 ± 0.04 (statistical) ± 0.09 (systematic)″; the parallax is 1.7σ above the published value. The systematic is the part of the difference between the two halves of the WISE epochs that noise does not explain. WISE sets almost all of this value: SPHEREx's three epochs change it by 0.002″. Distance is not computed from the shift: the shift is proper motion, and distance comes from parallax. The distance and speed shown in the tool use the catalogue parallax.

In the code: analysis.py · _shower (1/ϖ), vr.js · updateMeas (4.74 μ / ϖ)

Schematic; the angles are made much larger so that they can be seen. Six months apart, Earth looks from the two ends of its orbit, and the direction to the object changes by 2ϖ. The speed is computed with the catalogue proper motion of 8.15″ per year. Move the slider to 0.439″ and you get the published distance (2.28 pc) and 88 km/s.
10

Is it real? Controls

In a crowded field, even a spot that looks empty holds light from stars that cannot be told apart. If a candidate’s signal is real, the same measurement at hundreds of empty positions should rarely look the same. First we remove the common colour of the stars. Then we join two bands into one number. Last, we count: how many empty positions came out this high?

E=F−cFrefc=medi<jFi−FjFref,i−Fref,j S=∑bTbEb/σb2∑bTb2/σb2p=n+1N+1
FThe flux in a long band: 3.8–4.4 or 4.4–5.0 µm.
FrefThe 2.4–3.8 µm flux. A cold dwarf is dark here; ordinary stars are not.
cThe common colour of the empty positions: the median of the slopes of the lines through every pair of positions (the Theil–Sen slope). A few odd positions cannot spoil it.
EThe colour excess: the light that stars cannot explain. The median of the controls is set to zero.
Tb,σbb counts the two long bands. T is the shape of a Y dwarf across them: 0.53 and 1. σ is the scatter of E at the empty positions (1.4826 · MAD).
SThe matched filter: it adds the two bands into one number, with weights that suit the shape we look for.
N,nThe number of empty control positions, and how many of them reach the target’s value of S.
pThe chance probability. It comes from counting, not from a formula for the noise. The +1s count the target itself, so p is never zero.
SMDET-1: scatter, 4.4–5.0 µm
333 → 75 µJy
empty positions that reach the target
25 / 300
chance probability
26 / 301 ≈ 8.6%

Not a detectionThis is the result for SMDET-1: 25 of the 300 empty positions reach the same value. It is not a detection; it puts a number in place of the word “inconclusive” and shows that colour can push the crowding noise down. For WISE 0855, none of 150 empty positions reaches the target’s value.

In the code: analysis.py · cold_candidate, colour_excess

Real measurements: the SMDET-1 field, 300 empty positions (points) and the target (amber). The horizontal axis is the 2.4–3.8 µm flux, the vertical axis the 4.4–5.0 µm colour excess. At c = 0 the cloud is tilted and the scatter is large; at c = 0.52 the cloud lies flat and the band narrows. The target still sits among the controls. The count here is for one band (24 / 300); the 26 in the text is for S, which joins the two bands.
11

A light curve from a survey that never repeats a wavelength

SPHEREx sees a star at a different wavelength in every exposure. Did the brightness change, or is it just a different colour? To separate the two we assume this: the shape of the star’s spectrum stays the same, and only the whole of it gets brighter or fainter. Then, in the logarithm, two parts add up, and we solve for both together.

lnF(λ,t)=s(λ)+a(t)∑ka(tk)=0 Δm(t)=2.5ln10a(t) Period Δm(t)≈c0+c1sin2πtP+c2cos2πtP
F(λ,t)The flux measured at time t and wavelength λ. Each exposure is one pair (λ, t).
s(λ)The mean spectrum of the star (its logarithm).
a(t)The change in brightness that all wavelengths share: the light curve. One value for each 10-day bin.
∑a=0The condition that keeps the two parts apart: the light curve has zero mean.
ΔmThe same change in magnitudes; plus means brighter.
PThe period, in days. It is tried in steps of 0.5 day; the one with the smallest misfit (χ²) wins.
c0,c1,c2Found by least squares for each P. The peak-to-peak amplitude is 2√(c₁² + c₂²).
R Draconis, fitted period
267 days
honest range
250–280 days
published
245.6 days

The formal result is 267 ± 5 days (45 bins, χ² 150.7 / 42), with 1.7 magnitudes from peak to peak. But the data span 520 days, only 1.95 cycles, and the formal error understates the real uncertainty; the right statement is “about 250–280 days”. The core is saturated in 99.6% of the exposures, so the flux was measured in the wings of the image.

In the code: variable.py · decompose, period_fit

Real measurements: the light curve of R Draconis, 45 bins with at least five exposures each. The slider changes the period; the amber curve is the sine that fits best with that period. The curve at the bottom shows the misfit (χ²). Hollow points are bins with fewer than five exposures; they are not used in the fit.
12

Stereo depth

The left eye sees epoch A, the right eye sees epoch B. A star that stayed put falls on the same spot for both eyes and appears on the plate. An object that moved falls on slightly different spots, and the brain reads this as depth. The amber ring in the headset is placed at a chosen depth in the same way.

Z=DIPDIPD−dd=ΔWθ M=2arctan(W2D)θ
ZThe distance at which the object (or the ring) appears.
DThe distance from the eyes to the plate: 2.0 m.
IPDThe distance between the two pupils: 63 mm.
dHow far apart the two eyes’ images are on the plate, in metres. If it is positive the object appears behind the plate; if negative, in front of it.
ΔThe shift of the object between the two epochs, in arcseconds.
W,θThe width of the plate (1.6 m) and the field of sky it shows (5.0′, about 300″).
MThe magnification: the angle the plate covers for the eye, divided by the real angle of the patch of sky it shows. About 520.

LimitAs d gets close to the eye separation, Z goes to infinity. If d is larger still, the sight lines never meet and the image doubles. The roughly 130″ shift of WISE 0855 between 2010 and 2026 is 43% of the plate; in the headset that is about 19° apart, and it cannot be fused. Stereo is for shifts of a few arcseconds. Whether stereo is better than blink has not been measured, and that the object separates in depth has not yet been confirmed in the headset.

In the code: vr.js · updateMeas (Z), arcsecPerM (d), mag (M)

Seen from above, schematic: the sideways scale is stretched. The red and blue dots are the two images of the object on the plate; the amber dot where the sight lines cross is where the object appears. Make the shift larger: the crossing moves away; on a 5′ plate the lines become parallel at about 12″ and no longer meet.
13

The injection test: would you have seen it?

We add a synthetic source of known brightness and known shift to the real exposures, and see whether it is found. We choose its brightness as a multiple of the noise at that spot. The same list of trials goes to people and to a machine observer. In the end we have numbers like “9 of 10 trials”, and we give an interval that says how far they can be trusted.

Flux of the source σF=1∑i1/σF,i2Finj=SN·max(σFA,σFB) Machine observer z=|⟨B−A⟩3×3−med|1.4826·MADz>5 Wilson interval p^=knp^+12n±p^(1−p^)n+14n21+1n
σF,iThe formal flux error at the source position in exposure i (step 5).
σFAll the exposures of one epoch together: the flux error of that epoch. A and B are the two epochs; the larger of the two is used.
S/NThe chosen formal signal-to-noise ratio: 6, 10 or 16.
⟨B−A⟩3×3The 3 × 3 pixel mean of the difference plate. med and MAD are the median and the median deviation of this mean over the whole plate.
zHow many sigmas is the difference? The source counts as “found” if z is above 5 within 12″ of it, and below 5 there on the plate without the injection.
k,nThe number of hits and the number of trials.
±The two ends of the Wilson interval: the range that most likely (1σ, about 68%) holds the true rate. It still makes sense for extreme results such as 0 / 10 or 10 / 10.
closed loop: injected, recovered
275.85 → 275.85 µJy
exposures recovered
40 / 40

Not yet runThe human experiment has not been run yet. The numbers here belong to the machine observer alone; they do not hold for human observers and say nothing about stereo versus blink.

In the code: inject.py · flux_sigma, build_trial, zmap; experiment.js · wilson

Real results of the machine observer: WISE 0855 field, 4.0–5.0 µm, 5σ threshold. Each row is one cell: the dot is the rate found, the thick line is the Wilson interval. The amber row at the top is yours: choose how many of 10 trials were hits and watch the interval change. In the nine-trial cells one position fell in a corner that no exposure covers.
14

The cost of reading the archive

The tool does not download whole files; it asks only for the header and the pixel rows it needs. Before it downloads anything, it uses this formula to estimate how many bytes a field will cost, and shows the number in the interface.

B≈N×[H+o+n(4n+o)]n=2h+1
B,NThe total number of bytes, and the number of exposures.
HThe header read: 31 680 bytes (11 blocks of 2880 bytes).
oThe overhead of each request: 750 bytes.
n,hOne side of the window and its half-size, in pixels. For a 5′ window h = 24 and n = 49.
4n+oThe cost of one row. Each row is a separate request: n pixels of 4 bytes each, plus the overhead of the request.
per exposure
≈ 80 kB
358-exposure, 5′ field
≈ 29 MB
same job, cutout service
≈ 1.4 GB

The cutout service sends a 3.86 MB PSF table with every cutout: 3.95 MB per cutout. The estimate holds: for a 450-exposure field that had never been opened before (Luhman 16) the formula said 35.5 MB, and the measured total was 36.4 MB (catalogues included).

In the code: cube.py · estimate_bytes, remote.py · _HEAD_BYTES, net.py · OVERHEAD

The bar at the top shows the bytes of a single exposure: the largest share is not the pixels but the header and the overhead of 50 separate requests. The two bars below are on the same scale. For 358 exposures the formula gives 28.2 MB; the number in the README is about 29 MB.

The story of the method behind these formulas is on the “How it works” page; all the numbers and their limits are in the repository’s README. None of them says that we discovered a new object.

Open the tool How it works Back to top