Community研究與資料分析github.com

marnixGeerkens/rocketlauncher-claude-code

Astropy 天文學 Python 核心套件。用於處理天體座標、物理單位、FITS 檔案、宇宙學計算、時間系統、資料表、世界座標系統 (WCS) 及天文資料分析。

rocketlauncher-claude-code 是什麼?

此技能整合了 Astropy 天文學 Python 核心套件,為 AI Agent 提供處理天文資料的完整功能。支援的關鍵作業包括天體座標系統轉換 (ICRS、銀河座標、AltAz 等)、物理單位與量值計算 (例如 Jy 與 mJy 轉換、秒差距與公里轉換)、FITS 檔案讀取與操作、宇宙學距離計算 (如光度距離、共動距離)、精確時間處理 (UTC、TAI、TT、TDB 等時間尺度及 JD、MJD 格式)、星表資料跨比對與合併,以及影像像素座標與世界座標 (WCS) 間的轉換。該技能適用於 Claude Code、Cursor 等 AI Agent 平台,可直接透過 Python 指令碼呼叫 Astropy 功能,大幅簡化天文資料分析流程。

相容平台✓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、銀河座標、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、銀河座標、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}, 中位數: {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"光度距離: {d_L}")
print(f"角直徑距離: {d_A}")

# 該紅移下的宇宙年齡
age = Planck18.age(z)
print(f"z={z} 時的年齡: {age.to(u.Gyr)}")

# 回溯時間
t_lookback = Planck18.lookback_time(z)
print(f"回溯時間: {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"找到 {len(cat1_matched)} 個匹配")

最佳實務

  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.

相關技能