Skip to content

LS4Cam.gaia_dr3_to_instrument_mag: implement + multi-color refit g/i/z#2

Open
nugent68 wants to merge 1 commit into
rknop:import_ls4from
nugent68:nugent/ls4-gaia-color-fits
Open

LS4Cam.gaia_dr3_to_instrument_mag: implement + multi-color refit g/i/z#2
nugent68 wants to merge 1 commit into
rknop:import_ls4from
nugent68:nugent/ls4-gaia-color-fits

Conversation

@nugent68
Copy link
Copy Markdown

Summary

  • Implements LS4Cam.gaia_dr3_to_instrument_mag (replaces the
    NotImplementedError stub) with a polynomial-in-(BP-RP) form
    matching DECam's, plus a LS4_GAIA_TRNS_PLACEHOLDER class flag
    flipped to False.
  • Refits g, i, z polynomial coefficients against LS DR10 PSF
    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.
  • Groups all of nugent's LS4 hack scripts under hacks/nugent/ mirroring
    the existing hacks/rknop/ layout.

Refit details

Filter Calibration field PSF stars Catalog-fit RMS
g SE_C 0.86 M 0.011 mag
i mean of NE_F (1.17 M) and SW_G (0.85 M) 2.02 M 0.013 mag each
z NW_C 1.11 M 0.013 mag

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_mag still takes only
Gaia (BP-RP), unchanged. See
hacks/nugent/refit_ls4_color_terms.py for details on the
marginalization step.

Single-image verification

Running hacks/nugent/test_ls4_zp.py against exposure 20260410_000202
on each filter:

Filter Chip ZP Scatter N
g SE_C 26.72 0.097 mag 1517
i NE_F 26.66 0.145 mag 1372
z NW_C 26.18 0.158 mag 1403

ZP scatter ordering g < i < z matches the expected per-filter sky
background. Single-image scatter is photon-noise-dominated at the
default --snr-min 5 cut; tightening to SNR > 100 drops g-band
scatter 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 catalog
  • LS4_GAIA_TRNS_PLACEHOLDER is False
  • Filter validation: passing 'r' raises ValueError
  • hacks/nugent/test_ls4_zp.py <image> end-to-end on at least one g, i, z image
  • (optional) hacks/nugent/refit_ls4_color_terms.py --multi-color --photometric-zp-window 0.10 --indir ... reproduces the refit numbers above

Notes for review

  • The polynomial coefficients are fit from data overlapping the LS DR10
    footprint; recalibration should be straightforward when better
    reference photometry becomes available — just rerun
    refit_ls4_color_terms.py with the new --indir and paste the
    printed coefficient line.
  • hacks/nugent/refit_outputs/*.png (3.9 MB total) are the diagnostic
    plots 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.
  • The original hacks/make_superbias.py (merged in PR Add hacks/make_superbias.py: per-chip superbias / NMAD / bad-pixel mask #1, then extended
    upstream into improc/flat_bias_builder.py) is moved here as
    hacks/nugent/make_superbias.py for historical record.

🤖 Generated with Claude Code

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>
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.

1 participant