PYPHOT – A tool for computing photometry from spectra

This is a set of tools to compute synthetic photometry in a simple way, ideal to integrate in larger projects.

The inputs are photonic or energetic response functions for the desired photometric bands and stellar spectra. The modules are flexible to handle units in the wavelength definition through a simplified version of pint (link)

Filters are represented individually by a Filter object. Collections of filters are handled with a Library. We provide an internal library that contains a signitificant amount of common filters.

Each filter is minimally defined by a wavelength and throughput. Many properties such as central of pivot wavelength are computed internally.

When units are provided for the wavelength of the filters, zero points in multiple units are also accessible (AB, Vega magnitude, Jy, erg/s/cm2/AA). The default detector type is assumed to be photonic, but energetic detectors are also handled for the computations.


All provided filters have defined units and detector type that are used transparently throughout the package.

Package main content

This package is mostly organized around 2 main classes:

Both classes are able to manipulate units through a lightweight version of Pint pyphot.ezunits (…link….)

Additionally, and for convenience


  • Using pip: Use the –user option if you don’t have permissions to install libraries
pip install git+
  • Manually:
git clone
cd pyphot
python intall

Quick Start

import pyphot
# get the internal default library of passbands filters
lib = pyphot.get_library()
print("Library contains: ", len(lib), " filters")
# find all filter names that relates to IRAC
# and print some info
f = lib.find('irac')
for name in f:
Library contains:  196  filters
Filter object information:
    name:                 SPITZER_IRAC_45
    detector type:        photon
    wavelength units:     AA
    central wavelength:   45110.141614 angstrom
    pivot wavelength:     45020.219955 angstrom
    effective wavelength: 44425.747085 angstrom
    norm:                 4664.680820
    definition contains 417 points

        Vega: 28.933084 mag,
              2.671569250882836e-12 erg / angstrom * centimeter ** 2 * second,
              175.8794962126167 Jy
          AB: 25.674986 mag,
              5.370385702161592e-11 erg / angstrom * centimeter ** 2 * second,
              3535.5277855945205 Jy
          ST: 21.100000 mag,
              3.6307805477010028e-09 erg / angstrom * centimeter ** 2 * second,
              239027.9995089771 Jy


Suppose one has a calibrated spectrum and wants to compute the vega magnitude throug the HST WFC3 F110W passband,

# convert to magnitudes
import numpy as np
f = lib['hst_wfc3_f110w']
# compute the integrated flux through the filter f
# note that it work on many spectra at once
fluxes = f.get_flux(lamb, spectra, axis=1)
# convert to vega magnitudes
mags = -2.5 * np.log10(fluxes) - f.Vega_zero_mag
# or similarly
mags = -2.5 * np.log10(fluxes / f.Vega_zero_flux)

If one wants to use a given transmission curve as filter, defined by lamb_T and T, one would use the pyphot.phot.Filter directly as

# convert to magnitudes
from pyphot import Filter
# if lamb_T has units the Filter object will use those.
f = Filter(lamb_T, T, name='my_filter', dtype='photon', unit='Angstrom')
# compute the integrated flux through the filter f
fluxes = f.get_flux(lamb, spectra, axis=1)

Internal Vega reference

As mentioned in the above, sometimes a spectrum of reference of Vega is necessary.

We use the synthetic spectrum provided by Bohlin 2007, a common reference througout many photometric suites.

The interface to the Vega template is given through the pyphot.vega.Vega class.

Indices and tables