Registry / data / synphot

synphot

JSON →
library1.7.0pypypi✓ verified 86d ago

Synthetic photometry library for astronomy, providing tools to simulate observations through various bandpasses, compute count rates, and handle spectral flux densities. Current version 1.7.0, requires Python >=3.10 and Astropy. Release cadence is irregular, approximately 1-2 minor versions per year.

pip install synphot
INSTALL
IMPORT
SIG · SYNPHOT
S
synphot
datapythonv1.7.0
Install
10.5s avg
Import
3548ms
Disk
301MB
Pass rate
9/ 10
Env Coverage9 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.7.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
glibc
py 3.10
✓ —
✓ 10s
py 3.11
✓ —
✓ 10.1s
py 3.12
✓ —
✓ 10.4s
py 3.13
✓ —
✓ 10.8s
py 3.9
✕ build_error
✓ 11.4s
301MB installed
● package 301MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

SourceSpectrum
from synphot import SourceSpectrum
Main class for defining a source spectrum.
SpectralElement
from synphot import SpectralElement
Main class for defining a bandpass (filter).
Observation
from synphot import Observation
Class to combine source and bandpass and compute photometry.

Basic example of creating a source spectrum and a bandpass, then computing synthetic photometry.

from synphot import SourceSpectrum, SpectralElement, Observation from synphot.models import Empirical1D, BlackBodyNorm1D from astropy import units as u import numpy as np # Define a simple blackbody source spectrum bb = BlackBodyNorm1D(temperature=5000) wave = np.arange(1000, 10000) * u.AA source_spec = SourceSpectrum(bb, points=wave) # Define a Johnson V filter # (Filter throughput data can be loaded from a file or defined manually) # Example using a built-in filter from specutils or a custom one: # Here we create a simple Gaussian bandpass for demonstration from astropy.modeling.models import Gaussian1D v_filter = SpectralElement(Gaussian1D, mean=5500, stddev=500, points=wave) # Compute the observation obs = Observation(source_spec, v_filter) count_rate = obs.countrate() # counts per second print(count_rate) # Compute effective wavelength eff_wave = obs.effective_wavelength() print(eff_wave)
Debug
Known issues
breakingIn version 1.6.0, `force_flux_unit` was changed to require a unit instance, not a string. Passing a string will raise an error.
fix
Replace strings like 'flam' with astropy units: e.g., `u.erg/u.s/u.cm**2/u.AA`.
affects: >=1.6.0
deprecatedThe `countrate` method returns counts per second based on the default flux density units (FLAM). If you need counts per second in a different bandpass, specify the area explicitly.
fix
Use `Observation.countrate(area=...)` or convert units appropriately.
affects: all
gotchaWhen creating a `SourceSpectrum` from a model, the `points` argument must be in the correct wavelength unit. If omitted, the model's internal points may not match expectations.
fix
Always pass `points` with explicit units (e.g., `wave * u.AA`) when constructing from models.
affects: all
Errors
Common errors & fixes
AttributeError: module 'synphot' has no attribute 'SourceSpectrum'
synphot is sometimes confused with the older stsci_package synphot (a different library). The correct package is installed as `synphot`, but import path is `from synphot import SourceSpectrum`.
fix
Uninstall any old version (`pip uninstall synphot` and then reinstall with `pip install synphot`). Ensure you are using the correct import.
ValueError: The unit 'flam' is not recognized
In older versions, strings like 'flam' were accepted. Since 1.6.0, you must use astropy units.
fix
Use `u.erg / (u.s * u.cm**2 * u.AA)` instead of `'flam'`.
ImportError: cannot import name 'BlackBodyNorm1D' from 'synphot.models'
BlackBodyNorm1D was added in version 0.3. Ensure your version is up-to-date.
fix
Update synphot: `pip install --upgrade synphot`.
Upgrade
Version history
1.7.0latest on PyPI · released Mar 7, 2026
Audit
Dependencies
astropyrequiredCore dependency for units, FITS I/O, and cosmology.
scipyrequiredUsed for interpolation and integration.
numpyrequiredStandard math and array operations.
Agent activity
41 hits · last 30 days
node
36
OpenAI (training)
1
Resources
synphot — pip install synphot · libregistry