科研 Skill

恒星测光分析

photutils-photometry

Performs PSF and aperture photometry with photutils: source detection, PSF fitting, background estimation, multi-epoch light curves. Use for precision stellar photometry beyond one aperture sum.

发布者 Codar安全审核通过v0.1.0更新于 2026-11-18

SKILL.md

Photutils Photometry

Purpose

Covers precision stellar and point-source photometry with photutils: robust background estimation, source detection, aperture photometry with proper error propagation, PSF/PRF model fitting for crowded or faint fields, and building calibrated multi-epoch light curves. The astropy-astronomy skill demonstrates a single introductory aperture-photometry example; this skill goes further — PSF fitting for crowded fields, curve-of-growth aperture correction, and the light-curve assembly needed for variable-star or exoplanet transit work.

Use when a single aperture-sum example is not enough: crowded fields where apertures overlap, faint sources near the detection limit, building a light curve across many epochs, or needing calibrated (not instrumental) magnitudes with honest uncertainties.

When to Use

  • Detecting point sources in an image and measuring their flux with aperture or PSF photometry.
  • Crowded-field photometry where neighboring sources contaminate a simple circular aperture.
  • Building a time-series light curve from many exposures of the same field (variable stars, exoplanet transits, asteroid rotation).
  • Calibrating instrumental magnitudes to a standard photometric system using reference stars.

Prerequisites

  • photutils, astropy, numpy installed (pip install photutils astropy numpy).
  • Background-subtracted or at least bias/flat-corrected science images; this skill covers photometric background estimation for local sky subtraction, not detector-level calibration (bias, dark, flat-fielding), which must already be done.
  • A WCS solution on the image if sky coordinates (rather than only pixel coordinates) are needed for cross-matching detected sources.

Workflow

1. Estimate the background

from photutils.background import Background2D, MedianBackground
from astropy.stats import SigmaClip

sigma_clip = SigmaClip(sigma=3.0)
bkg_estimator = MedianBackground()
bkg = Background2D(data, box_size=(50, 50), filter_size=(3, 3),
                    sigma_clip=sigma_clip, bkg_estimator=bkg_estimator)
data_sub = data - bkg.background

A single global median is rarely good enough for real images with gradients (sky brightness, flat-fielding residuals, vignetting) — use Background2D with a box size a few times larger than the typical source size, not a single scalar background value.

2. Detect sources

from photutils.detection import DAOStarFinder

mean, median, std = sigma_clipped_stats(data_sub, sigma=3.0)
daofind = DAOStarFinder(fwhm=3.0, threshold=5.0 * std)
sources = daofind(data_sub)
  • DAOStarFinder assumes roughly Gaussian, unresolved point sources with a known approximate FWHM; for irregular/extended sources use photutils.segmentation (detect_sources + SourceCatalog) instead.
  • Set the detection threshold as a multiple of the background RMS (commonly 3-5 sigma), not an absolute count value, so it generalizes across exposures with different noise levels.

3. Aperture photometry with proper error propagation

from photutils.aperture import CircularAperture, CircularAnnulus, ApertureStats

positions = list(zip(sources["xcentroid"], sources["ycentroid"]))
apertures = CircularAperture(positions, r=5.0)
annulus = CircularAnnulus(positions, r_in=8.0, r_out=12.0)

ann_stats = ApertureStats(data_sub, annulus, sigma_clip=sigma_clip)
local_bkg = ann_stats.median
aperture_stats = ApertureStats(data_sub, apertures)
net_flux = aperture_stats.sum - local_bkg * apertures.area
  • Propagate Poisson (source) and background noise explicitly for the flux uncertainty: error = sqrt(net_flux / gain + apertures.area * (1 + apertures.area / annulus.area) * bkg_std**2) — this is the standard CCD-equation form; omitting the background-annulus-area term understates the uncertainty for faint sources.
  • Determine the aperture radius from a curve of growth (flux vs. aperture radius on a bright, isolated star in the same frame) rather than guessing a fixed radius, and apply an aperture correction if using a small aperture for crowded-field work.

4. PSF photometry for crowded or faint fields

from photutils.psf import IterativePSFPhotometry, GriddedPSFModel
from photutils.psf import SourceGrouper

