Community研究与数据分析github.com

marnixGeerkens/rocketlauncher-claude-code

全方位的 Python 天文学与天体物理学库。该技能应在处理天文数据时使用,包含天体坐标、物理单位、FITS 文件、宇宙学计算、时间系统、表格、世界坐标系统(WCS)以及天文数据分析。

rocketlauncher-claude-code 是什么?

Astropy 是 Python 生态中天文研究的核心库,为开发者提供统一、高效的数据处理能力。该技能集成了坐标变换、单位与量值计算、FITS 文件读写、宇宙学距离与时间计算、高精度时间处理以及表格数据操作等关键功能。无论是进行星表交叉匹配、图像像素与天空坐标转换,还是利用标准宇宙学模型(如 Planck18)计算光度距离,Astropy 都能显著简化工作流。它支持 ICRS、Galactic、AltAz 等多种坐标框架,并内置了物理常数与统计工具。该技能覆盖 Astropy 的主要子模块(units, coordinates, cosmology, io.fits, table, time, wcs),并提供详细的参考文档目录(如 references/units.md),适合在天文数据处理、数值模拟、观测规划等场景中使用。

兼容平台✓Claude Code~Codex CLI~Cursor
npx skills add https://github.com/marnixGeerkens/rocketlauncher-claude-code/tree/HEAD/components/skills/scientific/astropy

Installed? Explore more 研究与数据分析 skills: affaan-m/uspto-database, affaan-m/scholar-evaluation, affaan-m/literature-review · View all 6 →

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

Astropy

概述

Astropy 是 Python 的天文核⼼包,为天⽂研究和数据分析提供基础功能。使用 Astropy 进行坐标变换、单位与量值计算、FITS 文件操作、宇宙学计算、精确时间处理、表格数据操作以及天文图像处理。

何时使用本技能

当任务涉及以下内容时使用 Astropy:

  • 在天体坐标系统之间转换(ICRS、Galactic、FK5、AltAz 等)
  • 处理物理单位和量值(将 Jy 转换为 mJy,秒差距转换为千米等)
  • 读取、写入或操作 FITS 文件(图像或表格)
  • 宇宙学计算(光度距离、回溯时间、哈勃参数)
  • 使用不同时间尺度(UTC、TAI、TT、TDB)和格式(JD、MJD、ISO)进行精确时间处理
  • 表格操作(读取星表、交叉匹配、筛选、合并)
  • 像素坐标与世界坐标之间的 WCS 变换
  • 天文常数与计算

快速开始

import astropy.units as u
from astropy.coordinates import SkyCoord
from astropy.time import Time
from astropy.io import fits
from astropy.table import Table
from astropy.cosmology import Planck18

# 单位与量值
distance = 100 * u.pc
distance_km = distance.to(u.km)

# 坐标
coord = SkyCoord(ra=10.5*u.degree, dec=41.2*u.degree, frame='icrs')
coord_galactic = coord.galactic

# 时间
t = Time('2023-01-15 12:30:00')
jd = t.jd  # 儒略日

# FITS 文件
data = fits.getdata('image.fits')
header = fits.getheader('image.fits')

# 表格
table = Table.read('catalog.fits')

# 宇宙学
d_L = Planck18.luminosity_distance(z=1.0)

核心功能

1. 单位与量值 (astropy.units)

处理带有单位的物理量,执行单位转换,确保计算中的量纲一致性。

关键操作:

  • 将值与单位相乘创建量值
  • 使用 .to() 方法在单位间转换
  • 执行算术运算时自动处理单位
  • 使用等价关系进行特定领域的转换(光谱、多普勒、视差)
  • 处理对数单位(星等、分贝)

参见: references/units.md 了解完整的文档、单位系统、等价关系、性能优化和单位算术。

2. 坐标系统 (astropy.coordinates)

表示天体位置并在不同坐标框架间变换。

