Skip to content

Feature/reprojection#117

Merged
capetillo merged 9 commits intomainfrom
feature/reprojection
Feb 20, 2026
Merged

Feature/reprojection#117
capetillo merged 9 commits intomainfrom
feature/reprojection

Conversation

@capetillo
Copy link
Contributor

FEATURE: Stacking - reprojection

Background
Users could only do simple stacking. So when the input data was intended to track objects in our Solar System, the stacked output would be blurry. Now, with reprojection, the users can stack input data with moving objects and the output shows the movement of the object with the alignment being in the background.

Implementation
We obtain the optimized_wcs and otpimized_shape by using wcs's find_optimal_celestial_wcs.
We then pass these two values to reproject_images_to_reference along with the list of input_fits and we get an array and a footprint.
These are then used to crop the data correctly. Because some values are NaN and therefore return jagged edges, we must remove them and find the largest internal rectangle in the footprint.
This is done through prepare_for_sum which takes the arrays (images) and footprints. We find the common_b(oundary)box by cropping the boundary box from the footprint.crop_bbox_from_footprint takes the footprints and returns the coordinates of rows and columns with the largest internal rectangle in the footprint per each footprint.
Then, we find where the boundary boxes intersect (intersect_bboxes) and return those coordinates.
Lastly, we crop the intersected boundary box.

Note: there is a library that would take care of the logic to find the largest internal rectangle, but it would mean adding another dependency @jnation3406 let me know what you think https://github.com/OpenStitching/lir

VISUALS

Screen.Recording.2026-02-17.at.2.30.02.PM.mov

First, we find the optimal reference using the wcs's find_optimal_celestial_wcs
We pass the inputs_fits_list, optimized_wcs, and optimized shape to
get the arrays and footprints using wcs's reproject_adaptive
Then, we pass the arrays and footprints to get the cropped data using prepare_for_sum
Which returns the largest interior rectangle found in the stacked images
Copy link
Contributor

@jnation3406 jnation3406 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few questions and comments but in general looks good. I think we will want to add reprojection as an option to other operations as well, so its probably worth moving all the helper functions into there own utils file. We should make another story and check in with Rachel on what other operations she wants to have the option to reproject on.

c0, c1 = cols[0], cols[-1] + 1

# now shrink until the *edges* are fully valid
while True:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This iterative approach seems like it'll be slow, but I can't immediately think of a more efficient way

Copy link
Contributor

@jnation3406 jnation3406 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great!

@capetillo capetillo merged commit dc82785 into main Feb 20, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants