Communitygithub.com

Anhvu1107/all-agent-skill

當請求與 Astropy 相關時,請務必使用此技能:Astropy 是天文學的核心 Python 套件,為天文研究和數據分析提供基本功能。

all-agent-skill 是什麼?

此技能旨在為 AI 代理(如 Claude Code、Cursor 或 Codex)提供關於 Astropy(天文學的基礎 Python 套件)的完整且專業的使用指引。它涵蓋了座標轉換、單位與量值計算、FITS 檔案操作、宇宙學計算、精確時間處理、表格資料操作以及天文影像處理等核心功能。該技能包含詳細的文件引用、快速入門範例、常見工作流程(如交叉匹配星表、轉換座標系統)以及最佳實務,確保代理能正確且高效地使用 Astropy。主要支援 Python 環境,並通過多個參考文件(如 `references/coordinates.md`)提供深入的模組說明,適合作為處理天文資料任務時的可靠技術手冊。

相容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/Anhvu1107/all-agent-skill/tree/HEAD/.agent/skills/astropy

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

Astropy

選擇性閱讀規則

請從以下文件開始:

  • references/senior-master-standard.md
  • references/usage-routing.md
  • references/quality-checklist.md

然後僅載入與使用者實際任務相符的繼承文件、腳本、資源或範例。

概述

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)

表示天體位置並在不同座標框架之間進行轉換。

主要操作:

  • 在任何框架(ICRS、Galactic、FK5、AltAz 等)中使用 SkyCoord 創建座標
  • 在座標系統之間進行轉換
  • 計算角距離和位置角
  • 將座標匹配到星表
  • 包含距離以進行 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 資訊的多維資料集容器。

建模

用於創建和將數學模型擬合到天文資料的框架。

視覺化

使用適當拉伸和縮放進行天文影像顯示的工具。

常數

具有適當單位的物理和天文常數(光速、太陽質量、普朗克常數等)。

卷積

用於平滑和過濾的影像處理核心。

統計

包含 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} 時的年齡: {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 20 individual skills — each has its own dedicated page.

Anhvu1107/all-agent-skill

ALWAYS use this when the request matches 007: Security audit, hardening, threat modeling (STRIDE/PASTA), Red/Blue Team, OWASP checks, code review, incident response, and infrastructure security for any project.

Anhvu1107/all-agent-skill

ALWAYS use this when the request matches Agentfolio: Skill for discovering and researching autonomous AI agents, tools, and ecosystems using the AgentFolio directory.

Anhvu1107/all-agent-skill

ALWAYS use this when the request matches Animejs Animation: Advanced JavaScript animation library skill for creating complex, high-performance web animations.

Anhvu1107/all-agent-skill

ALWAYS use this when the request matches Astro: Build content-focused websites with Astro — zero JS by default, islands architecture, multi-framework components, and Markdown/MDX support.

Anhvu1107/all-agent-skill

ALWAYS use this when the request matches Emotional ARC Designer: One sentence - what this skill does and when to invoke it

Anhvu1107/all-agent-skill

ALWAYS use this when the request matches Fixing Motion Performance: Audit and fix animation performance issues including layout thrashing, compositor properties, scroll-linked motion, and blur effects.

Anhvu1107/all-agent-skill

ALWAYS use this when the request matches I18n Localization: Internationalization and localization patterns.

Anhvu1107/all-agent-skill

ALWAYS use this when the request matches Interactive Portfolio: Expert in building portfolios that actually land jobs and clients - not just showing work, but creating memorable experiences.

Anhvu1107/all-agent-skill

ALWAYS use this when the request matches JQ: Expert jq usage for JSON querying, filtering, transformation, and pipeline integration.

Anhvu1107/all-agent-skill

ALWAYS use this when the request matches Landing Page Generator: Generates high-converting Next.js/React landing pages with Tailwind CSS.

Anhvu1107/all-agent-skill

ALWAYS use this when the request matches LEX: Centralized ''Truth Engine'' for cross-jurisdictional legal context (US, EU, CA) and contract scaffolding.

Anhvu1107/all-agent-skill

ALWAYS use this when the request matches Magic Animator: AI-powered animation tool for creating motion in logos, UI, icons, and social media assets.

Anhvu1107/all-agent-skill

ALWAYS use this when the request matches Makepad Animation: CRITICAL: Use for Makepad animation system.

Anhvu1107/all-agent-skill

ALWAYS use this when the request matches Nextjs APP Router Patterns: Comprehensive patterns for Next.js 14+ App Router architecture, Server Components, and modern full-stack React development.

Anhvu1107/all-agent-skill

ALWAYS use this when the user mentions Nextjs Best Practices, asks to build, debug, review, document, automate, test, configure, migrate, or make decisions in this domain, or the task clearly depends on Nextjs Best Practices; scope: Next.js App Router principles. Apply the bundled workflow, references, scripts, Senior Master standard, and Codex strict review gate before final output.

Anhvu1107/all-agent-skill

description: ALWAYS use this when the work is specifically about modern Next.js or React architecture, data flow, rendering strategy, routing, or performance-sensitive frontend behavior.

Anhvu1107/all-agent-skill

ALWAYS use this when the request matches Nextjs Supabase Auth: Expert integration of Supabase Auth with Next.js App Router

Anhvu1107/all-agent-skill

ALWAYS use this when the task involves reading, extracting, splitting, merging, rotating, creating, validating, OCR-ing, form-filling, or otherwise producing or modifying PDF files.

Anhvu1107/all-agent-skill

ALWAYS use this when the request matches React Nextjs Development: React and Next.js 14+ application development with App Router, Server Components, TypeScript, Tailwind CSS, and modern frontend patterns.

Anhvu1107/all-agent-skill

ALWAYS use this when working with Remotion code, video compositions, rendering logic, timing, media assets, or React-based motion workflows.

相關技能