关键操作:

  • 使用 SkyCoord 在任意框架(ICRS、Galactic、FK5、AltAz 等)中创建坐标
  • 在坐标系统之间变换
  • 计算角距和位置角
  • 将坐标与星表匹配
  • 加入距离用于 3D 坐标操作
  • 处理自行和径向速度
  • 从在线数据库查询命名天体

参见: references/coordinates.md 了解详细的坐标框架描述、变换、依赖观测者的框架(AltAz)、星表匹配和性能提示。

3. 宇宙学计算 (astropy.cosmology)

使用标准宇宙学模型执行宇宙学计算。

关键操作:

  • 使用内置宇宙模型(Planck18、WMAP9 等)
  • 创建自定义宇宙学模型
  • 计算距离(光度距离、共动距离、角直径距离)
  • 计算年龄和回溯时间
  • 确定任意红移下的哈勃参数
  • 计算密度参数和体积
  • 执行逆向计算(根据给定距离求红移)

参见: references/cosmology.md 了解可用模型、距离计算、时间计算、密度参数和中微子效应。

4. FITS 文件处理 (astropy.io.fits)

读取、写入和操作 FITS(灵活图像传输系统)文件。

关键操作:

  • 使用上下文管理器打开 FITS 文件
  • 按索引或名称访问 HDU(头数据单元)
  • 读取和修改头部项(关键字、注释、历史记录)
  • 处理图像数据(NumPy 数组)
  • 处理表格数据(二进制和 ASCII 表格)
  • 创建新的 FITS 文件(单个或多个扩展)
  • 对大文件使用内存映射
  • 访问远程 FITS 文件(S3、HTTP)

参见: references/fits.md 了解全面的文件操作、头部项操作、图像和表格处理、多扩展文件以及性能考量。

5. 表格操作 (astropy.table)

处理带单位、元数据和支持多种文件格式的表格数据。

关键操作:

  • 从数组、列表或字典创建表格
  • 以多种格式(FITS、CSV、HDF5、VOTable)读写表格
  • 访问和修改列和行
  • 排序、筛选和索引表格
  • 执行数据库风格的操作(合并、分组、聚合)
  • 堆叠和拼接表格
  • 使用单位感知的列(QTable)
  • 使用掩码处理缺失数据

参见: references/tables.md 了解表格创建、I/O 操作、数据操作、排序、筛选、合并、分组和性能提示。

6. 时间处理 (astropy.time)

精确的时间表示以及不同时间尺度和格式之间的转换。

关键操作:

  • 以多种格式(ISO、JD、MJD、Unix 等)创建 Time 对象
  • 在不同时间尺度之间转换(UTC、TAI、TT、TDB 等)
  • 使用 TimeDelta 执行时间算术
  • 计算观测者的恒星时
  • 计算光行时校正(质心、日心)
  • 高效处理时间数组
  • 处理掩码(缺失)时间

参见: references/time.md 了解时间格式、时间尺度、转换、算术、观测功能以及精度处理。

7. 世界坐标系统 (astropy.wcs)

在图像的像素坐标与世界坐标之间变换。

关键操作:

  • 从 FITS 头部项读取 WCS
  • 将像素坐标转换为世界坐标(反之亦然)
  • 计算图像覆盖区域
  • 访问 WCS 参数(参考像素、投影、比例)
  • 创建自定义 WCS 对象

参见: references/wcs_and_other_modules.md 了解 WCS 操作和变换。

附加功能

references/wcs_and_other_modules.md 文件也涵盖了:

NDData 和 CCDData

包含元数据、不确定性、掩码和 WCS 信息的 n 维数据容器。

建模

创建和拟合数学模型的框架。

可视化

用于天文图像显示的工具,支持适当的拉伸和缩放。

常数

带有适当单位的物理和天文常数(光速、太阳质量、普朗克常数等)。

卷积

用于平滑和滤波的图像处理核。

