# Background repair candidates and three-epoch validation — 2026-10-03

**Conclusion:** an experimental component-crop detector preserves most of the
original anomaly mask and suppresses the identified distant-source coupling.
Combined with harmonic filling and positive RMS interpolation, it completes
the selected three-epoch tests. Circular local gates fail correlated-noise
controls and are not adopted. This is candidate development, not acceptance
of a corrected light-curve product. The full instrument-free/photon-noise goal
remains unmet; current RAW photometry and production outputs are unchanged.

Run: `/astro/armin/koji/syndiff/dev_runs/temporal_raw_epsf_20261001/`.
Code: `/home/kshukawa/syndiff_pipeline/dev/.worktrees/temporal-raw-epsf`,
local branch `codex/temporal-raw-epsf`. No push, merge or PR.

## Preserve detection capability, not just a quiet response

The previous `BACKGROUND_ANOMALY_LOCALITY.md` showed that disabling SEP
deblending suppresses the tested coupling but reduces anomaly-mask coverage.
Two alternatives were developed:

1. **Local gates:** finite-neighbourhood peaks, quadratic 3×3 refinement,
   circular acceptance (radius 3 or 2) or a locally estimated ellipse.
   Local noise and the original 2–5-pixel growth acceptance are retained.
   The ellipse uses positive intensity inside radius 5 after a 4–5-pixel
   median pedestal subtraction; a 0.35-pixel axis floor prevents degeneracy.
   These are anomaly descriptors, not stellar PSF-width estimates.
2. **Component crops:** find undecomposed islands without cleaning, run SEP
   in each bounding box plus two guard pixels, and keep only detections whose
   filtered peak belongs to that parent. Coordinate offsets are restored.
   SEP's shape/growth machinery remains, with a separate random sequence per
   crop. Boxes may overlap or contain other islands, and large islands remain
   large: this is not a guarantee of strict fixed-radius locality everywhere.

Numerical checks cover peak geometry, distant invariance, compact recovery,
invalid/empty support, local plateau ties and callback binding. The component
test preserves the separated blend's shape and flux exactly when the other
blend is removed, and passes coordinate-translation and empty-image checks.

| Method | All anomaly-mask pixels | Eligible background-repair pixels |
|---|---:|---:|
| Original | 46,843 | 29,893 |
| No deblending | 15,727 | 9,950 |
| Local radius 3 | 288,582 | 150,195 |
| Local radius 2 | 399,457 | 220,963 |
| Local ellipse | 111,002 | 68,756 |
| Component crops | 47,569 | 30,562 |

The component mask retains 45,453/46,843 original marked pixels (97.0%),
or 29,109/29,893 original eligible pixels (97.4%). These are agreement
statistics, not ground-truth completeness. The tested component and local
gates have zero changed mask pixels beyond 400 pixels in the sealed-input
case. Component cropping still needs more difficult locality/edge tests.

![Real masks on common pixel support](/astro/armin/koji/syndiff/dev_runs/temporal_raw_epsf_20261001/results/local_anomaly_comparison/real_masks.png)

![Underlying detector inputs and mask boundaries](/astro/armin/koji/syndiff/dev_runs/temporal_raw_epsf_20261001/results/local_anomaly_comparison/real_input_patches.png)

## Known-feature development corpus

Eight noise realizations contain fixed isolated/paired compact Gaussians and
broad controls. Peak amplitudes are 8, 16 and 32 in units of the supplied
noise RMS. White and correlated cases share the same random seeds. The
correlated noise is

$$\eta=\frac{G*\epsilon}{\sqrt{\sum_p G_p^2}}.$$

Here $\epsilon$ is independent zero-mean, unit-variance Gaussian pixel noise;
$G$ is a unit-sum two-dimensional Gaussian kernel with width 1.5 pixels and
radius 6; $*$ denotes convolution with periodic boundaries; and $\eta$ has
unit marginal variance in expectation. Normalization is analytic, not fitted
to each realized image. The index $p$ runs over kernel pixels. Detector
errors are supplied as one in these dimensionless test images.

