# PS1-to-template trace: a depression is present, but the former causal interpretation does not hold

> **Causal follow-up completed:** [paired injection and scene-list audit](/home/kshukawa/syndiff_pipeline/doc/ps1_injection_cause_20261002.md) locate near-star photon loss in footprint removal and show that the five saved fitting scenes omit recorded faint neighbours. Complete one-source tests recover the induced bright-flux error when the neighbour is included. The population contrasts below remain valid descriptive measurements, not a direct causal missing-flux budget.

> **Five-field extension completed 2026-10-02:** see the [five-field report](/home/kshukawa/syndiff_pipeline/doc/ps1_stage_trace_five_fields_20261002.md). The operator result holds across F1/F2/S22/C1/C4 in the tested interiors. The local canvas is updated in place; the original C4 numbers below are retained as the narrower initial experiment.

2026-10-02. C4 = Sector 23, camera 4, CCD 2, paper frame `tess2020087042920`.

## Conclusion

The template is lower at removed bright-star positions than at unrestricted control positions. In the tested C4 interiors this feature is already present in the published PS1 source-removal output. The subsequent Gaussian convolution broadens it, and direct binning and saved-kernel replay reproduce the actual TESS template and hp_c. There is no evidence in these checks for an additional unexplained loss introduced after the combined cells.

The former inference that a deficit at stars with zero recorded deleted neighbours proves an untracked background loss is invalid: untouched empty sky selected to lack nearby retained sources produces a comparable negative stack. Matching controls by local detector position and retained-source distance removes much of the actual contrast, but leaves a smaller residual. Thus neither “the whole effect is a pipeline bias” nor “there is no photometric bias” is justified. The remaining contrast needs a better matched scene or known-truth injection, not a new background pedestal imposed on the template.

This is a completed stage-trace milestone, not a finished certification of the photometry or all five fields. No production source, template, mask or fit was changed.

## Records and reproducibility

- Run directory: `/astro/armin/koji/syndiff/dev_runs/epsf_stage_trace_20261002/` (README, code copies, logs, tables, figures).
- Prior experiment: `/astro/armin/koji/syndiff/dev_runs/epsf_atlas_20261001/`.
- Diagnostic code branch: `codex/ps1-stage-trace`, initial checkpoint `ea9142c` in the nested dev repository; worktree `/home/kshukawa/syndiff_pipeline/dev/.claude/worktrees/codex-ps1-stage-trace`.
- Frozen processing source: `/home/kshukawa/syndiff_pipeline/.claude/worktrees/paper-pin`, commit `648c0bcf4b559691177f7b4764f721ac54aebdc8`.
- Frozen combined recipe: `e17a198a4942aa2d`, footprint_v1, Gaia RP<18; r/i/z/y weights **0.254/0.4368/0.1654/0.1438**. These are this experiment’s recorded weights, not the general site defaults.
- PS1 cells: projection 2528, 002/005/011/035/042/043/047/054.
- Input C4 bootstrap products: `/astro/armin/koji/syndiff/dev_runs/paper_dataset_20261001/C4/bootstrap/`.
- Local results canvas: `/home/kshukawa/syndiff_pipeline/doc/ps1_stage_trace_canvas/index.html`. PNGs are symlinks to the run directory. This session has no Claude Artifact publishing or SendUserFile tool; the existing remote Claude canvas has not been republished.

Commands, from `/home/kshukawa/syndiff_pipeline` after `source /home/kshukawa/miniforge3/etc/profile.d/mamba.sh` and `mamba activate syndiff`, with `OPENBLAS_NUM_THREADS=1 OMP_NUM_THREADS=1`:

```bash
python dev/.claude/worktrees/codex-ps1-stage-trace/forward_epsf_wcs/diagnostics/ps1_stage_trace.py --cells 005 002 011 035 042 043 047 054 --out /astro/armin/koji/syndiff/dev_runs/epsf_stage_trace_20261002
python dev/.claude/worktrees/codex-ps1-stage-trace/forward_epsf_wcs/diagnostics/ps1_raw_verify.py
python dev/.claude/worktrees/codex-ps1-stage-trace/forward_epsf_wcs/diagnostics/ps1_removal_replay.py
python dev/.claude/worktrees/codex-ps1-stage-trace/forward_epsf_wcs/diagnostics/ps1_trace_figures.py
python dev/.claude/worktrees/codex-ps1-stage-trace/forward_epsf_wcs/diagnostics/ps1_hpc_replay.py
python dev/.claude/worktrees/codex-ps1-stage-trace/forward_epsf_wcs/diagnostics/ps1_control_null.py
python dev/.claude/worktrees/codex-ps1-stage-trace/forward_epsf_wcs/diagnostics/ps1_control_null.py --match-bright-environment
```

## Method and what the comparisons mean

The tested chain is

$$I_1=Z(I_0),\qquad C=G_{40}*I_1,\qquad T=B[(1-M)C_{\mathrm{pad}}],\qquad H=K_\theta(T)+b.$$

