Cache per-frame WCS and aperture geometry for light-curve measurement#130
Merged
jnation3406 merged 1 commit intoJul 16, 2026
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR optimizes aperture-photometry/light-curve generation by caching per-frame WCS and pixel-space aperture geometry and by streaming full-resolution pixel data one frame at a time, reducing repeated FITS/WCS work and peak memory usage while keeping outputs identical.
Changes:
- Introduces
FrameGeometry(cached WCS + aperture/annulus radii in pixels) and threads it through target/candidate measurement paths. - Streams SCI pixel data per frame via
_load_frame_image/_measure_frame_pixelsand adds a downsampledFramePreviewfor diagnostics overlays (avoids reloading pixels for rendering). - Adds
get_fits_headerand updates analysis endpoints/tests to avoid decompressing large compressed SCI images when only metadata is needed.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| datalab/datalab_session/utils/photometry_diagnostics.py | Adds FramePreview + downsampled preview generation; overlays now draw on previews instead of full-res images. |
| datalab/datalab_session/utils/fits_metadata.py | Adds FrameGeometry and frame_geometry() to cache WCS and pixel radii per frame. |
| datalab/datalab_session/utils/file_utils.py | Adds get_fits_header() to read headers without forcing SCI decompression; clarifies get_hdu() behavior. |
| datalab/datalab_session/utils/comparison_stars.py | Refactors comparison selection to operate on pre-measured per-frame measurements; measurement uses cached FrameGeometry. |
| datalab/datalab_session/utils/centroiding.py | Avoids forced float64 conversion to prevent copying full frames per centroid call. |
| datalab/datalab_session/utils/aperture_light_curve.py | Major refactor to validate metadata without pixels, then stream per-frame pixel measurement; builds diagnostics previews; reduces CAT-column retention. |
| datalab/datalab_session/tests/test_operations.py | Updates operation tests for new FileCache usage and generate_light_curve(fits_paths=...) API. |
| datalab/datalab_session/tests/test_aperture_photometry.py | Updates tests to use FITS paths; adds tests for streaming pixel loading and preview scaling/overlay behavior. |
| datalab/datalab_session/data_operations/aperture_photometry.py | Resolves FITS paths via FileCache and passes fits_paths into generate_light_curve. |
| datalab/datalab_session/analysis/wcs.py | Uses get_fits_header() to avoid decompressing SCI image data for WCS inspection. |
| datalab/datalab_session/analysis/source_catalog.py | Avoids loading SCI pixel data by using get_fits_dimensions() instead of sci_hdu.data.shape. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
jnation3406
changed the base branch from
main
to
fix/optimize_aperture_photometry
July 16, 2026 23:51
jnation3406
approved these changes
Jul 16, 2026
jnation3406
left a comment
Contributor
There was a problem hiding this comment.
Looks good other than some duplication of the wcs helper functions. I'm going to merge it into my branch and continue adding to it there.
jnation3406
merged commit Jul 16, 2026
fef55b5
into
fix/optimize_aperture_photometry
4 checks passed
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.
Add FrameGeometry (fits_metadata), built once per frame, holding the cached WCS plus the aperture/annulus radii in pixels, and thread it through _measure_target and measure_candidate_on_frame. WCS builds drop from ~4 per candidate to ~2 per frame.
Testing on the NGC7331 in rp data set on my machine confirmed that the results are identical but run time falls from 72s to 16s.