科研 Skill

天文星表检索

astro-catalog-queries

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.

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

SKILL.md

Astronomical Catalog Queries

Purpose

Covers how to query major astronomical archives and catalogs programmatically, build cone-search and ADQL queries, handle paging and row limits, and cross-match results across surveys by sky position. The astropy-astronomy skill touches a single Gaia/SIMBAD example inline; this skill is the dedicated reference for querying multiple archives, handling their different APIs and quirks, and combining results into a clean working catalog.

Use when a task requires fetching real astronomical data rather than simulating it: building a target list, checking what surveys cover a field, cross-identifying an object across catalogs, or downloading a cutout image or spectrum for further analysis.

When to Use

  • Need photometry, astrometry, or spectroscopic parameters for known objects from Gaia, SDSS, 2MASS, WISE, or similar surveys.
  • Need to cross-match a local source list against a reference catalog by sky position.
  • Need to run a custom ADQL query against a TAP service (Gaia archive, SDSS CasJobs-style services) for a cut on magnitude, color, proper motion, or parallax.
  • Need to resolve an object name to coordinates (SIMBAD/NED) or fetch a cutout image/spectrum for a known target.

Prerequisites

  • astroquery, astropy installed (pip install astroquery astropy); specific submodules query NASA/ESA/university-hosted services over the network, so a working internet connection is required at run time — these are not bundled offline databases.
  • Network access to the relevant archive's TAP/VO service; some services (e.g., Gaia archive large queries) may require registering for anonymous vs. authenticated query limits, covered below.

Workflow

1. Choose the right query interface

  • Cone search (small area, known center): astroquery.vizier.Vizier, astroquery.sdss.SDSS, astroquery.gaia.Gaia.query_object_async — simplest interface, good for "give me everything within N arcmin of this position."
  • ADQL/TAP (complex cuts, large catalogs): astroquery.gaia.Gaia.launch_job_async(adql_query) or astroquery.utils.tap.TapPlus for a generic TAP service — needed for magnitude/color/parallax cuts, joins, or row counts beyond a simple cone search's row limit.
  • Name resolution: astroquery.simbad.Simbad.query_object(name) for basic identification, or astroquery.ipac.ned.Ned.query_object for extragalactic objects, to get coordinates from a name (e.g., "M51", "NGC 5457") or vice versa.
  • Image/spectrum cutouts: astroquery.skyview.SkyView.get_images for multi-survey image cutouts; astroquery.sdss.SDSS.get_spectra for SDSS spectra by position or plate/MJD/fiber ID; astroquery.mast.Observations for HST/JWST/TESS/Kepler data products.

2. Build a cone search

from astroquery.vizier import Vizier
from astropy.coordinates import SkyCoord
import astropy.units as u

coord = SkyCoord.from_name("M51")  # name resolution via SIMBAD/Sesame
Vizier.ROW_LIMIT = -1  # remove the default 50-row cap
result = Vizier.query_region(coord, radius=5 * u.arcmin,
                              catalog="I/350/gaiaedr3")  # Gaia EDR3
table = result[0]

Always set an explicit ROW_LIMIT — the default silently truncates results to 50 rows, a common source of "my catalog looks incomplete" bugs.

3. Build an ADQL query for cuts beyond a cone search

from astroquery.gaia import Gaia

query = """
SELECT source_id, ra, dec, phot_g_mean_mag, parallax, pmra, pmdec
FROM gaiadr3.gaia_source
WHERE 1 = CONTAINS(
    POINT('ICRS', ra, dec),
    CIRCLE('ICRS', 202.47, 47.20, 0.0833))  -- 5 arcmin around M51
  AND phot_g_mean_mag < 18
  AND parallax > 0.2
"""
job = Gaia.launch_job_async(query)
results = job.get_results()

Use launch_job_async (not the synchronous launch_job) for queries that may take more than a few seconds — the archive queues long jobs and the async call polls for completion automatically.

4. Cross-match across catalogs

  • For catalogs already loaded as astropy.table.Table with RA/Dec columns, cross-match with astropy.coordinates.match_to_catalog_sky:
from astropy.coordinates import SkyCoord
import astropy.units as u

cat_a = SkyCoord(ra=table_a["ra"], dec=table_a["dec"], unit="deg")
cat_b = SkyCoord(ra=table_b["ra"], dec=table_b["dec"], unit="deg")
idx, sep2d, _ = cat_a.match_to_catalog_sky(cat_b)
matched = sep2d < 1 * u.arcsec  # keep only matches within 1 arcsec
  • For server-side cross-matching of large catalogs (millions of rows), use the Gaia archive's Gaia.cross_match or VizieR's xmatch service (astroquery.xmatch.XMatch.query) instead of downloading both catalogs and matching locally.
  • Always choose a match radius informed by the positional uncertainties of both catalogs (typically a few tenths of an arcsec to a few arcsec depending on survey epoch and proper motion), and report the chosen radius — an unjustified radius is a common review comment.

5. Handle rate limits, paging, and caching

  • Large archives (Gaia, SDSS) throttle or queue large synchronous queries; prefer async jobs and add TOP n / WHERE cuts during development, removing them only for the final run.
  • astroquery caches query results locally by default (astroquery.cache) — useful for reruns during development, but clear or bypass the cache (cache=False) when the underlying catalog may have been updated (e.g., a new Gaia data release).
  • Respect each archive's usage policy and attribution requirements (most surveys require citing a specific data-release paper, not just "Gaia" or "SDSS" generically — check the archive's citation page).

Limitations

  • Requires live network access to third-party services (ESA Gaia archive, SDSS SkyServer, MAST, NASA/IPAC); none of this works offline, and service outages or schema changes on the provider side are outside this skill's control.
  • ADQL syntax and available tables differ across TAP services (Gaia archive vs. a generic VO TAP endpoint); the examples here target the Gaia archive specifically and may need adjustment for other services.
  • Row limits, query timeouts, and anonymous-vs-authenticated quotas vary by archive and can change; check the specific archive's current documentation for large queries.
  • Does not cover proprietary/embargoed data access (e.g., unreleased HST/JWST proposals), which requires authenticated access through astroquery.mast with credentials managed outside this skill.

Quality Checklist

  • Row limit explicitly set (not left at a silent default) for cone searches.
  • Cross-match radius chosen based on stated positional uncertainties, not an arbitrary round number.
  • Async queries used for anything beyond a trivial cone search.
  • Catalog/data-release version recorded (e.g., "Gaia DR3", not just "Gaia") for reproducibility and citation.
  • Cache behavior considered when re-running against a catalog that may have been updated.

示例提示词

帮我从Gaia和SDSS星表查询某天区的恒星数据并做交叉证认。

所属插件

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

安装该插件会一并获得同领域的 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。

如何安装天文星表检索?

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

天文星表检索需要哪些权限?

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

天文星表检索经过官方审核吗?

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