科研 Skill

天文光谱分析

astronomical-spectroscopy

Reduces 1D astronomical spectra with specutils: continuum normalization, line fitting, redshift/radial-velocity measurement, equivalent widths. Use for spectral classification or velocity work.

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

SKILL.md

Astronomical Spectroscopy

Purpose

Covers the standard workflow for analyzing a reduced 1D astronomical spectrum: loading it into a Spectrum1D object, normalizing the continuum, fitting emission/absorption lines, measuring redshift or radial velocity from line positions, and computing equivalent widths and line fluxes. This is distinct from instrument-specific data reduction pipelines (bias/flat correction, wavelength calibration from arc lamps) — it assumes a already wavelength-calibrated, flux- or count-level 1D spectrum as the starting point, the typical output of a reduction pipeline or an archive download.

Use when a task involves identifying spectral lines, measuring a redshift or Doppler velocity, classifying a spectral type, or reporting a line flux/equivalent width from spectroscopic data.

When to Use

  • A reduced 1D spectrum (FITS or ASCII, wavelength + flux) needs line identification, redshift, or velocity measurement.
  • Converting observed wavelengths of known lines (Halpha, [OIII], Ca II H&K, etc.) into a redshift or radial velocity.
  • Measuring equivalent width or integrated flux of an emission or absorption feature.
  • Normalizing a noisy continuum before line fitting, or stacking multiple exposures of the same spectrum.

Prerequisites

  • specutils, astropy, and typically matplotlib installed (pip install specutils astropy).
  • A wavelength-calibrated 1D spectrum (FITS with a WCS/wavelength axis, or a plain table of wavelength and flux). Raw 2D detector frames, arc-lamp wavelength solutions, and flux calibration against a standard star are reduction steps that happen before this skill and are not covered here — use an instrument-specific reduction pipeline (e.g., IRAF/PypeIt/specreduce) first.

Workflow

1. Load the spectrum

from specutils import Spectrum1D
import astropy.units as u
from astropy.io import fits

spec = Spectrum1D.read("galaxy_spectrum.fits")  # auto-detects common formats
# or build manually from arrays:
# spec = Spectrum1D(flux=flux*u.Jy, spectral_axis=wave*u.angstrom)

Always check spec.spectral_axis.unit and spec.flux.unit explicitly — mismatched or missing units (e.g., treating pixel index as wavelength) are the most common source of wrong line-identification results.

2. Normalize the continuum

from specutils.fitting import fit_generic_continuum
from specutils.manipulation import noise_region_uncertainty

continuum_fit = fit_generic_continuum(spec)
continuum = continuum_fit(spec.spectral_axis)
normalized = spec / continuum
  • For spectra with strong, broad features, exclude obvious line regions from the continuum fit (exclude_regions parameter) so the continuum estimate is not biased low/high near strong lines.
  • Inspect the normalized spectrum visually before fitting lines; a poor continuum fit is the most common cause of biased equivalent widths.

3. Identify and fit lines

from specutils.fitting import fit_lines
from specutils import SpectralRegion
from astropy.modeling import models

region = SpectralRegion(6550 * u.angstrom, 6580 * u.angstrom)  # near Halpha
sub_spectrum = spec_extract_region(normalized, region)  # see specutils.manipulation.extract_region
g_init = models.Gaussian1D(amplitude=1.0, mean=6563 * u.angstrom, stddev=3 * u.angstrom)
g_fit = fit_lines(sub_spectrum, g_init)
  • Use Gaussian1D for typical emission/absorption lines, Voigt1D for lines with broadened wings (pressure or instrumental broadening), or a double-Gaussian for blended doublets (e.g., [OIII] 4959/5007, Na D).
  • Report the fitted line center with its formal uncertainty from the fit covariance, not just a by-eye estimate.

4. Measure redshift or radial velocity

  • Redshift from a single identified line: z = (lambda_observed - lambda_rest) / lambda_rest. Cross-check with at least one additional line when possible — a single-line redshift is fragile to line misidentification (e.g., confusing [OIII] 5007 with Halpha at a different redshift).
  • Radial velocity from a line shift: for non-cosmological velocities, v = c * (lambda_observed - lambda_rest) / lambda_rest (classical Doppler, valid for v << c); use the relativistic Doppler formula for high-velocity systems.
  • Cross-correlation redshift (noisy spectra, many features): specutils does not include a built-in cross-correlation redshift finder; for stellar/galaxy template cross-correlation use astropy-compatible packages such as PyAstronomy's crosscorrRV or survey-specific pipelines (e.g., SDSS redshift pipeline outputs) rather than reimplementing it from scratch.
  • Always state the rest-frame wavelength reference and vacuum-vs-air wavelength convention used (optical line lists are commonly tabulated in air wavelengths below ~2000 Angstrom transitions at ground-based resolution; mixing air and vacuum wavelengths is a frequent few-hundred km/s systematic error).

5. Compute equivalent width and line flux

from specutils.analysis import equivalent_width, line_flux

ew = equivalent_width(normalized, regions=region)
flux = line_flux(spec, regions=region)  # on the un-normalized, flux-calibrated spectrum
  • Equivalent width is computed on the continuum-normalized spectrum; line flux requires the flux-calibrated (not normalized) spectrum — using the wrong one for each is a common mistake.
  • Report the spectral region (wavelength bounds) used for the integration alongside the result, since equivalent width is sensitive to the chosen bandpass.

6. Sanity-check results

  • Compare measured line ratios (e.g., [OIII]/Hbeta, [NII]/Halpha) to expected physical ranges (e.g., BPT diagram loci) as a plausibility check for galaxy spectra.
  • Check that the measured redshift is consistent with any independent redshift estimate (photometric redshift, catalog redshift) within the expected scatter.

Limitations

  • Assumes an already wavelength- and (for line-flux work) flux-calibrated 1D spectrum; raw detector frames, arc-lamp wavelength solutions, sky subtraction, and telluric correction are out of scope — use an instrument-specific reduction pipeline first.
  • specutils has no built-in template cross-correlation redshift finder; high-precision or low-S/N redshift work typically needs a dedicated package or survey pipeline, mentioned here but not implemented.
  • Line-list rest wavelengths and the air/vacuum convention must be supplied by the user from an authoritative source (e.g., NIST ASD, a published line list) — this skill does not bundle one.
  • Does not cover 2D/3D (IFU, slit) spectroscopy extraction; assumes the 1D extraction has already happened.

Quality Checklist

  • Spectral axis and flux units verified before any line identification.
  • Continuum fit inspected visually; line regions excluded from the continuum fit.
  • Rest wavelength source and air/vacuum convention stated explicitly.
  • Redshift or velocity cross-checked against at least one independent line or external estimate when possible.
  • Equivalent width computed on normalized flux; line flux computed on calibrated (non-normalized) flux.

示例提示词

我有一条星系光谱,帮我做连续谱归一化、谱线拟合和红移测量。

所属插件

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

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

同插件的其他科研 Skill

常见问题

天文光谱分析能做什么?

Reduces 1D astronomical spectra with specutils: continuum normalization, line fitting, redshift/radial-velocity measurement, equivalent widths. Use for spectral classification or velocity work。

如何安装天文光谱分析?

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

天文光谱分析需要哪些权限?

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

天文光谱分析经过官方审核吗?

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