统计

稳健的统计函数,包括 sigma 裁剪和异常值剔除。

安装

# 安装 astropy
uv pip install astropy

# 安装可选依赖以获得完整功能
uv pip install astropy[all]

常见工作流

在坐标系之间转换坐标

from astropy.coordinates import SkyCoord
import astropy.units as u

# 创建坐标
c = SkyCoord(ra='05h23m34.5s', dec='-69d45m22s', frame='icrs')

# 转换为银道坐标
c_gal = c.galactic
print(f"l={c_gal.l.deg}, b={c_gal.b.deg}")

# 转换为高度-方位坐标(需要时间和地点)
from astropy.time import Time
from astropy.coordinates import EarthLocation, AltAz

observing_time = Time('2023-06-15 23:00:00')
observing_location = EarthLocation(lat=40*u.deg, lon=-120*u.deg)
aa_frame = AltAz(obstime=observing_time, location=observing_location)
c_altaz = c.transform_to(aa_frame)
print(f"Alt={c_altaz.alt.deg}, Az={c_altaz.az.deg}")

读取并分析 FITS 文件

from astropy.io import fits
import numpy as np

# 打开 FITS 文件
with fits.open('observation.fits') as hdul:
    # 显示结构
    hdul.info()

    # 获取图像数据和头部项
    data = hdul[1].data
    header = hdul[1].header

    # 访问头部项值
    exptime = header['EXPTIME']
    filter_name = header['FILTER']

    # 分析数据
    mean = np.mean(data)
    median = np.median(data)
    print(f"Mean: {mean}, Median: {median}")

宇宙学距离计算

from astropy.cosmology import Planck18
import astropy.units as u
import numpy as np

# 计算 z=1.5 处的距离
z = 1.5
d_L = Planck18.luminosity_distance(z)
d_A = Planck18.angular_diameter_distance(z)

print(f"Luminosity distance: {d_L}")
print(f"Angular diameter distance: {d_A}")

# 该红移处的宇宙年龄
age = Planck18.age(z)
print(f"Age at z={z}: {age.to(u.Gyr)}")

# 回溯时间
t_lookback = Planck18.lookback_time(z)
print(f"Lookback time: {t_lookback.to(u.Gyr)}")

星表交叉匹配

from astropy.table import Table
from astropy.coordinates import SkyCoord, match_coordinates_sky
import astropy.units as u

# 读取星表
cat1 = Table.read('catalog1.fits')
cat2 = Table.read('catalog2.fits')

# 创建坐标对象
coords1 = SkyCoord(ra=cat1['RA']*u.degree, dec=cat1['DEC']*u.degree)
coords2 = SkyCoord(ra=cat2['RA']*u.degree, dec=cat2['DEC']*u.degree)

# 查找匹配
idx, sep, _ = coords1.match_to_catalog_sky(coords2)

# 按分离角阈值筛选
max_sep = 1 * u.arcsec
matches = sep < max_sep

# 创建匹配后的星表
cat1_matched = cat1[matches]
cat2_matched = cat2[idx[matches]]
print(f"Found {len(cat1_matched)} matches")

最佳实践

  1. 始终使用单位:为量值附加单位以避免错误并确保量纲一致性
  2. 对 FITS 文件使用上下文管理器:确保文件正确关闭
  3. 优先使用数组而非循环:将多个坐标/时间作为数组处理以获得更好性能
  4. 检查坐标框架:在变换前确认框架
  5. 使用适当的宇宙学模型:为分析选择合适的宇宙学模型
  6. 处理缺失数据:对含有缺失值的表格使用掩码列
  7. 指定时间尺度:在精确计时中明确时间尺度(UTC、TT、TDB)
  8. 使用 QTable 处理单位感知的表格:当表格列具有单位时
  9. 检查 WCS 有效性:在使用变换前验证 WCS
  10. 缓存常用值:昂贵的计算(如宇宙学距离)可以缓存

