Source Detection

The module provides tools and algorithms for detecting and extracting point-like sources.

Performance

Below are some benchmarks comparing the source detection capabilities of Photometry.jl with the photutils astropy package. The benchmark code can be found in the bench folder.

Julia Version 1.12.6
Commit 15346901f00 (2026-04-09 19:20 UTC)
Build Info:
  Official https://julialang.org release
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 12 × AMD Ryzen 5 PRO 6650U with Radeon Graphics
  WORD_SIZE: 64
  LLVM: libLLVM-18.1.7 (ORCJIT, znver3)
  GC: Built with stock GC
Threads: 1 default, 1 interactive, 1 GC (on 12 virtual cores)

API/Reference

Photometry.Detection.extract_sources — Function
extract_sources(::SourceFinder, data, [error]; sort=true)

Find and extract point-like sources in data using the given Detection.SourceFinder algorithm.

Returns a TypedTables.Table with the positions of the sources and any information specific to the algorithm. For instance, PeakMesh adds a value column with the peak values.

The returned x/y positions index the first/second axis of data respectively, following the Pixel Convention shared with the aperture types. This allows detected sources to be passed directly to the aperture constructors, e.g., CircularAperture.(sources.x, sources.y, r).

data is assumed to be background-subtracted. If error is provided it will be propagated into the detection algorithm. If sort is true the sources will be sorted by their amplitude, otherwise they are returned in array (column-major) order.

error should be nothing or an AbstractArray with the same axes as data defining the expected error in each pixel. If nothing is provided, any local maximum is returned, including negative values. The default is a lazy array of zeros (FillArrays.Zeros), which means only positive pixels are returned.

See Also

Example

julia> data = zeros(20, 30); data[4, 27] = 5; data[10, 3] = 3;

julia> sources = extract_sources(PeakMesh(), data)
Table with 3 columns and 2 rows:
     x   y   value
   ┌──────────────
 1 │ 4   27  5.0
 2 │ 10  3   3.0

julia> photometry(CircularAperture.(sources.x, sources.y, 2.0), data).aperture_sum
2-element Vector{Float64}:
 5.0
 3.0
source