astropy-fundamentals
БесплатноБез исполняемых скриптовНе проверенUse when the user asks about astronomical data, FITS files, celestial coordinates, photometry, spectroscopy, or references AstroPy. Work with astronomical…
от uw-ssec★ 33 звезды на GitHubОб этом скилле
Astropy Fundamentals
Quick Reference Card
Installation
pixi add astropy photutils specutils # recommended
pip install astropy[all] photutils specutils
Essential Imports & One-Liners
import astropy.units as u
from astropy.io import fits
from astropy.coordinates import SkyCoord
from astropy.time import Time
from astropy.table import Table, QTable
from astropy.wcs import WCS
# Units
distance = 10 * u.parsec
freq = (5000 * u.angstrom).to(u.Hz, equivalencies=u.spectral())
# FITS I/O
with fits.open('image.fits') as hdul:
data, header = hdul[0].data, hdul[0].header
# Coordinates
coord = SkyCoord(ra=10.625*u.degree, dec=41.2*u.degree, frame='icrs')
galactic = coord.galactic
sep = coord.separation(other_coord)
# Time
t = Time('2024-01-01T00:00:00', format='isot', scale='utc')
future = t + 1*u.day
# Tables
tbl = QTable([ra_col, dec_col, flux_col], names=['ra', 'dec', 'flux'])
filtered = tbl[tbl['flux'] > 100]
# WCS
wcs = WCS(header)
sky = wcs.pixel_to_world(x_pix, y_pix) # returns SkyCoord
Module Decision Tree
Working with astronomical data?
├─ FITS files → astropy.io.fits
├─ Celestial coordinates → astropy.coordinates (SkyCoord)
├─ Physical quantities → astropy.units
├─ Astronomical time → astropy.time
├─ Catalogs / tables → astropy.table (QTable preserves units)
├─ Image pixel ↔ sky → astropy.wcs
├─ Photometry → photutils
└─ Spectroscopy → specutils
Coordinate task?
├─ Transform frame → SkyCoord.transform_to() or .galactic / .fk5
├─ Angular separation → SkyCoord.separation()
├─ Cross-match catalogs → SkyCoord.match_to_catalog_sky()
└─ Alt/Az (needs location + time) → AltAz frame
Unit task?
├─ Convert units → quantity.to(target_unit)
├─ Wavelength ↔ frequency → u.spectral() equivalency
├─ Doppler shift → u.doppler_radio() / u.doppler_optical()
└─ Magnitudes → u.ABmag, quantity.physical
Module Reference
Detailed patterns and code for each module are in references/patterns.md.
| Module | Key classes / functions | patterns.md section |
|---|---|---|
astropy.io.fits |
fits.open(), HDUList, PrimaryHDU, ImageHDU |
FITS Manipulation Patterns |
astropy.units |
u.<unit>, .to(), equivalencies |
Units and Quantities Patterns |
astropy.coordinates |
SkyCoord, EarthLocation, AltAz |
Coordinate Patterns |
astropy.time |
Time, TimeDelta, TimeSeries |
Time Patterns |
astropy.table |
Table, QTable, join() |
Table Patterns |
astropy.wcs |
WCS, Cutout2D |
WCS Patterns |
photutils |
DAOStarFinder, CircularAperture, aperture_photometry() |
Photometry Patterns |
specutils |
Spectrum1D, fit_lines, fit_generic_continuum |
Spectroscopy Patterns |
Non-obvious gotchas per module (things Claude won't assume you know):
- FITS:
fits.open()withoutmemmap=Trueloads the whole file into RAM — always usememmap=Truefor files > a few hundred MB. - Units: NumPy ufuncs generally preserve units, but third-party functions often strip them silently — check with
isinstance(result, u.Quantity). - Coordinates:
AltAzrequires bothobstime=andlocation=or it raisesCoordinateFrameErrorat transform time, not at construction time. - Time:
UTCandTAIdiffer by the current leap-second count (~37 s as of 2024). Subtracting twoTimeobjects in different scales gives a non-zeroTimeDelta. Convert to the same scale first. - WCS:
all_pix2world(x, y, 0)uses Python 0-based convention;all_pix2world(x, y, 1)uses FITS 1-based convention. Mixing these off by one is a common silent error. - Photutils:
aperture_photometry()does not subtract background — always subtract background separately or useCircularAnnulusfor local background.
See references/common-issues.md for full error messages and fixes.
FITS Image Processing Workflow
A complete pipeline with explicit validation checkpoints. See references/examples.md for full implementations of this and five other workflows (catalog cross-matching, light curve analysis, SED construction, spectroscopic redshift, observability calculation).
from astropy.io import fits
from astropy.wcs import WCS
from astropy.stats import sigma_clipped_stats, SigmaClip
from astropy.table import QTable
import astropy.units as u
import numpy as np
from photutils.detection import DAOStarFinder
from photutils.aperture import CircularAperture, CircularAnnulus, aperture_photometry
from photutils.background import Background2D, MedianBackground
# ── Step 1: Load ────────────────────────────────────────────────────────────
with fits.open('image.fits', memmap=True) as hdul:
image = hdul[0].data.astype(float)
header = hdul[0].header
wcs = WCS(header)
# Checkpoint 1: confirm image loaded and WCS is valid
assert image is not None, "Image data is None — check H
Установить astropy-fundamentals в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл astropy-fundamentals?
Use when the user asks about astronomical data, FITS files, celestial coordinates, photometry, spectroscopy, or references AstroPy. Work with astronomical data using AstroPy for FITS file I/O, coordinate transformations, physical units, precise time handling, catalog cross-matching, photutils photometry, and specutils spectroscopy.
Как установить скилл astropy-fundamentals?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл astropy-fundamentals запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
от Anthropicdiscernment-nudge
After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
от Anthropicdata-consolidate
Joins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
от Anthropicinspection-to-capa
Runs the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…
от Anthropic