LS4Cam.gaia_dr3_to_instrument_mag: implement + multi-color refit g/i/z#2
Open
nugent68 wants to merge 1 commit into
Open
LS4Cam.gaia_dr3_to_instrument_mag: implement + multi-color refit g/i/z#2nugent68 wants to merge 1 commit into
nugent68 wants to merge 1 commit into
Conversation
models/ls4cam.py
----------------
Replace the NotImplementedError stub at gaia_dr3_to_instrument_mag with
a working implementation that mirrors DECam's polynomial-in-(BP-RP)
form. Refit g, i, z coefficients against LS DR10 PSF photometry using
the multi-color (Gaia BP-RP + DR10 g-r, r-i, i-z) total-degree-3 fit
documented below; flip LS4_GAIA_TRNS_PLACEHOLDER to False.
g: SE_C, 0.86M PSF stars, catalog-fit RMS 0.011 mag
i: mean of independent NE_F (1.17M) and SW_G (0.85M) per-chip fits;
they agreed to 2-7 mmag across BP-RP=0.5..2.0
z: NW_C, 1.11M PSF stars, catalog-fit RMS 0.013 mag
Single-image verification with test_ls4_zp.py on exposure 20260410_000202:
g (SE_C): ZP=26.72, scatter 0.097 mag, 1517 matched stars
i (NE_F): ZP=26.66, scatter 0.145 mag, 1372 matched stars
z (NW_C): ZP=26.18, scatter 0.158 mag, 1403 matched stars
hacks/nugent/
-------------
Group all of nugent's LS4 hack scripts under a personal subdir, mirroring
the existing hacks/rknop/ layout:
combine_mask_and_flags.py Bitwise OR a per-chip bad-pixel mask with
a per-image flags FITS into a single
*.mask.fits.fz uint16 Rice-compressed file.
Promotes the chip mask to flag_image_bits
bit 0.
pull_chip_files.py Pull image+sources+wcs trios from a NERSC
archive given a chip-list text file; cleans
up orphans whose companions are missing
both locally and at NERSC. Uses ssh+tar
with tar -T - to avoid argv-length limits.
refit_ls4_color_terms.py Multi-color refit: per-cluster Gaia DR3 +
LS DR10 queries via NOIRLab DataLab. The
--multi-color flag enables a 4-feature
total-degree-3 fit with marginalization
back to a 1-D Gaia-only polynomial via
E[DR10_color | BP-RP]. Optional
--photometric-zp-window restricts the
calibration sample to images whose per-
image ZP lies near the photometric mode.
test_ls4_zp.py Standalone end-to-end zeropoint sanity
test for one image: Gaia DR3 query, source-
list match, mask-aware filtering, and a
sigma-clipped median ZP. Exercises the
new LS4Cam.gaia_dr3_to_instrument_mag.
make_superbias.py Moved here from hacks/ ; originally landed
via PR 1 and now superseded by
improc/flat_bias_builder.py upstream, but
kept here as historical record.
run_overscan_on_zeros.py Early diagnostic: applies overscan+trim to
a directory of bias frames and tabulates
per-chip stats.
diagnose_nwb.py Early diagnostic: 4x2 panel comparing the
suspect NW_B chip vs a known-good chip on
one bias frame.
refit_outputs/ Diagnostic PNGs + per-fit CSV summaries
for SE_C g, NE_F+SW_G i, NW_C z.
Co-Authored-By: Claude Opus 4.7 (1M context) <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.
Summary
LS4Cam.gaia_dr3_to_instrument_mag(replaces theNotImplementedErrorstub) with a polynomial-in-(BP-RP) formmatching DECam's, plus a
LS4_GAIA_TRNS_PLACEHOLDERclass flagflipped to
False.photometry using a new multi-color (Gaia BP-RP + DR10 g-r, r-i, i-z)
total-degree-3 fit, marginalized to a 1-D Gaia-only polynomial for
production.
hacks/nugent/mirroringthe existing
hacks/rknop/layout.Refit details
Per-chip i-band fits (NE_F vs SW_G) agreed to 2-7 mmag across
BP-RP=0.5..2.0 — well below the per-chip RMS — so I averaged them
into a single i-band entry rather than carrying chip-specific
coefficients. If a future test reveals chip-specific drift, the
per-chip fits are still in
hacks/nugent/refit_outputs/.The multi-color fit is a calibration-time-only enhancement; the
production interface in
gaia_dr3_to_instrument_magstill takes onlyGaia (BP-RP), unchanged. See
hacks/nugent/refit_ls4_color_terms.pyfor details on themarginalization step.
Single-image verification
Running
hacks/nugent/test_ls4_zp.pyagainst exposure20260410_000202on each filter:
ZP scatter ordering
g < i < zmatches the expected per-filter skybackground. Single-image scatter is photon-noise-dominated at the
default
--snr-min 5cut; tightening to SNR > 100 drops g-bandscatter to ~0.026 mag.
Test plan
from models.ls4cam import LS4Cam ; LS4Cam().gaia_dr3_to_instrument_mag('g', catdata)returns sensible mags + errs for a small dict-of-Quantity catalogLS4_GAIA_TRNS_PLACEHOLDERisFalse'r'raisesValueErrorhacks/nugent/test_ls4_zp.py <image>end-to-end on at least one g, i, z imagehacks/nugent/refit_ls4_color_terms.py --multi-color --photometric-zp-window 0.10 --indir ...reproduces the refit numbers aboveNotes for review
footprint; recalibration should be straightforward when better
reference photometry becomes available — just rerun
refit_ls4_color_terms.pywith the new--indirand paste theprinted coefficient line.
hacks/nugent/refit_outputs/*.png(3.9 MB total) are the diagnosticplots for each per-chip fit (residual-vs-color before/after, per-
image ZP histogram, marginalized 1-D collapse, residual binned in
each DR10 color). Useful for inspecting fit quality without re-running.
hacks/make_superbias.py(merged in PR Add hacks/make_superbias.py: per-chip superbias / NMAD / bad-pixel mask #1, then extendedupstream into
improc/flat_bias_builder.py) is moved here ashacks/nugent/make_superbias.pyfor historical record.🤖 Generated with Claude Code