examples: Hubble FITS denoising (train in place on a non-zarr archive)#16
Merged
Conversation
A cross-domain example on an archival format that never was zarr. Real Hubble WFC3/IR frames of M16 on MAST's public S3 bucket are indexed as virtual references (VirtualiZarr -> kerchunk.fits -> Icechunk) and streamed by insitubatch with no reshard: sample_axis=0 makes each frame one sample, a NaN-scrubbing + robust-normalizing chunk stage and a block-mean Coarsen run on the decode pool, and per-sample Gaussian noise lives in the batch stage. A tiny residual CNN denoiser beats a median-filter baseline (~26.4 vs ~24.7 dB PSNR). The build-time index stack (virtualizarr/kerchunk/astropy) is needed only to build the store; the train hot path is icechunk + numpy. Ships an offline synthetic source (sharp point sources a median filter can't keep) as the default -- no network or FITS stack -- which also backs tests/test_hubble.py, a drift guard on the insitubatch-facing wiring. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The median-filter baseline reached for scipy.ndimage, but scipy is only a transitive (scikit-learn/bench) dep -- so tests/test_hubble.py would fail on CI matrix jobs that don't install --extra bench (jax, tf, free-threaded). Replace it with a vectorized numpy median (edge-padded sliding windows), matching the pure-numpy baselines in the microscopy/advection examples, so the example and its test need nothing beyond insitubatch core (+ torch, already guarded). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
What
A cross-domain example that trains in place on an archival format that never was zarr: real Hubble WFC3/IR frames of M16 (the Eagle Nebula) on MAST's public S3 bucket (
s3://stpubdata, anonymous), indexed as virtual references (VirtualiZarr →kerchunk.fits→ Icechunk) and streamed by insitubatch with no reshard.examples/hubble/data.py— build the virtual-reference store, thedenoise_dataset, the chunk/batch transform stages, and the median-filter baseline.examples/hubble/train_torch.py— a tiny residual CNN denoiser.tests/test_hubble.py— a drift guard on the insitubatch-facing wiring.How it maps onto the engine
sample_axis=0→ each FITS frame is one sample (one image = one chunk).clean_normalize→ block-meanCoarsen) runs vectorized on the decode pool; per-sample Gaussian noise lives in theAddNoisebatch stage — per the transform-cost contract.virtualizarr/kerchunk/astropy) is needed only to build the store; the train hot path isicechunk+ numpy (kerchunk never runs at train time).Result
A short CPU run has the trained denoiser beat the median-filter baseline (real ≈26.4 vs ≈24.7 dB PSNR).
Testing / offline default
--source synthetic(the default) writes a local zarr with the sameSCI (frame, y, x)geometry — sharp point sources a median filter can't preserve, plus NaN bad-pixels to exercise the NaN-scrub — so the example runs with no network or FITS stack and backstests/test_hubble.py. The test asserts the geometry (one frame per chunk), the(noisy, clean)batch labels + NaN scrubbing, the baseline denoises, and the CNN beats the baseline.ruff,mypy, and the tests are green.🤖 Generated with Claude Code