Photutils Python Package

repository·main·Indexed 43 days ago

https://github.com/astropy/photutils

A Python package for photometry providing tools for aperture photometry, PSF modeling, and source detection. Includes comprehensive benchmarks for subpackages such as photutils.centroids, photutils.geometry, photutils.isophote, photutils.morphology, photutils.profiles, photutils.psf, photutils.detection, photutils.segmentation, and photutils.background.

Tokens
68.5K
Snippets
172
Records
315
Agent score
56%

What's inside Photutils

  1. Overview of Photutils functionality

    main

    Photutils is a Python library designed for detecting and performing photometry of astronomical sources. It is a coordinated package of Astropy and integrates with the broader Astropy ecosystem for astronomical image analysis.

    Key capabilities include:

    • Background Estimation: Tools for estimating the background level in images.
    • Source Detection & Extraction: Star finding, source detection, and extraction.
    • Photometry: Support for both Aperture Photometry and PSF (Point Spread Function) Photometry.
    • Image Analysis: Image segmentation, centroid calculation, radial profiles, and elliptical isophote fitting.
  2. Overview of Photutils Benchmarks

    main
    The benchmarks/ directory contains standalone benchmark scripts for evaluating the performance of various photutils subpackages. These scripts are not part of the installed package or the test suite. They use shared helper functions located in bench_helpers.py. Use these scripts to understand the scaling and performance characteristics of different photometry and detection algorithms.
  3. Overview of Photutils capabilities

    main

    Photutils is a Python package providing a wide range of tools for astronomical photometry and source analysis. Its primary capabilities include:

    • Photometry: Performing aperture photometry and PSF-fitting photometry.
    • Source Detection & Extraction: Detecting and extracting both point-like sources (e.g., stars) and extended sources (using image segmentation).
    • Background Estimation: Estimating the background and background RMS in astronomical images.
    • Source Characterization: Centroiding sources, estimating morphological parameters, and creating radial profiles or curves of growth.
    • PSF Modeling: Building an effective Point Spread Function (ePSF) and matching PSF kernels.
    • Galaxy Analysis: Fitting elliptical isophotes to galaxies.
    • Image Simulation: Creating simulated astronomical images and estimating limiting depths.
  4. Explore the Photutils API Reference

    main
    The Photutils API reference provides detailed documentation for functions, modules, and objects organized by subpackage. To use these tools, you should first understand the core concepts in the user guide and follow the standard import patterns for the package. The API is organized into several specialized subpackages covering tasks from aperture photometry to PSF modeling.
  5. Use the photutils.background module for background estimation

    main

    The photutils.background module provides tools for estimating and modeling the background in astronomical images. This is a prerequisite step for many photometry tasks to ensure that source flux measurements are not biased by the underlying sky level.

    For detailed workflows on how to select and apply specific background estimation methods, refer to the full User Guide.

  6. Explore the Photutils User Guide

    main

    Photutils is a Python library designed for detecting and performing photometry on astronomical sources. The library is organized into specialized subpackages. You can use Photutils for the following core tasks:

    • Background Estimation: Tools for modeling and subtracting backgrounds.
    • Centroiding: Finding the center of astronomical sources.
    • Source Detection: Identifying sources in images.
    • Segmentation and Morphology: Segmenting images and measuring source shapes/properties.
    • Aperture Photometry: Measuring flux within defined apertures.
    • PSF Photometry: Performing photometry using Point Spread Function models, including PSF building and grouping.
    • PSF Matching: Matching PSFs between different images.
    • Profiles: Analyzing radial profiles and curves of growth.
    • Elliptical Isophotes: Modeling isophotal structures.
    • Datasets and Simulation: Generating synthetic astronomical data.
    • Serialization: Saving and loading data using the asdf format.
  7. Perform elliptical isophote analysis with photutils.isophote

    main

    The photutils.isophote module provides tools for elliptical isophote analysis. This is typically used to characterize the shape, orientation, and intensity profiles of astronomical objects by fitting ellipses to constant-intensity contours (isophotes).

    For detailed workflows, including how to set up fitting parameters and interpret results, refer to the full User Guide.

  8. What is a SegmentationImage?

    main

    A SegmentationImage is the output of detection and deblending processes. It is an object with the same shape as the input data where:

    • Each detected source is assigned a unique positive integer label.
    • Background pixels are assigned a value of 0.
    • The segments represent the isophotal footprints of the detected sources.
  9. What is an effective PSF (ePSF)?

    main

    An effective PSF (ePSF) is an empirical model that describes the fraction of a star's light that lands in a particular pixel. Unlike a standard instrumental PSF, an ePSF can be oversampled relative to the detector pixels.

    Oversampling is critical when the PSF is undersampled by the detector (e.g., a FWHM of only 1-2 pixels). Because stars land at fractional pixel positions, an oversampled ePSF captures the 'pixel-phase variation,' allowing the PSF to be accurately interpolated to the exact position of any star.

  10. Use window functions in PSF matching

    main

    When performing PSF matching with make_kernel or make_wiener_kernel, you can provide an optional window parameter to suppress high-frequency spatial noise artifacts in the Fourier ratio. A window function is a radially-symmetric 2D filter that equals 1.0 in the center and tapers to 0.0 at the edges, filtering out frequencies where the signal-to-noise ratio is low.

    Both photutils.psf_matching.make_kernel and photutils.psf_matching.make_wiener_kernel accept a window argument. Note that windows are generally less critical when using make_wiener_kernel because its regularization already suppresses high-frequency noise.

    # Example usage pattern (conceptual)
    kernel = make_kernel(image1, image2, window=TukeyWindow(alpha=0.5))
  11. How errors are estimated for Isophote parameters

    main

    Errors in photutils.isophote are calculated using two different approaches:

    1. Direct Parameters: Most parameters computed directly at each isophote use standard error propagation.
    2. Geometrical Parameters: Errors for the ellipse center, ellipticity, and position angle are estimated empirically. They are computed by "projecting" the harmonic amplitude errors (from the least-squares covariance matrix) using the same formulae used for parameter updates.