grouper = SourceGrouper(min_separation=10)
psf_model = ...  # build or fit an empirical/analytic PSF model, e.g. from photutils.psf.EPSFBuilder
photometry = IterativePSFPhotometry(psf_model=psf_model, fit_shape=(5, 5),
                                     finder=daofind, grouper=grouper)
result = photometry(data_sub)
  • Build an empirical PSF (EPSFBuilder) from several bright, isolated stars in the same frame rather than assuming an analytic Gaussian PSF — real PSFs have wings and asymmetries that bias flux for faint/blended sources if ignored.
  • IterativePSFPhotometry fits overlapping sources jointly and iterates to recover sources missed in crowded regions — use this instead of independent aperture photometry whenever source spacing is comparable to the PSF FWHM.

5. Calibrate to a standard photometric system

  • Compute instrumental magnitude: m_inst = -2.5 * log10(net_flux / exposure_time).
  • Fit a zero-point (and optionally a color term) against reference stars with known catalog magnitudes in the same field (e.g., from a catalog query — see the astro-catalog-queries skill): m_cat = m_inst + ZP + c * (color_term), solved by linear regression over several reference stars, not a single star.
  • Report the zero-point uncertainty (scatter across reference stars) alongside the calibrated magnitudes.

6. Build a multi-epoch light curve

  • Photometer each epoch with a consistent method (same aperture size or same PSF-fitting configuration) so that systematic differences between epochs do not masquerade as source variability.
  • Use several non-variable reference stars in the same field for differential photometry: subtract their magnitude scatter from the target's light curve to remove shared systematics (airmass, transparency, tracking).
  • Flag or clip epochs with poor seeing, clouds, or tracking issues (e.g., using the FWHM or background RMS of that epoch) rather than silently including degraded data points.

Limitations

  • Assumes detector-level calibration (bias, dark, flat-fielding) is already done; this skill covers photometric (not instrumental) calibration.
  • PSF photometry quality depends heavily on having enough bright, isolated stars in the frame to build a good empirical PSF model; very sparse or very crowded fields may need a reference PSF from a different exposure or instrument model.
  • Differential/relative photometry for light curves assumes several non-variable comparison stars exist in the field; absolute flux calibration in the absence of standard-star observations is only approximate.
  • Does not cover space-based instrument-specific pipelines (e.g., JWST/HST native photometry tools), which have their own calibrated photometry packages and conventions.

Quality Checklist

  • Background estimated with a spatially-varying model (Background2D), not a single scalar, unless the field is genuinely flat.
  • Detection threshold set relative to background RMS, not an absolute count.
  • Aperture radius justified by a curve of growth, or PSF model built from real in-frame stars rather than assumed analytically.
  • Flux uncertainty includes both source Poisson noise and background-annulus noise terms.
  • Photometric zero-point fit from multiple reference stars with reported scatter, not a single star.
  • Light curves use consistent per-epoch methodology and differential correction against stable reference stars.

示例提示词

帮我对这组多历元图像做PSF测光并构建变星光变曲线。

所属插件

物理与天文学面向物理与天文研究:有限元、分子动力学、蒙特卡洛、量子计算与量子光学、符号与数值计算、天文数据与地震学分析。

安装该插件会一并获得同领域的 22 个 Skill / MCP。

同插件的其他科研 Skill

常见问题

恒星测光分析能做什么?

Performs PSF and aperture photometry with photutils: source detection, PSF fitting, background estimation, multi-epoch light curves. Use for precision stellar photometry beyond one aperture sum。

如何安装恒星测光分析?

在科搭 Codar 左侧点击「插件」,在「组件」页签搜索「恒星测光分析」并安装;在 Claude Code 或 Codex 中可以发送本页的安装提示词,或下载 Skill 包后解压到 ~/.claude/skills 或 ~/.codex/skills。

恒星测光分析需要哪些权限?

该科研 Skill没有声明额外权限;执行具体操作时仍由 Agent 按自身规则请求确认。

恒星测光分析经过官方审核吗?

是。SpeedSkills 收录的每个版本都会记录内容摘要与权限声明,当前版本已通过安全审核。