Registry / ai-ml / photutils

photutils

JSON →
library3.0.0pypypi✓ verified 84d ago

Photutils is an Astropy package for detecting and performing photometry on astronomical sources in image data. It provides tools for source detection, background estimation, aperture and PSF photometry, and image segmentation. Photutils is actively maintained, with new minor versions typically released every 1-3 months, following Astropy's release cycle. The current stable version is 2.3.0.

pip install photutils
INSTALL
IMPORT
SIG · PHOTUTILS
P
photutils
ai-mlpythonv3.0.0
Install
9.8s avg
Import
3284ms
Disk
277MB
Pass rate
5/ 10
Env Coverage5 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v2.0.2 · 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
py 3.103.910 runs
build_error
glibc
py 3.103.910 runs
installs and imports cleanly · install 9.8s · import 3.284s · 294MB
277MB installed
● package 277MB
Code
Verified usage

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

DAOStarFinder
from photutils.detection import DAOStarFinder
IRAFStarFinder
from photutils.detection import IRAFStarFinder
Background2D
from photutils.background import Background2D
MedianBackground
from photutils.background import MedianBackground
detect_sources
from photutils.segmentation import detect_sources
deblend_sources
from photutils.segmentation import deblend_sources
CircularAperture
from photutils.aperture import CircularAperture
aperture_photometry
from photutils.aperture import aperture_photometry
PropertiesCatalog
from photutils.segmentation import PropertiesCatalog
from photutils.segmentation import SourceProperties
SourceProperties and SourceCatalog were removed in v2.0.0; use PropertiesCatalog instead.
Gaussian2D
from astropy.modeling.models import Gaussian2D
from photutils.psf import Gaussian2D
PSF models were removed from photutils.psf in v2.0.0; use astropy.modeling.models instead.

This quickstart demonstrates a basic `photutils` workflow: generating synthetic image data, estimating and subtracting the background, detecting point sources using DAOStarFinder, and performing aperture photometry on the detected sources. This covers fundamental steps in analyzing astronomical images.

import numpy as np from astropy.stats import sigma_clipped_stats from photutils.detection import DAOStarFinder from photutils.background import Background2D, MedianBackground from photutils.aperture import CircularAperture, aperture_photometry # Create dummy data (replace with your actual FITS data) data = np.random.rand(100, 100) * 100 y, x = np.mgrid[0:100, 0:100] data += 500 * np.exp(-((x - 20)**2 + (y - 20)**2) / (2 * 5**2)) # Add a star data += 700 * np.exp(-((x - 70)**2 + (y - 80)**2) / (2 * 7**2)) # Add another star # 1. Estimate background mean_bkg, median_bkg, std_bkg = sigma_clipped_stats(data, sigma=3.0) bkg = Background2D(data, (50, 50), filter_size=(3, 3), bkg_estimator=MedianBackground()) data_subtracted = data - bkg.background # 2. Detect sources finder = DAOStarFinder(fwhm=5.0, threshold=3.0 * std_bkg) sources = finder(data_subtracted) if sources is None: print("No sources found. Adjust DAOStarFinder parameters.") else: print(f"Detected {len(sources)} sources:") for col in sources.colnames: sources[col].info.format = '%.8g' # for consistent output print(sources) # 3. Perform aperture photometry positions = (sources['xcentroid'], sources['ycentroid']) aperture = CircularAperture(positions, r=8.0) phot_table = aperture_photometry(data_subtracted, aperture) print("\nAperture Photometry:") for col in phot_table.colnames: phot_table[col].info.format = '%.8g' # for consistent output print(phot_table)
Debug
Known issues
breakingPSF models (e.g., `Gaussian2D`, `Moffat2D`) were removed from `photutils.psf` in v2.0.0.
fix
Use equivalent models from `astropy.modeling.models` instead (e.g., `from astropy.modeling.models import Gaussian2D`).
affects: >=2.0.0
breakingThe `SourceProperties` and `SourceCatalog` classes were removed in v2.0.0.
fix
Use `photutils.segmentation.PropertiesCatalog` instead, which provides similar functionality and is the recommended replacement.
affects: >=2.0.0
breakingThe generic `photutils.aperture.PixelAperture` class was removed in v2.0.0.
fix
For geometrically shaped source apertures, use `CircularAperture`, `RectangularAperture`, `EllipticalAperture`, etc. For pixel-based *background* apertures, use `photutils.aperture.BkgPixelAperture`.
affects: >=2.0.0
gotcha`photutils` functions often expect plain NumPy arrays for image data, even if your data is an `astropy.units.Quantity` object.
fix
If your input data is an `astropy.units.Quantity`, extract its numerical value using `.value` (e.g., `data.value`) before passing it to functions that do not explicitly handle `Quantity` inputs for image data. Be mindful of units when interpreting results.
affects: All versions
gotchaStar-finding algorithms like `DAOStarFinder` and `IRAFStarFinder` return `None` if no sources are found in the image data.
fix
Always check if the returned `sources` table is `None` before attempting to access its columns or perform subsequent operations like photometry (e.g., `if sources is not None:`).
affects: All versions
Errors
Common errors & fixes
AttributeError: 'module' object has no attribute 'Gaussian2D'
Attempting to import PSF models (like Gaussian2D) from `photutils.psf` after the v2.0.0 release.
fix
Replace `from photutils.psf import Gaussian2D` with `from astropy.modeling.models import Gaussian2D`.
NameError: name 'SourceProperties' is not defined
Using the `SourceProperties` or `SourceCatalog` classes, which were removed in `photutils` v2.0.0.
fix
Import and use `from photutils.segmentation import PropertiesCatalog` instead, adapting your code to its API.
TypeError: 'astropy.units.quantity.Quantity' object cannot be interpreted as an integer
Passing an `astropy.units.Quantity` object (data with units) directly to a `photutils` function that expects a plain numerical array.
fix
Extract the numerical value from the `Quantity` using `.value` before passing it to the function (e.g., `data_quantity.value`). Ensure you handle units appropriately in subsequent calculations.
ImportError: cannot import name 'PixelAperture' from 'photutils.aperture'
Attempting to import the generic `PixelAperture` class after its removal in `photutils` v2.0.0.
fix
For geometrically shaped source apertures, use specific classes like `CircularAperture`, `RectangularAperture`, or `EllipticalAperture`. For pixel-based *background* apertures, use `photutils.aperture.BkgPixelAperture`.
Upgrade
Version history
3.0.0latest on PyPI · released Apr 17, 2026
Audit
Dependencies
astropyrequiredCore dependency for astronomical data structures, units, WCS, and modeling.
numpyrequiredFundamental for numerical array operations.
scipyrequiredUsed for various scientific computing tasks, including PSF fitting and filtering.
matplotliboptionalOptional dependency for visualization and plotting in examples and user scripts.
Agent activity
11 hits · last 30 days
node
10
Amazon
1
Resources
photutils — pip install photutils · libregistry