- $I_0$: original band-combined PS1 pixels after the pipeline’s documented linear flux conversion, in PS1-combination flux units per PS1 pixel. One cell was freshly downloaded in all four bands and verified against the cached input.
- $Z$: the frozen SEP segmentation/background zeroing and bright-star footprint removal algorithm, with its recorded Gaia catalogue and masks. It is replayed, not fitted.
- $I_1$: published combined cell after source removal, in the same units as $I_0$.
- $G_{40}$: unit-sum discrete Gaussian with configured standard deviation 40 PS1 pixels and truncation radius 470 PS1 pixels. The asterisk denotes convolution.
- $C$: canonical PS1-grid convolved image. $C_{\mathrm{pad}}$ is the saved padding-aware convolved image read by downsampling; boundary padding itself is not independently rebuilt here.
- $M$: binary indicator of mask bit 12, from the saved convolved mask. Downsampling suppresses those pixel contributions.
- $B$: sum over the frozen PS1-to-OS4 assignment, with units changing from per PS1 pixel to per oversampled TESS pixel. The interior check excludes assignment seams.
- $T$: published oversampled TESS template, in PS1-combination flux units per OS4 pixel.
- $K_\theta$: Hotpants convolution and block-sum downsampling with the saved spatial kernel coefficients $\theta$. The kernel incorporates the conversion to TESS electron rate; no parameters were refitted.
- $b$: saved constant Hotpants background, 0.1569122709 electron/s per native pixel.
- $H$: published hp_c, in electron/s per native TESS pixel, including $b$.

Operator closure is the difference between each right-hand prediction and its saved output. This tests implementation and provenance, not whether the scientifically chosen removal model is ideal.

The old deficit statistic instead compares an aperture about a removed star with an aperture about a control:

$$D=\langle A(H,\boldsymbol{x}_s)-A(H,\boldsymbol{x}_c)\rangle.$$

- $D$: ensemble aperture contrast, electron/s.
- $A$: sum within 3 native pixels of the rounded stamp centre after subtracting the mean in the 20–30 pixel annulus, reproducing the old estimator; its subpixel annulus uses the catalogue position.
- $\boldsymbol{x}_s$: selected star or selected empty-sky position, in crop-local native TESS pixels.
- $\boldsymbol{x}_c$: control position, originally 25 native pixels east; matched-control tests choose positions by Gaia geometry.
- Angle brackets: arithmetic mean over selected positions. Errors for the new null/control comparisons bootstrap 128-pixel detector cells, 500 draws.

There is no reason for $D$ to equal the negative flux of deleted neighbours for each star: the control contains a different realisation of retained sources, and conditioning on no neighbours changes that source distribution. A small slope of $D$ against the deleted-neighbour prediction alone therefore does not establish an extra loss mechanism.

## Direct stage checks

| Check | Result | Supporting images and records |
|---|---|---|
| Fresh raw r/i/z/y combination, mask, uncertainty, cell 005 | Identical to cached arrays, including NaN patterns | `figs/raw_to_removal.png`, `tables/raw_verify.json` |
| Pinned removal replay, cell 005 | All 39,942,231 pixels identical; same 60 removal rows | `figs/removal_closure.png`, `tables/removal_replay.json` |
| Nonzero published combined pixels, all eight cells | Exactly unchanged from segmented pre-removal data | `tables/*_qa.json`; raw/removal images |
| Direct Gaussian vs canonical convolution, 24 star cutouts | RMS at approximately $10^{-9}$–$10^{-8}$ PS1 units/pixel after excluding both the 480-pixel overlap and kernel support | `figs/operator_closure.png`, `tables/*_qa.json` |
| Bin saved padding-aware inputs, including bit 12, vs saved contributions | 319,888 pure-cell interior output pixels; pooled RMS $2.85\times10^{-6}$ PS1 units/OS4 pixel; worst absolute $9.68\times10^{-5}$ | `figs/operator_maps.png`, `figs/stage_example.png`, `tables/operator_summary.json` |
| Saved contributions vs published template in same interiors | Exactly equal | same images and records |
| Saved Hotpants kernel replay | 356 patches including 87 removed-star centres; RMS $1.35\times10^{-6}$ electron/s/pixel, max $3.05\times10^{-5}$ | `figs/hpc_replay.png`, `tables/hpc_replay.json` |

The matched stage stacks use 114 directional pairs involving 65 star entries, with no relative isolation cut. Their central depression is already visible in $I_1$; its smoothing follows the ordinary Gaussian operator. The after-convolution, predicted-template and published-template radial curves overlap. These small-area stacks are descriptive and much noisier than the full-CCD control tests.

![Raw PS1 through source removal](/astro/armin/koji/syndiff/dev_runs/epsf_stage_trace_20261002/figs/raw_to_removal.png)
![Absolute stage stacks and differences](/astro/armin/koji/syndiff/dev_runs/epsf_stage_trace_20261002/figs/stage_stacks.png)
![Pixel-level prediction and residual maps](/astro/armin/koji/syndiff/dev_runs/epsf_stage_trace_20261002/figs/operator_maps.png)
![Hotpants saved-kernel replay](/astro/armin/koji/syndiff/dev_runs/epsf_stage_trace_20261002/figs/hpc_replay.png)

