Skip to content

reference: scale inputs by photmjsr, not photmjsr x pixel area; awaicgen -sf 0 - #683

Open
jjencson91 wants to merge 1 commit into
mainfrom
fix/reference-sb-scaling
Open

jjencson91 wants to merge 1 commit into
mainfrom
fix/reference-sb-scaling

Conversation

@jjencson91

Copy link
Copy Markdown
Contributor

Implements Caltech-IPAC/rapid_docs#251 (system/reference.md, Preparation and awaicgen steps; new ruling decision-reference-surface-brightness).

What changed

  • rapidpipe/science/reference/prep.py: the per-frame factor is 10 ** (0.4 * (zprefimg - ZPTMAG)) * A_mosaic / A. A is the frame's WCS pixel area (|det CD| of HDU 1, new pixel_area_deg2) for the header ZPTMAG, or the run's nominal_pixel_area for the nominal one; A_mosaic is awaicgen_pixelscale_absolute squared. In effect inputs are scaled by photmjsr instead of photmjsr x pixel area. FrameHeader and PreparedFrame record the area.
  • rapidpipe/stages/reference.py: passes nominal_pixel_area (sr -> deg^2) under use_nominal_zptmag; a run body without the key keeps dev's factor.
  • rapidpipe/settings/foundation-thin.toml: awaicgen_pixelflux_scale_flag = 0 (was 1); new [reference.awaicgen] nominal_pixel_area = 2.8440e-13 sr (the 0.11" pixel, so nominal scaling is unchanged for zero points made for it).
  • rapidpipe/settings/datasets/flight.toml: nominal_pixel_area = 2.7185e-13 sr, the median meta.photometry.pixel_area over the 18 SCAs.
  • tests/unit/test_reference_science.py: test frames carry a 0.11" WCS; scaling tests include the area factor; new tests for the area swap, the nominal area being required, the pre-key run body, and pixel_area_deg2.

Why

  • ZPTMAG = -2.5 log10(photmjsr * 1e6 * pixel_area / 3631) is a point-source zero point. awaicgen's simple coadd is an overlap-weighted mean of its inputs (awaicgen_compute_simpcoadd.c), i.e. it treats them as surface brightness, so each SCA's pixel area (about 2.63 / 2.72 / 2.80e-13 sr on flight) was counted twice.
  • -sf 1 multiplies the coadd by (0.11")^2 over the first input file's CDELT1 * CDELT2 (awaicgen_store_img_fnames.c, i == 0; awaicgen_compute_results_simple.c), 1.015 to 1.081 across flight SCAs, so the mosaic's real zero point differed from its MAGZP depending on input order. With the area in the inputs and -sf 0, MAGZP = zprefimg holds for any order.
  • Reprocessed program 1049 F158 (romancal 1.2.0 / CRDS roman_0104), matched stars across SCAs: per-SCA scatter 7.4% with the nominal ZP, 5.3% with the current per-frame ZPTMAG, 3.5% with photmjsr alone. An offline awaicgen test on field 3018415 gives the same ordering in the mosaics.

Effect on runs

  • Flight default (use_nominal_zptmag = true): still one factor per filter; the absolute level shifts by a few percent and no longer depends on input order.
  • use_nominal_zptmag = false (e.g. run 302): the per-SCA pixel-area patches go away.
  • Simulations whose frames share one pixel area: only the difference between that area and the first file's CDELT1 * CDELT2.

Review: touches rapidpipe/settings/, so it needs one approval from a team member (CONTRIBUTING.md, Review and Acceptance).

Tests: tests/unit/test_reference_science.py, test_reference_stage.py, test_layers.py pass locally (138). The full unit suite is left to CI (the local environment's photutils is older than requirements.txt).

🤖 Generated with Claude Code

…gen -sf 0

Each reference input was scaled by 10^(0.4 (zprefimg - ZPTMAG)). ZPTMAG is a
point-source zero point that includes the SCA's pixel area, and awaicgen's
simple coadd averages surface brightness, so the area was counted twice. The
factor now also takes that area out and the 0.11" mosaic pixel's in:
10^(0.4 (zprefimg - ZPTMAG)) * A_mosaic / A, with A the frame's WCS pixel area
(|det CD|, equal to meta.photometry.pixel_area to 0.02% on flight files) or,
under use_nominal_zptmag, the new [reference.awaicgen] nominal_pixel_area
(base: the 0.11" pixel, so nominal scaling is unchanged for zero points made
for it; flight: 2.7185e-13 sr, the median over the 18 SCAs).

awaicgen_pixelflux_scale_flag goes to 0 in the base: -sf 1 multiplied the
coadd by (0.11")^2 over the first input's CDELT1 * CDELT2 only, so the
mosaic's zero point depended on input order. A run body without
nominal_pixel_area keeps dev's factor (and the -sf 1 it stored).

Implements rapid_docs#251 (system/reference.md, decision
reference-surface-brightness).

Co-Authored-By: Claude Opus 5.5 <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