Repository navigation
Fix group AstromCorr_*_HighSN exceeding 1 in astrstats_fgroup() - #43
Conversation
The group-level (FGroups) high-S/N astrometric error-floor correlations AstromCorr_Internal_HighSN and AstromCorr_Reference_HighSN written to scamp.xml could exceed 1.0, which is impossible for a Pearson correlation coefficient. Root cause in astrstats_fgroup() (src/astrstats.c): the high-S/N group correlations were normalised using the FULL-sample cross-product numerators (gcorr_int, gcorr_ref) divided by the high-S/N counts (nsource_hsn, nmatch_hsn), inflating the result by a factor of N_all / N_highSN. The correctly built high-S/N numerators (gcorr_int_hsn, gcorr_ref_hsn), already scaled by the high-S/N sigma, were computed but never read (dead code). Additionally, the internal high-S/N numerator accumulated the full-sample cross-product 'corr' (about the full-sample mean) instead of the high-S/N cross-product 'corr_hsn' (about the high-S/N mean). Fixes: - accumulate gcorr_int_hsn from corr_hsn instead of corr - normalise sig_corr_int_hsn with gcorr_int_hsn (was gcorr_int) - normalise sig_corr_ref_hsn with gcorr_ref_hsn (was gcorr_ref) The non-HighSN group values and all per-field values are computed by separate, correct code paths and are unaffected.
|
Detailed root-cause analysis — kept out of the PR description for brevity. Expand below for the full write-up: the dead-code trace, the worked example with real FGroups counts, and why the non-HighSN group values and all per-field values are unaffected. Full bug report (click to expand)Group-level
|
|
Nice catch! Thank you @smeingast! |
The group-level high-S/N error-floor correlations in
scamp.xml(
AstromCorr_Internal_HighSN,AstromCorr_Reference_HighSN) are Pearsoncoefficients but routinely come out > 1. In
astrstats_fgroup()(
src/astrstats.c) they divide the full-sample numerator(
gcorr_int/gcorr_ref) by the high-S/N count, inflating the value by~
N_all / N_highSN; the correctly built high-S/N numerators(
gcorr_int_hsn/gcorr_ref_hsn, already scaled by the high-S/N sigma) werenever read — dead code. The fix uses them:
Diagnostic-only: no solver, cross-matching, or fitting code is touched.
Verification. A/B on a real 12-image VIRCAM stack, identical inputs, only
this patch differing: the two group values drop
2.92 → 0.53and2.02 → 0.26;every other
AstromCorrvalue (group non-HighSN and all per-field) is byte-for-byteunchanged, and 0 values now exceed 1.