文档与资源

参考文件

有关特定模块的详细信息:

  • references/units.md - 单位、量值、转换和等价关系
  • references/coordinates.md - 坐标系统、变换和星表匹配
  • references/cosmology.md - 宇宙学模型和计算
  • references/fits.md - FITS 文件操作和处理
  • references/tables.md - 表格创建、I/O 和操作
  • references/time.md - 时间格式、尺度和计算
  • references/wcs_and_other_modules.md - WCS、NDData、建模、可视化、常数和实用工具

Individual skills in this repo

This repo contains 13 individual skills — each has its own dedicated page.

marnixGeerkens/rocketlauncher-claude-code

When the user wants to optimize, improve, or increase conversions on any marketing page — including homepage, landing pages, pricing pages, feature pages, or blog posts. Also use when the user says "CRO," "conversion rate optimization," "this page isn't converting," "improve conversions," or "why isn't this page working." For signup/registration flows, see signup-flow-cro. For post-signup activation, see onboarding-cro. For forms outside of signup, see form-cro. For popups/modals, see popup-cro.

marnixGeerkens/rocketlauncher-claude-code

Balance visual design with ATS compatibility for creative roles. Use when the user is in design, art, writing, marketing creative, or any visual/creative field and needs a resume that looks distinctive but still parses.

marnixGeerkens/rocketlauncher-claude-code

Transform resume bullets into detailed portfolio case studies with context, action, and outcome. Use when the user mentions portfolio, case study, project write-up, or expanding a resume bullet into a longer narrative.

marnixGeerkens/rocketlauncher-claude-code

Expert in building portfolios that actually land jobs and clients - not just showing work, but creating memorable experiences. Covers developer portfolios, designer portfolios, creative portfolios, and portfolios that convert visitors into opportunities. Use when: portfolio, personal website, showcase work, developer portfolio, designer portfolio.

marnixGeerkens/rocketlauncher-claude-code

Tailwind CSS v4 principles. CSS-first configuration, container queries, modern patterns, design token architecture.

marnixGeerkens/rocketlauncher-claude-code

Frontend development patterns for React, Next.js, state management, performance optimization, and UI best practices.

marnixGeerkens/rocketlauncher-claude-code

Frontend development guidelines for React/TypeScript applications. Modern patterns including Suspense, lazy loading, useSuspenseQuery, file organization with features directory, MUI v7 styling, TanStack Router, performance optimization, and TypeScript best practices. Use when creating components, pages, features, fetching data, styling, routing, or working with frontend code.

marnixGeerkens/rocketlauncher-claude-code

Next.js App Router principles. Server Components, data fetching, routing patterns.

marnixGeerkens/rocketlauncher-claude-code

Expert integration of Supabase Auth with Next.js App Router Use when: supabase auth next, authentication next.js, login supabase, auth middleware, protected route.

marnixGeerkens/rocketlauncher-claude-code

Comprehensive frontend development skill for building modern, performant web applications using ReactJS, NextJS, TypeScript, Tailwind CSS. Includes component scaffolding, performance optimization, bundle analysis, and UI best practices. Use when developing frontend features, optimizing performance, implementing UI/UX designs, managing state, or reviewing frontend code.

marnixGeerkens/rocketlauncher-claude-code

Create API handoff documentation for frontend developers. Use when backend work is complete and needs to be documented for frontend integration, or user says 'create handoff', 'document API', 'frontend handoff', or 'API documentation'.

marnixGeerkens/rocketlauncher-claude-code

Document frontend data needs for backend developers. Use when frontend needs to communicate API requirements to backend, or user says 'backend requirements', 'what data do I need', 'API requirements', or is describing data needs for a UI.

marnixGeerkens/rocketlauncher-claude-code

Comprehensive patterns for Next.js 14+ App Router architecture, Server Components, and modern full-stack React development.

相关技能