# Galaxy-light contamination in positive-profile training

**2026-10-05: controlled repair completed; not a photometric solution.** A conditional loss audit identifies
one training stamp as supplying about 88% of positive preference for a fitted
outer component in the profile for target 134. The actual larger RAW field
shows that retained pixels sample NGC 5985 light. Catalogue point-source
core masks do not describe that extended galaxy. Test whether removing its
contaminated training support removes the learned lobe, with all evaluation
pixels and target identities unchanged.

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

The source is auxiliary index 74, cube index 1206, Gaia
1602991234929899008, TESS magnitude 12.614. The fitted outer component
is centred at (−6,−6) pixels relative to the primary. Actual stamp pixels,
the original retained mask and the surrounding 41-by-41 field are under
`results/pooled_positive_profile_wings/lobe_trace/`. S24 FFIs 1/601 and S25
FFIs 0/584 exactly match their cached native stamps at the same detector
coordinates. S25 contains different sky and does not show the same feature
there; this is context, not an independent flat-field calibration.

The galaxy association uses coordinates transcribed from the
[NASA/IPAC NED05D table](https://w0.ned.ipac.caltech.edu/level5/NED05D/ned05D_5.html):
NGC 5985 at 15:39:37.1, +59:19:55.0 and NGC 5982 at 15:38:39.8,
+59:21:21.2. The corresponding measured header projection places the
galaxies on the observed extended objects. The live NED API request timed
out and supplied no data; the provenance is explicitly the indexed table,
not a downloaded API response. This is image-resolution object identification,
not precision astrometry or a new WCS fit.

![Independent galaxy positions on the actual RAW field](/astro/armin/koji/syndiff/dev_runs/temporal_raw_epsf_20261001/results/pooled_positive_profile_wings/lobe_trace/galaxy_identification.png)
![S24 and S25 at the same physical pixels](/astro/armin/koji/syndiff/dev_runs/temporal_raw_epsf_20261001/results/pooled_positive_profile_wings/lobe_trace/detector_context.png)
![Historical catalogue-core masks and retained light](/astro/armin/koji/syndiff/dev_runs/temporal_raw_epsf_20261001/results/pooled_positive_profile_wings/lobe_trace/native_mask_context.png)

## Declared comparison

Use the completed 304-component directional-wing model as the parent.
Place fixed circular training footprints of radius six TESS pixels at the
two independently tabulated galaxy positions, projected through the FFI1
header. These are diagnostic footprints, not measured isophotal radii or
an adopted universal mask. Four- and eight-pixel alternatives are supported
by the code but are not yet executed or selected by light-curve flatness.

The six-pixel geometry removes 12 previously retained training pixels,
all in auxiliary stamp 74. It removes no retained radius-two core pixel
in any training star at either epoch. The same 64-star pools, kernel weights,
normalization, dictionary, per-source free amplitude/sky model and regularization
strength remain. The ridge value is copied from each parent fit instead of
being recomputed after changing the mask. No training star is deleted.

Only pools for targets 134, 191 and 190 contain source 74. Refit those pools
at both FFIs from two starts, retaining the original convergence criteria.
Reuse the parent coefficients for the other pools only after checking their
complete pixel masks are identical. Record reuse separately from new training.
Recompute the parent target fits and require replay of saved predictions.
Then compare both arms on precisely the same old target pixels and source IDs.
All real photometric apertures, reference populations and count-loss products
remain unchanged during this diagnostic.

```bash
/home/kshukawa/syndiff_pipeline/syndiff_pipeline/common/orchestration/condor_wrapper.sh python temporal_raw_epsf/launch_diagnostics.py --local --job pooled_galaxy_mask_r6 --cpus 2 --memory 6000 pooled_positive_profile.py --refine-core --expand-wings --pool-sizes 64 --galaxy-radius 6 --save
```

Outputs: `results/pooled_galaxy_mask_r6/`; frozen code, exact command and
host/PID/exit record: `condor/pooled_galaxy_mask_r6/`. Save original/revised
training masks explicitly. Required checks are convergence, fixed-support
held-pixel residuals, same-exposure flux consistency, learned lobe changes
and canonical residual grids. A smaller lobe alone is not reliable photometry.

## Completed controlled results

The frozen local fit exited zero. Six affected epoch/pool fits were repeated;
both starts met the original stopping criteria in every case. The six
unaffected epoch/pool vectors were explicitly reused after checking identical
masks. Parent target predictions replay within numerical tolerance. Neither
the unchanged vectors nor their stored histories are counted as new fits.

The coefficient of the contaminating Gaussian at (−6,−6) pixels becomes zero
at FFI1 in all three affected profiles. At FFI601 its coefficients in profiles
134/191/190 are approximately 0.0000096/0.0000206/0, compared with parent
values 0.00468/0.00364/0.00400. These are mixture flux fractions, not measured
galaxy fluxes. The actual sampled profiles show disappearance of this lobe;
other irregular features remain.

![Exact training-pixel intervention](/astro/armin/koji/syndiff/dev_runs/temporal_raw_epsf_20261001/results/pooled_galaxy_mask_r6/geometry_assessment/training_pixels.png)
![Profile 134 before and after training repair](/astro/armin/koji/syndiff/dev_runs/temporal_raw_epsf_20261001/results/pooled_galaxy_mask_r6/assessment/profile_134.png)
![Profile 191 before and after training repair](/astro/armin/koji/syndiff/dev_runs/temporal_raw_epsf_20261001/results/pooled_galaxy_mask_r6/assessment/profile_191.png)
![Profile 190 before and after training repair](/astro/armin/koji/syndiff/dev_runs/temporal_raw_epsf_20261001/results/pooled_galaxy_mask_r6/assessment/profile_190.png)
![Unchanged profile 138](/astro/armin/koji/syndiff/dev_runs/temporal_raw_epsf_20261001/results/pooled_galaxy_mask_r6/assessment/profile_138.png)
![Unchanged profile 359](/astro/armin/koji/syndiff/dev_runs/temporal_raw_epsf_20261001/results/pooled_galaxy_mask_r6/assessment/profile_359.png)
![Unchanged profile 358](/astro/armin/koji/syndiff/dev_runs/temporal_raw_epsf_20261001/results/pooled_galaxy_mask_r6/assessment/profile_358.png)

| Pair | Parent held native RMS | Repaired-training held native RMS |
|---|---:|---:|
| 134 / 138 | 125.950 | 125.370 |
| 359 / 358 | 69.178 | 69.178 |
| 191 / 190 | 67.143 | 53.134 |

Each value is the median over two epochs and two evaluation halves, in units
of archived pixel uncertainty. Those uncertainties are not a pure Poisson
denominator. These are large residuals, not successful photometry.

![Actual pair 134/138 data and held residuals](/astro/armin/koji/syndiff/dev_runs/temporal_raw_epsf_20261001/results/pooled_galaxy_mask_r6/pooled_pixels_pair0.png)
![Actual pair 359/358 data and held residuals](/astro/armin/koji/syndiff/dev_runs/temporal_raw_epsf_20261001/results/pooled_galaxy_mask_r6/pooled_pixels_pair1.png)
![Actual pair 191/190 data and held residuals](/astro/armin/koji/syndiff/dev_runs/temporal_raw_epsf_20261001/results/pooled_galaxy_mask_r6/pooled_pixels_pair2.png)

Independent-pixel source estimates do not become consistent. For source 134,
the same-exposure half difference becomes −2.865/−2.662% at FFIs1/601;
for source 191 it becomes −1.724/−1.513%, and for source 190,
3.023/2.821%. Their absolute discrepancies increase despite reduced pixel
RMS. The unchanged pair 359/358 still has substantial discrepancies.

![Source rates and same-exposure half differences](/astro/armin/koji/syndiff/dev_runs/temporal_raw_epsf_20261001/results/pooled_galaxy_mask_r6/assessment/half_consistency.png)

The additional relative-time check is

$$r_h=F_{601,h}/F_{1,h},\qquad E=10^6(r_1/r_0-1).$$

Here $F_{t,h}$ is the fitted source rate in electrons/second at FFI $t$ from
training pixel half $h$; $r_h$ is its dimensionless epoch ratio; and $E$ is
the disagreement between those ratios in ppm. Common intrinsic source
variability and a constant multiplicative gain of each half cancel in the
ideal single-source model. Actual fitted rates also contain neighbour/sky
attribution and profile errors. There is no complete covariance-based
significance or claim that every nonzero value is instrumental.

| Source | Parent ratio disagreement [ppm] | Repaired-training disagreement [ppm] |
|---|---:|---:|
| 134 | 1882 | 2040 |
| 138 | 258 | 228 |
| 359 | 5854 | 5854 |
| 358 | −5665 | −5665 |
| 191 | 2154 | 2115 |
| 190 | −2186 | −2021 |

![Measured relative changes from both pixel halves](/astro/armin/koji/syndiff/dev_runs/temporal_raw_epsf_20261001/results/pooled_galaxy_mask_r6/relative_consistency/relative_changes.png)
![Optimization histories, with reused fits identified](/astro/armin/koji/syndiff/dev_runs/temporal_raw_epsf_20261001/results/pooled_galaxy_mask_r6/convergence/training_histories.png)

## Population support and execution

The canonical grids retain six unique sources, five inside the standard
bins, and no bin with the required five stars. Empty panels establish lack
of population support, not absence of residuals. All six diagnostic targets
remain in the source tables; they are not the complete science cohort.

![Parent absolute sparse grid](/astro/armin/koji/syndiff/dev_runs/temporal_raw_epsf_20261001/results/pooled_galaxy_mask_r6/residual_grids/parent/resgrid_raw_pooled_galaxy_mask_r6_parent_20261005.png)
![Parent relative sparse grid](/astro/armin/koji/syndiff/dev_runs/temporal_raw_epsf_20261001/results/pooled_galaxy_mask_r6/residual_grids/parent/resgrid_raw_pooled_galaxy_mask_r6_parent_20261005_rel.png)
![Repaired absolute sparse grid](/astro/armin/koji/syndiff/dev_runs/temporal_raw_epsf_20261001/results/pooled_galaxy_mask_r6/residual_grids/pool64/resgrid_raw_pooled_galaxy_mask_r6_pool64_20261005.png)
![Repaired relative sparse grid](/astro/armin/koji/syndiff/dev_runs/temporal_raw_epsf_20261001/results/pooled_galaxy_mask_r6/residual_grids/pool64/resgrid_raw_pooled_galaxy_mask_r6_pool64_20261005_rel.png)

Completed frozen jobs under `condor/`: `pooled_galaxy_mask_r6`,
`galaxy_training_geometry`, `pooled_galaxy_r6_assessment`,
`pooled_galaxy_r6_grids`, `pooled_galaxy_r6_convergence`, and
`pooled_galaxy_r6_relative`. All exit zero. Training ran for approximately
14 minutes on plscience3; local memory hints were not enforced. All figures
were inspected. The relative-check unit test verifies cancellation of common
stellar variability and fixed half gains, and recovery of a known response
change. No light-curve or count-loss product was replaced.

The next declared test holds these profiles fixed and fits shared versus
individual positions on disjoint pixel halves; see
`POOLED_POSITION_CONTROL_20261005.md`. More flexible profiles must still be
tested against colour/magnitude/spatial support and extended-scene leakage.

**Conclusion:** removing known galaxy pixels removes the corresponding false
PSF lobe, supporting a concrete training-contamination mechanism. It does
not solve independent-pixel relative photometry and cannot be adopted as a
complete repair. Calibration, WCS, temporal response, signal preservation,
full-population trends and physical photon-noise validation remain open.
