Skip to content

POTPyRI 1.0.16 – Sky masking, relative calibration, and calibration/WCS fixes

Choose a tag to compare

@charliekilpatrick charliekilpatrick released this 06 Mar 01:54
· 45 commits to main since this release
3191a6f

POTPyRI 1.0.16 – Sky masking, relative calibration, and calibration/WCS fixes

Sky image creation and masking

  • Iterative sigma clipping when building sky frames and master sky: configurable maxiters and sigma limits so the sky level is estimated from progressively cleaned pixels.
  • Bright-source and low-outlier masking in each sky frame and in the combined master sky (pixels above/below median ± Nσ are masked; masked pixels set to 1.0 in normalized sky).
  • Configurable parameters for create_sky: sky_sigma_upper/lower, sky_maxiters, sky_n_sigma_high/low, msky_n_sigma_high/low, msky_maxiters (defaults remain backward compatible).
  • Robust scale when applying sky in process_science: sigma-clipped median of the science frame (with maxiters) is used to scale the master sky so bright objects don’t bias the sky level.
  • CCDData mask handling: initialize mask when None before setting masked pixels so combination and downstream steps work correctly.

Relative calibration before stacking

  • Optional relative flux calibration before stacking: run Source Extractor on each aligned frame, cross-match sources in RA/Dec, and use relative source fluxes to set per-frame scale factors for ccdproc.combine.
  • Inverse-variance weighting using FLUXERR_AUTO when available; otherwise median of flux ratios.
  • CLI flag --relative-calibration to enable this step; scales are used as-is in stack_data (no division by exposure time when relative scales are provided).
  • Fallback for failed frames: if a frame has too few matches, its scale is set to 1.0/exptime for that frame instead of aborting relative calibration; exptimes is passed into compute_relative_scales.
  • Unit tests for compute_relative_scales (mocked SExtractor): single image, exptimes mismatch, SExtractor failure, catalog too small, two-frame flux ratio, failed-frame exptime fallback, FLUXERR weighting, no-FLUXERR median path.

Calibration and WCS robustness

  • Calibration FITS (master bias/dark/flat/sky) no longer carry WCS keywords that can trigger invalid transforms (e.g. DEC=-100): headers are sanitized before write and calibration frames are loaded with _read_calibration_ccd (no WCS parsing).
  • Sky subtraction units: fixed UnitConversionError when subtracting normalized (dimensionless) sky from electron science frame by scaling sky with the science median in electron units before subtract.
  • find_catalog (utilities): all code paths now return a 6-tuple (catalog, catalog_ID, ra, dec, mag, err); 2MASS K-band mapping for K, Ks, Kspec.

Testing and CI

  • Unit tests for create_sky (masking bright sources, default and custom sigma params), compute_relative_scales (eight cases above), instruments, utilities, and image_procs.
  • Integration tests marked with @pytest.mark.integration and skipped in CI; CI runs pytest -m "not integration".

Documentation

  • README and CONTRIBUTING updated (testing, docs, contributing).
  • Installation and index docs updated for current setup.

One-paragraph summary (for PyPI “Description” or short announcment)

This release improves sky frame creation with iterative sigma clipping and configurable masking of bright sources and defects, and adds an optional relative flux calibration step before stacking: Source Extractor catalogs are cross-matched in RA/Dec and relative source fluxes (with optional FLUXERR_AUTO weighting) define per-frame scale factors for the stack combine. Calibration frames no longer write or parse WCS keywords that could cause invalid transform errors; sky subtraction uses a sigma-clipped science median for scaling and correct units. Additional unit tests cover sky creation, relative calibration, and calibration loading; integration tests are marked and skipped in CI.


Version suggestion

  • Current dev version in the repo: 1.0.15.dev10.
  • For a patch release (fixes only): 1.0.15 (tag and build from the commit you want).
  • For a minor release (new features: relative calibration, sky improvements): 1.0.16 (bump then tag, or use setuptools-scm and tag e.g. v1.0.16 so the built package gets that version).

After tagging, build and upload to PyPI:

pip install build twine
python -m build
twine upload dist/*