Repository navigation
Conversation
…variable in astrsolve Two bugs fixed: 1. mosaic.c: SAME_CRVAL overwrote all detectors' CRVALs with the field mean without adjusting CRPIX or CD. This collapsed all detectors to the same sky position, breaking the virtual-image matching step for multi-detector instruments. Now uses crval_to_crpix() like the other mosaic types, which preserves each detector's sky footprint while sharing a common tangent point. Tested with VIRCAM 16-detector data (30 exposures): internal astrometric residuals went from 1.46" (broken) to 0.018" (fixed), matching the performance of LOOSE and FIX_FOCALPLANE modes. 2. astrsolve.c: In the loop computing findex2 adjustments per instrument, the code used a stale `instru` variable (set by the previous loop's last field) instead of the loop variable `i`. This is harmless for single-instrument setups but would corrupt the normal equation matrix dimensions for multi-instrument configurations.
ebertin
left a comment
There was a problem hiding this comment.
Thank you for your PR! You will find my comments inline.
| if (prefs.mosaic_type[field->astromlabel] == MOSAIC_SAMECRVAL) | ||
| for (s=0; s<field->nset; s++) | ||
| { | ||
| for (d=0; d<naxis; d++) | ||
| sets[s]->wcs->crval[d] = wcsmean[d]; | ||
| init_wcs(sets[s]->wcs); | ||
| range_wcs(sets[s]->wcs); | ||
| invert_wcs(sets[s]->wcs); | ||
| } | ||
| else | ||
| for (s=0; s<field->nset; s++) | ||
| crval_to_crpix(sets[s]->wcs, wcsmean); | ||
| for (s=0; s<field->nset; s++) | ||
| crval_to_crpix(sets[s]->wcs, wcsmean); |
There was a problem hiding this comment.
I think you misunderstood the goal of the MOSAIC_TYPE SAME_CRVAL option, which is to bring the CRVALs of all extensions to a common set of coordinates without compensating the possible shifts using the CDs and CRPIXs. It is generally used in conjunction with a .ahead file defining the focal plane of a mosaic instrument (where the CRPIXs and CDs are known to be correct), when the original CRVALs have been re-adjusted individually (common among simple astrometry calibration pipelines). What you actually want is what the MOSAIC_TYPE SHARE_PROJAXIS option already provides (the "else" code path here). So, in short, no code change is required here.
| for (i=0; i<ninstru; i++) | ||
| { | ||
| if (prefs.stability_type[instru]!=STABILITY_PREDISTORTED) | ||
| if (prefs.stability_type[i]!=STABILITY_PREDISTORTED) |
In astrsolve_fgroups() the loop at src/astrsolve.c:273 iterates `i` from 0 to ninstru, but the stability_type[] check inside used the variable `instru` (set at line 193 to field->astromlabel from the previous loop) instead of the current loop variable `i`. For single-instrument setups the two indices match and this has no effect. For multi-instrument configurations with mixed STABILITY_TYPE values per instrument, the check would consult the wrong instrument and potentially mis-size the normal equation matrix. Fix: use `i` as the index into prefs.stability_type. Split out from astromatic#38; the mosaic.c portion of that PR is being dropped (SHARE_PROJAXIS already provided the intended behaviour).
|
Thank you for the detailed review @ebertin. You're right on both counts:
Closing this PR in favour of #39. |
Summary
MOSAIC_TYPE SAME_CRVALoverwrote all detectors' CRVALs with the field mean without adjusting CRPIX or CD. This collapsed all detectors to the same sky position, breaking the virtual-image matching for multi-detector instruments (e.g. VIRCAM). Now usescrval_to_crpix()like the other mosaic types, preserving each detector's sky footprint while sharing a common tangent point.findex2adjustments per instrument (line 275), the code used a staleinstruvariable from the previous loop instead of the current loop variablei. Harmless for single-instrument setups but would corrupt the normal equation matrix for multi-instrument configurations.Test results (VIRCAM, 16 detectors, 30 exposures)
All modes now produce equivalent results with
STABILITY_TYPE INSTRUMENT.Test plan
astrsolveindexing is unchangedastrsolvefix not tested (no multi-instrument data available)