{"id":24679,"library":"synphot","title":"synphot","description":"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.","status":"active","version":"1.7.0","language":"python","source_language":"en","source_url":"https://github.com/spacetelescope/synphot_refactor","tags":["astronomy","synthetic-photometry","spectral-modeling"],"install":[{"cmd":"pip install synphot","lang":"bash","label":"Install synphot from PyPI"}],"dependencies":[{"reason":"Core dependency for units, FITS I/O, and cosmology.","package":"astropy","optional":false},{"reason":"Used for interpolation and integration.","package":"scipy","optional":false},{"reason":"Standard math and array operations.","package":"numpy","optional":false}],"imports":[{"note":"Main class for defining a source spectrum.","symbol":"SourceSpectrum","correct":"from synphot import SourceSpectrum"},{"note":"Main class for defining a bandpass (filter).","symbol":"SpectralElement","correct":"from synphot import SpectralElement"},{"note":"Class to combine source and bandpass and compute photometry.","symbol":"Observation","correct":"from synphot import Observation"}],"quickstart":{"code":"from synphot import SourceSpectrum, SpectralElement, Observation\nfrom synphot.models import Empirical1D, BlackBodyNorm1D\nfrom astropy import units as u\nimport numpy as np\n\n# Define a simple blackbody source spectrum\nbb = BlackBodyNorm1D(temperature=5000)\nwave = np.arange(1000, 10000) * u.AA\nsource_spec = SourceSpectrum(bb, points=wave)\n\n# Define a Johnson V filter\n# (Filter throughput data can be loaded from a file or defined manually)\n# Example using a built-in filter from specutils or a custom one:\n# Here we create a simple Gaussian bandpass for demonstration\nfrom astropy.modeling.models import Gaussian1D\nv_filter = SpectralElement(Gaussian1D, mean=5500, stddev=500, points=wave)\n\n# Compute the observation\nobs = Observation(source_spec, v_filter)\ncount_rate = obs.countrate()  # counts per second\nprint(count_rate)\n\n# Compute effective wavelength\neff_wave = obs.effective_wavelength()\nprint(eff_wave)","lang":"python","description":"Basic example of creating a source spectrum and a bandpass, then computing synthetic photometry."},"warnings":[{"fix":"Replace strings like 'flam' with astropy units: e.g., `u.erg/u.s/u.cm**2/u.AA`.","message":"In version 1.6.0, `force_flux_unit` was changed to require a unit instance, not a string. Passing a string will raise an error.","severity":"breaking","affected_versions":">=1.6.0"},{"fix":"Use `Observation.countrate(area=...)` or convert units appropriately.","message":"The `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.","severity":"deprecated","affected_versions":"all"},{"fix":"Always pass `points` with explicit units (e.g., `wave * u.AA`) when constructing from models.","message":"When 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.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Uninstall any old version (`pip uninstall synphot` and then reinstall with `pip install synphot`). Ensure you are using the correct import.","cause":"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`.","error":"AttributeError: module 'synphot' has no attribute 'SourceSpectrum'"},{"fix":"Use `u.erg / (u.s * u.cm**2 * u.AA)` instead of `'flam'`.","cause":"In older versions, strings like 'flam' were accepted. Since 1.6.0, you must use astropy units.","error":"ValueError: The unit 'flam' is not recognized"},{"fix":"Update synphot: `pip install --upgrade synphot`.","cause":"BlackBodyNorm1D was added in version 0.3. Ensure your version is up-to-date.","error":"ImportError: cannot import name 'BlackBodyNorm1D' from 'synphot.models'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}