Skip to content

Instantly share code, notes, and snippets.

@monodera
Created February 20, 2026 04:07
Show Gist options
  • Select an option

  • Save monodera/3f917a043162065b3e4d859b4fbd396f to your computer and use it in GitHub Desktop.

Select an option

Save monodera/3f917a043162065b3e4d859b4fbd396f to your computer and use it in GitHub Desktop.
Convert maggy to AB magnitude with astropy.units
# /// script
# dependencies = [
# "astropy",
# ]
# ///
#
# ref: https://www.sdss4.org/dr17/algorithms/magnitudes/
#
from astropy import units as u
flux_in_maggy = 10 * u.nanomaggy
flux0 = (0. * u.ABmag).to(u.Jy) # 1 maggy ~ 3631 Jy
mag_ab = flux_in_maggy.to(u.ABmag, equivalencies=u.zero_point_flux(flux0))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment