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, throughput, and detector type either energy or photon (default). Many properties such as central of pivot wavelengths are computed internally.

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.

Note

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

https://mybinder.org/badge.svg https://img.shields.io/badge/render%20on-nbviewer-orange.svg

Package main content#

This package is mainly organized around two backend to handle quantities with units: a lightweight version of Pint (pyphot.ezunits) and the Astropy Units. As these do no provide the same functionalities, the package is designed to be able to switch between the two by importing either from pyphot.sandbox or pyphot.astropy.

Tip

You can transparently switch between pint and astropy units with aliasing the import line:

from pyphot import astropy as pyphot
# or
from pyphot import sandbox as pyphot

This package is mostly organized around 2 main classes (from either root module above):

  • UnitFilter that handles filter definitions and manipulations.

  • UnitLibrary that handles a collection of filters in a few formats.

Additionally, and for convenience

  • the library class is derived into an ascii file reader Ascii_Library, and a single hdf file reader HDF_Library.

  • svo provides an interface to the SVO Filter Profile Service to download filters directly from the SVO database.

  • Vega provides an interface to a synthetic reference of Vega.

  • Sun provides an interface to a synthetic and empirical reference of the Sun spectrum.

  • licks provides an extension to computing lick indices.

Contents#

Installation#

  • Using pip: Use the –user option if you don’t have permissions to install libraries

pip install git+https://github.com/mfouesneau/pyphot
  • Manually:

git clone https://github.com/mfouesneau/pyphot
cd pyphot
python setup.py intall

Quick Start#

Additional examples can be found on the More example usage page.

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:
    lib[name].info(show_zeropoints=True)
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

    Zeropoints
        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.

Internal Sun reference#

We also provide observed and theoretical references for the solar spectrum following Colina, Bohlin, & Castelli 1996.

The observed solar spectrum comes from CALSPEC sun_reference_stis_001.fits which provides the ultraviolet to near-infrared absolute flux distribution of the Sun covering the 0.12-2.5 μm wavelength range. The solar reference spectrum combines absolute flux measurements from satellites and from the ground with a model spectrum for the near-infrared.

The theoretical spectrum comes from the Kurucz’93 atlas: sun_kurucz93.fitsftp://ftp.stsci.edu/cdbs/grid/k93models/standards/sun_kurucz93.fits The theoretical spectrum is scaled to match the observed spectrum from 1.5 - 2.5 microns, and then it is used where the observed spectrum ends. The theoretical model of the Sun uses the following parameters when the Sun is at 1 au:

Solar Parameters#

log_Z

T_eff

log_g

V_{Johnson}

+0.0

5777

+4.44

-26.75

The interface to the Sun templates is given through the pyphot.sun.Sun class.

Contributors#

Author: Morgan Fouesneau (@mfouesneau)

Direct contributions to the code base:

Citation#

If you use this software in your work, please cite it using the following:

@software{zenodopyphot,
author       = {Fouesneau, Morgan},
title        = {pyphot},
month        = jan,
year         = 2025,
publisher    = {Zenodo},
version      = {pyphot\_v1.6.0},
doi          = {10.5281/zenodo.14712174},
url          = {https://doi.org/10.5281/zenodo.14712174},
}

Indices and tables#