The nominal 2–5-pixel-noise-radius subset has 56 isolated and 112 paired
placements per method/noise case. Reported rates are fractions of planted
centres marked, not resolved-source completeness. Noise seeds are reused
across amplitudes, so these are not independent-trial confidence intervals.
This corpus influenced development and is not a blind final validation.

| Method | Isolated, white / correlated | Paired, white / correlated |
|---|---:|---:|
| Original | 87.5% / 60.7% | 43.8% / 30.4% |
| Component crops | 87.5% / 60.7% | 45.5% / 29.5% |
| Local ellipse | 58.9% / 75.0% | 42.9% / 31.2% |

Circular radius-3/radius-2 gates mark 0.5805%/0.8661% of off-feature pixels
in the correlated corpus; the other methods mark none in this finite test.
No method marks a broad control's centre. These simplified tests do not
establish real-background false-positive rates. They reject the circular
candidates at these settings and show the ellipse's sensitivity tradeoff.

![Corpus scores with the actual denominators](/astro/armin/koji/syndiff/dev_runs/temporal_raw_epsf_20261001/results/local_anomaly_comparison/known_feature_scores.png)

![Actual planted-feature/noise images and masks](/astro/armin/koji/syndiff/dev_runs/temporal_raw_epsf_20261001/results/local_anomaly_comparison/known_feature_images.png)

## Complete background-step controls at the original epoch

All candidates remain process-local overrides of the frozen operator.
Baseline and perturbation are computed in the same process. The component
detector gives target errors −0.374672/+0.374672 ppm for +/-1-ppt injections;
its zero-input control is exactly zero everywhere. Its maximum distant
reference response in the positive control is 6.52e-6 ppm, compared with
97.186 ppm originally. Harmonic filling plus component crops gives a target
error of −0.072917 ppm. These are deterministic conditional responses, not
light-curve noise floors or bounds on all stars.

![Actual remote-aperture response images](/astro/armin/koji/syndiff/dev_runs/temporal_raw_epsf_20261001/results/local_anomaly_comparison/operator_response_stamps.png)

## A new-epoch failure exposes negative RMS interpolation

Original backgrounds at FFIs 1 and 601 replay bit for bit over the full CCD,
as did FFI 602. The component-only probes complete on those epochs. The
component+harmonic first-FFI run fails on four non-finite SEP ellipse shapes.
It is preserved as failed, not silently counted as successful.

