ztforce.utils
Pure math helpers — no ztforce imports.
Functions
|
Convert instrumental flux to AB magnitude. |
|
Convert AB magnitude to instrumental flux. |
|
Signal-to-noise ratio from flux and its uncertainty. |
|
Return True if any pixel within radius of (row, col) is masked. |
|
Round x up to the nearest odd integer. |
|
Sigma-clipped sky level and RMS in an annulus around (cx, cy). |
Module Contents
- flux_to_ab_mag(flux: float, zero_point: float, flux_err: float | None = None) tuple[float, float | None][source]
Convert instrumental flux to AB magnitude.
Uses the AB system definition from Oke & Gunn (1983, ApJ, 266, 713):
mag = zero_point - 2.5 * log10(flux).Returns (mag, mag_err). mag_err is None when flux_err is not given. Returns (nan, nan) when flux <= 0.
- ab_mag_to_flux(mag: float, zero_point: float, mag_err: float | None = None) tuple[float, float | None][source]
Convert AB magnitude to instrumental flux.
Returns (flux, flux_err). flux_err is None when mag_err is not given.
- snr_from_flux(flux: float, flux_err: float) float[source]
Signal-to-noise ratio from flux and its uncertainty.
- has_nan_nearby(row: int, col: int, radius: float, mask: numpy.ndarray) bool[source]
Return True if any pixel within radius of (row, col) is masked.
- annular_background(data: numpy.ndarray, cx: float, cy: float, r_inner: float, r_outer: float, sigma: float = 3.0) tuple[float, float][source]
Sigma-clipped sky level and RMS in an annulus around (cx, cy).
cx/cy follow the FITS/numpy column/row convention (cx = column index). Returns (sky_level, sky_rms). Falls back to the global finite-pixel statistics when fewer than 5 annulus pixels are available.