## Empty-sky null

Choose random positions and their 25-pixel-east controls, both farther than 5 pixels from a bright Gaia star. Do not change any pixels. Restrict the selected centres by distance to the nearest **retained** Gaia source with $13\le T<18$, where $T$ is catalogue TESS magnitude. Each row samples 4,000 positions.

| Exclusion radius (TESS px) | Selected-minus-control aperture contrast (electron/s) |
|---|---|
| 0 | $+3.5\pm4.8$ |
| 0.5 | $+3.2\pm4.8$ |
| 1 | $-23.7\pm5.2$ |
| 1.5 | $-55.8\pm4.9$ |
| 2 | $-93.7\pm4.6$ |

The images show a central negative blob generated by selection alone, at locations without a central bright-star removal. This disproves the uniqueness of the prior interpretation. It does not measure how much of each real star’s contrast is selection, and it does not show that removed faint sources are harmless for a scene model that omits them.

![Untouched-sky null: measured images](/astro/armin/koji/syndiff/dev_runs/epsf_stage_trace_20261002/figs/control_null_stamps.png)
![Untouched-sky null: aperture contrast](/astro/armin/koji/syndiff/dev_runs/epsf_stage_trace_20261002/figs/control_null_metric.png)

## Real stars with matched controls

Match zero-recorded-neighbour stars to four random positions in the same 128-pixel detector cell and the same 0.2-pixel bin of nearest retained-source distance. The controls are selected from Gaia positions, never central hp_c intensity. The stricter variant also requires real stars, their original shifted controls and matched controls to be farther than 5 pixels from **other** bright stars. This produces the following comparisons on the same retained real-star subset:

| TESS magnitude | Stars | Original shifted control (electron/s) | Matched control (electron/s) |
|---|---:|---:|---:|
| 8–10 | 213 | $-88.1\pm17.4$ | $-26.7\pm10.5$ |
| 10–11 | 469 | $-61.1\pm12.7$ | $-25.4\pm7.5$ |
| 11–12 | 1,255 | $-44.1\pm7.3$ | $-16.8\pm5.7$ |
| 12–13 | 3,076 | $-36.9\pm5.1$ | $-9.8\pm3.9$ |

Much of the contrast disappears with a more comparable source environment. The remaining negative contrast is about 2.5–3.4 statistical standard errors per bin and must not be declared zero. The match does not control retained-source brightness, the full neighbour scene, catalogue completeness, PS1 masked cores or source-detection thresholds; those are systematic uncertainties beyond the quoted bootstrap errors. The broad/lopsided residuals in the images also caution against treating the aperture sum as a pure central missing-flux component.

![Real stars and matched controls, absolute and difference stacks](/astro/armin/koji/syndiff/dev_runs/epsf_stage_trace_20261002/figs/matched_controls_brightmatched.png)

## Corrections, scope and next test

- The earlier claim “the extra loss must enter after the PS1 cells” is superseded for these tested interiors. Convolution broadens an existing source-removal depression; width alone does not locate new flux loss.
- The old Gaia-neighbour closure is an unmatched population comparison, not a direct pixel or causal closure. Its failure does not establish a diffuse pedestal or rule out deleted neighbours contributing to a real scene-model error.
- The prior relative-isolation bug remains important. None of the new operator checks uses that cut.
- During this work, the first Hotpants replay assertion exposed the difference between allocated and populated coefficient layouts. The saved background uses index 722; the unused allocated tail must not be read as background. Corrected before reporting any result.
- An exploratory array-statistics print attempted a percentile of a Boolean mask and failed; no scientific output depended on it. The final scripts operate on the appropriate float/count arrays.
- The first Gaussian comparison admitted a cutout whose kernel support reached the adjacent-cell overlap, where canonical row assembly can use different input pixels. Its small discrepancy was not a valid same-input closure test. The final check excludes the overlap plus kernel support plus measured window; it agrees at float precision. This is a geometry correction to the test, not a relaxed numerical tolerance.
- Published/raw PS1 contain unavailable pixels at bright-star cores. They are shown as unavailable in native-band figures; treating NaNs as zero during pipeline reproduction does not imply zero astrophysical sky there.
- Exact stage checks cover one fully refetched/reprocessed cell, eight cached-cell interiors and sampled Hotpants patches. They do not certify all projections, padding seams, kernels or fields. Kernel replay verifies application of the saved fit, not its scientific adequacy against an ideal sky.
- The prior V1 ePSF-estimator scores remain a separate unresolved issue; no new ePSF training was performed here.

**Next scientifically discriminating test:** inject known faint sources into matched PS1 scenes and propagate the **difference of identical scenes with and without the injected source** through source removal and the saved template operators. Condition on whether the source is recorded as removed, and evaluate the downstream scene model including those recorded sources. This supplies a known counterfactual photon budget and separates actual lost/omitted light from the empty-centre selection statistic. Do not add a template pedestal based on the old contrast alone.

**Final conclusion:** a central template depression is real as a descriptive stack; unexplained downstream processing loss is not supported by the direct trace. A smaller population-dependent residual remains, and an actual photometric bias has not yet been established or excluded.