The geometry audit finds all four peaks on negative values in SEP's
interpolated anomaly-noise RMS map. There are 68,775 nonpositive pixels,
including 22,722 eligible background-fit pixels; the minimum is −0.05453.
This is **not the archived FFI photon-uncertainty plane**. The version-matched
implementation interpolates RMS cubically, which need not remain positive.
[SEP 1.4.1 background evaluator](https://raw.githubusercontent.com/sep-developers/sep/v1.4.1/src/background.c).

An experimental alternative reconstructs the effective positive mesh from
the dense native map and interpolates those same nodes bilinearly:

$$r(x,y)=\sum_{i,j} w_{ij}(x,y)s_{ij},\qquad
w_{ij}\ge0,\quad\sum_{i,j}w_{ij}=1.$$

Here $s_{ij}$ are recovered coarse RMS estimates, in the anomaly map's
electrons/second/pixel units. The four bracketing-node weights $w$ are
dimensionless bilinear weights, with edge clamping. The interpolated $r$
has the same units and remains inside the positive nodal range. No pixels
are excluded and no arbitrary noise floor is added. This is a representation
change, not proof that the coarse estimates describe true detector noise.

Recovery follows the pinned evaluator's x/y knot conventions and recurrence.
A standard SciPy natural-spline reconstruction failed the dense replay guard
and was rejected. The correct pinned recurrence gives replay errors of
1.54/2.53/2.12 float32-peak units on FFIs 1/601/602, below the unchanged
16-unit threshold. Tests cover known meshes, negative cubic overshoot,
constant fields, the installed SEP evaluator and unsupported geometry.
Only complete 64-pixel meshes are currently supported; invalid or nonpositive
recovered nodes fail explicitly.

![Native and positive RMS representations](/astro/armin/koji/syndiff/dev_runs/temporal_raw_epsf_20261001/results/rms_interpolation_audit/rms_maps.png)

![Actual invalid-geometry locations and revised noise values](/astro/armin/koji/syndiff/dev_runs/temporal_raw_epsf_20261001/results/rms_interpolation_audit/rms_invalid_locations.png)

Re-extraction produces no invalid shapes in this first-FFI audit. Candidates
were not manually removed, but changing the noise representation changes
which weak peaks pass detection; it would be incorrect to say all detections
were preserved. The four original invalid shapes disappear through that
recomputed detection step. Signal/anomaly sensitivity needs broader checks.

## Three actual epochs

The comparison uses the first and last quality-zero FFIs of orbit 1 and the
first of orbit 2. Each uses its actual RAW core profile and r3 normalization;
all cube stamps are checked against direct FFI pixels. The conditional
3–30-pixel wing stays fixed. The same science/reference cohort is retained.

| Frame | Original target error [ppm] | Component-only [ppm] | Component + harmonic + positive RMS [ppm] |
|---|---:|---:|---:|
| 1 | −0.335951 | −0.336487 | −0.065943 |
| 601 | −0.451581 | −0.451662 | −0.085143 |
| 602 | +2.741488 | −0.374672 | −0.072832 |

The original distant failure is not triggered by this probe on frames 1 and
601, but is triggered on 602. The combined candidate's maximum remote-reference
response is 3.30e-5, 3.93e-5 and 3.02e-5 ppm in these three deterministic
tests. These values are not measured noise in real stellar light curves.
All strict harmonic solves converge below 1e-10 relative residual. No
full-cadence, full-source or astrophysical-amplitude acceptance follows.

![Measured response across the three epochs](/astro/armin/koji/syndiff/dev_runs/temporal_raw_epsf_20261001/results/background_epoch_validation/epoch_responses.png)

![Underlying paired images on a common scale](/astro/armin/koji/syndiff/dev_runs/temporal_raw_epsf_20261001/results/background_epoch_validation/epoch_response_images.png)

## Execution record and limitations

Code and source hashes are frozen in each named `condor/` job directory.
All result products and failed histories remain on `/astro`.

- Local/correlated development: 1846, 1849, 1853. Callback pilots 1854–1856
  failed before outputs because a closure captured a radius variable later
  reused as an array; a bound hook factory and integration test fix that bug.
  The ellipse retry completed; circular candidates were not rerun after their
  quality failure.
- Component validation 1866 was cancelled for a redundant median inside the
  object loop; termination was verified and only its empty output directory
  was removed. Corrected 1869 and independent corpus 1867 completed.
- Component operator 1873, negative/null/combined 1878–1880 completed.
- New-epoch preparation 1882/1883 and exact replays 1888/1889 completed.
  Probes 1897–1902 completed except combined-first-FFI 1899, which failed
  on invalid geometry and remains a failure.
- Geometry audit 1908, positive-RMS probes 1921–1923, RMS assessment 1924,
  candidate figures 1893 and three-epoch assessment 1933 completed.
- All nine published figures were inspected. No production code, background,
  uncertainty image, WCS or accepted light curve was changed.

Next broaden source/epoch validation and test shadow background corrections
on the actual RAW extraction with unchanged pixels, WCS/ePSF and signal
injections. A global background may address curvature that a local plane
cannot, but it must not absorb stellar wings or reference variability. Full
Hotpants/ePSF refits, normalized-amplitude preservation, multiscale magnitude/
colour/spatial tests and the complete noise budget remain required.

**Conclusion:** the crop-based detector and positive-noise representation
are concrete, tested experimental repairs for the identified failures.
Their limited controls pass without declaring quieter masks or numerical
zeros to be photon-limited science. The overall goal remains active.
