科研 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.
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 typicallymatplotlibinstalled (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_regionsparameter) 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
Gaussian1Dfor typical emission/absorption lines,Voigt1Dfor 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 forv << c); use the relativistic Doppler formula for high-velocity systems. - Cross-correlation redshift (noisy spectra, many features):
specutilsdoes not include a built-in cross-correlation redshift finder; for stellar/galaxy template cross-correlation useastropy-compatible packages such asPyAstronomy'scrosscorrRVor 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.
specutilshas 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
- 天文星表检索Queries astronomical archives (Gaia, SDSS, VizieR, MAST, NED, SIMBAD) via astroquery/TAP/ADQL and cross-matches results. Use when sourcing or combining survey data by position.
- 天文观测数据分析Runs applied astronomy pipelines with astropy/astroquery: catalog cross-matching, Gaia/SIMBAD queries, aperture photometry, CMB power spectra. Use for end-to-end data-analysis workflows.
- Astropy天文数据处理Covers core Astropy APIs for units, coordinates, FITS I/O, tables, time systems, WCS, and cosmology. Use as the API reference, before reaching for applied workflows.
- 谷歌量子计算框架Builds noise-aware quantum circuits for Google Quantum AI hardware and runs characterization experiments. Use for Google-hardware targeting; use qiskit for IBM or pennylane for differentiable ML.
- 有限元法求解偏微分方程Solves PDEs with finite elements using FEniCS/dolfinx: weak forms, gmsh meshing, Poisson/elasticity problems, boundary conditions, ParaView export. Use for continuum-physics simulation.
- 计算流体力学模拟Runs pseudospectral CFD simulations in Python: Navier-Stokes, shallow water, stratified flows with FFT-based solvers. Use for turbulence, vortex dynamics, or geophysical flow simulation.
- LAMMPS经典分子动力学Runs classical molecular dynamics with LAMMPS: force field selection, NVT/NPT ensembles, RDF/MSD post-processing, OVITO visualization. Use for atomistic materials or molecular simulation.
- 三维科学可视化Creates 3D scientific visualizations with Mayavi: vector fields, isosurfaces, volume rendering, animated 3D plots. Use for visualizing volumetric or vector-field physics data.
- 蒙特卡洛物理模拟Simulates physical systems with Monte Carlo methods: statistical integration, MCMC sampling, the Ising model, error estimation. Use for stochastic physics simulation.
- 地震学数据处理Analyzes seismological data with ObsPy: FDSN waveform download, response removal, phase picking, moment tensor inversion. Use for earthquake and seismic-waveform analysis.
- 粒子图像测速分析Extracts velocity fields from PIV image pairs with OpenPIV: cross-correlation, vector validation, vorticity/strain-rate statistics. Use for experimental fluid-flow measurement.
- 量子机器学习框架Trains quantum circuits with autodiff across IBM/Google/Rigetti/IonQ devices: VQE, QAOA, hybrid models with PyTorch/JAX. Use for gradient-based variational quantum algorithms.
- 恒星测光分析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.
- 物理信息神经网络Builds physics-informed neural networks, neural ODEs, and data-driven force fields with PyTorch, DeepXDE, torchdiffeq. Use for ML-based physics simulation and surrogate modeling.
- IBM量子计算框架Runs IBM Quantum workflows end to end: Runtime primitives, transpilation, hardware backend selection, error mitigation. Use when targeting IBM Quantum hardware or Runtime.
- Qiskit量子线路实验Implements Qiskit algorithms: circuit construction, VQE/QAOA workflows, noise-model simulation, statevector-vs-shot comparisons. Use for algorithm design and local simulation.
- 开放量子系统模拟Simulates open quantum systems with QuTiP: master equations, Lindblad dynamics, decoherence, cavity QED. Use for open-system physics, not circuit-based quantum computing.
- SciPy数值计算工具Solves ODEs/PDEs, runs FFT analysis, optimization, and sparse linear algebra with SciPy for physics problems. Use as the general-purpose numerical-computing toolkit.
- SymPy符号计算Performs symbolic computation for physics with SymPy: algebra, calculus, Lagrangian mechanics, quantum operators, code generation. Use for exact derivations, not numerical solving.
- 物理量纲与不确定度传播Tracks physical units and propagates measurement uncertainty with pint/uncertainties: GUM budgets, Monte Carlo propagation, dimensionless-group checks. Use to sanity-check a result or unit.
- 多维标注数组NetCDF分析Analyzes labeled multi-dimensional arrays with xarray: NetCDF/HDF5 I/O, lazy Dask loading, rechunking, Zarr stores, CF conventions. Use for gridded scientific data handling.
常见问题
天文光谱分析能做什么?
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 收录的每个版本都会记录内容摘要与权限声明,当前版本已通过安全审核。