fix(wcs)!: Integrate AstroImages.jl with FITSWCS.slice_wcs - #117
Merged
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #117 +/- ##
==========================================
+ Coverage 55.28% 56.53% +1.24%
==========================================
Files 9 9
Lines 1069 1056 -13
==========================================
+ Hits 591 597 +6
+ Misses 478 459 -19 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
icweaver
marked this pull request as ready for review
July 11, 2026 08:36
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes the loop on the
slice_wcsintegration discussed in #113 (comment). Depends on JuliaAstro/FITSWCS.jl#17.Motivation
This PR aims to adopt
FITSWCS.slice_wcsto simplify the parent-frame bookkeeping here, and also fix several correctness bugs that were unearthed in the process.Bugs fixed
step-1: Legacy mapped slice-local --> parent asp*step + first - 1. Correct is(p-1)*step + first. The formulas agree only whenstep == 1, soimg[1:2:9, :]reported world coordinates one parent pixel off.dim[1] - 1.pixel_to_world(slice; all = true)reported, e.g.,FREQ = 1.0e9where the truth for a slice at parent index 2 is1.001e9. (Also affected the slice-label values inimplottitles.)parent = trueshifted by one pixel:pixel_to_world(img, p; parent = true)equaledraw(p .- 1), disagreeing with the default path on an unsliced image and shifting WCS-grid extents in the plot recipes by one pixel.world_to_pixelstuffed frozen pixel indices into world coordinate slots before inverting. Harmless only when axes are fully separable. Frozen axes now contribute their exact world values (one forward evaluation).world_to_pixelnow throws a descriptiveArgumentError(astropy'sSlicedLowLevelWCSsimilarly refuses) instead of returning wrong pixels.wcsdimslost on every slice: Bothrebuildmethods defaulted to recomputingwcsdimsfrom the already-sliced dims (DimensionalData no longer routes slicing throughrebuildsliced), which broke categorical (Stokes) refdim resolution and name-tracked transposition.rebuildnow preserves the parentwcsdims.New architecture (
src/wcs.jl)pixel_to_world: one body for all cases. Expand dims-ordered coords into the full parent frame (kept dims via their lookups, frozen refdims at their parent positions, degenerate header axes at CRPIX), evaluate the full transform, filter to the selected dims (all = truereturns every axis).world_to_pixel(default): Delegates to aSlicedWCSTransform(FITSWCS.slice_wcs) describing the current view, guarded byworld_keep == pixel_keep.world_to_pixel(parent = true): Unchanged contract for the WCS-grid plot recipes (naxiscoordinates, WCS axis order), now with exact frozen-axis world values._world_to_pixelworker are deleted. Docstrings now documentwcsn/all/parentand the 1-based FITS convention.world_to_pixel(img, ...)returnsndims(img)slice-local coordinates indims(img)order (was:naxisparent-frame values), making it the actual inverse ofpixel_to_world. Parent-frame output remains available viaparent = true.world_to_pixelthrows on slices that drop a pixel axis the remaining world axes depend on (was: silently wrong values).parent = trueno longer shifted by one pixel. WCS grid overlays now land at their true positions.