Communitygithub.com

ASoudy/AGS

Astropy は天文学研究のためのコアPythonパッケージで、座標変換、単位計算、FITSファイル操作、宇宙論計算などに不可欠な機能を提供します。

AGS とは?

Astropyは、天文学研究におけるデータ分析と計算に不可欠なPythonパッケージです。このスキルは、IAU基準の座標系(ICRS、銀河座標、FK5、AltAzなど)間の変換、物理単位と量の安全な変換、FITSファイルの読み書き、宇宙論的距離や時間の計算、高精度な時刻処理(UTC、TAI、TT、TDBなど)、表形式データの操作(カタログのクロスマッチングや結合)、WCSによるピクセルと世界座標の変換など、天文学者が日常的に行う作業を効率的に実行できます。Claude Code、Cursor、CodexなどのAIエージェントで使用することを想定しており、SKILL.mdに基づいて各モジュールの使い方とベストプラクティスを説明しています。プラットフォームに依存せず、インストール( `uv pip install astropy` )ですぐに利用可能で、大規模データセットや高精度計算にも対応できるよう設計されています。

対応~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/ASoudy/AGS/tree/HEAD/AGAS/plugins/antigravity-awesome-skills-claude/skills/astropy

お気に入りのAIに質問する

このエージェントスキルを事前に読み込んだ状態で新しいチャットを開きます。

ドキュメント

Astropy

概要

Astropy は天文学研究のためのコアPythonパッケージであり、天文学研究とデータ分析に不可欠な機能を提供します。座標変換、単位と量の計算、FITSファイル操作、宇宙論計算、高精度な時刻処理、表形式データの操作、天文学的な画像処理に astropy を使用してください。

このスキルを使用するタイミング

以下の作業に astropy を使用します。

  • 天体座標系(ICRS、銀河座標、FK5、AltAzなど)の変換
  • 物理単位と量(Jy を mJy に、パーセクを km に変換など)の操作
  • 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、銀河座標、FK5、AltAzなど)で SkyCoord を使用して座標を作成
  • 座標系間の変換
  • 角距離と位置角の計算
  • カタログへの座標マッチング
  • 3D座標操作のための距離の組み込み
  • 固有運動と視線速度の扱い
  • オンラインデータベースからの天体名の検索

参照: references/coordinates.md に詳細な座標フレームの説明、変換、観測者依存フレーム(AltAz)、カタログマッチング、パフォーマンスのヒントがあります。

3. 宇宙論計算(astropy.cosmology)

標準的な宇宙モデルを使用して宇宙論計算を実行します。

主要な操作:

  • 組み込み宇宙モデル(Planck18、WMAP9など)の使用
  • カスタム宇宙モデルの作成
  • 距離計算(光度距離、共動距離、角直径距離)
  • 年齢と遡及時間の計算
  • 任意の赤方偏移におけるハッブルパラメータの計算
  • 密度パラメータと体積の計算
  • 逆計算(特定の距離に対応する赤方偏移の検索)

参照: references/cosmology.md に利用可能なモデル、距離計算、時間計算、密度パラメータ、ニュートリノ効果があります。

4. FITSファイル操作(astropy.io.fits)

FITS(Flexible Image Transport System)ファイルの読み取り、書き込み、操作を行います。

主要な操作:

  • コンテキストマネージャを使用して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 次元データセットのコンテナ。

モデリング

天文データに数理モデルを作成し適合させるためのフレームワーク。

可視化

適切な引き伸ばしとスケーリングを用いた天文画像表示のためのツール。

定数

適切な単位を持つ物理定数と天文定数(光速度、太陽質量、プランク定数など)。

畳み込み

平滑化とフィルタリングのための画像処理カーネル。

統計

シグマクリッピングや外れ値除去を含むロバストな統計関数。

インストール

# 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 20 individual skills — each has its own dedicated page.

ASoudy/AGS

Advanced JavaScript animation library skill for creating complex, high-performance web animations.

ASoudy/AGS

Build content-focused websites with Astro — zero JS by default, islands architecture, multi-framework components, and Markdown/MDX support.

ASoudy/AGS

One sentence - what this skill does and when to invoke it

ASoudy/AGS

Audit and fix animation performance issues including layout thrashing, compositor properties, scroll-linked motion, and blur effects. Use when animations stutter, transitions jank, or reviewing CSS/JS animation performance.

ASoudy/AGS

Internationalization and localization patterns. Detecting hardcoded strings, managing translations, locale files, RTL support.

ASoudy/AGS

Pull a YouTube video transcript into a queryable markdown vault with yt-dlp subtitle discovery, VTT cleanup, metadata frontmatter, and capture-seed stubs.

ASoudy/AGS

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.

ASoudy/AGS

Generates high-converting Next.js/React landing pages with Tailwind CSS. Uses PAS, AIDA, and BAB frameworks for optimized copy/components (Heroes, Features, Pricing). Focuses on Core Web Vitals/SEO.

ASoudy/AGS

AI-powered animation tool for creating motion in logos, UI, icons, and social media assets.

ASoudy/AGS

CRITICAL: Use for Makepad animation system. Triggers on: makepad animation, makepad animator, makepad hover, makepad state, makepad transition, "from: { all: Forward", makepad pressed, makepad 动画, makepad 状态, makepad 过渡, makepad 悬停效果

ASoudy/AGS

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

ASoudy/AGS

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

ASoudy/AGS

Expert integration of Supabase Auth with Next.js App Router

ASoudy/AGS

React and Next.js 14+ application development with App Router, Server Components, TypeScript, Tailwind CSS, and modern frontend patterns.

ASoudy/AGS

Best practices for Remotion - Video creation in React

ASoudy/AGS

Generate walkthrough videos from Stitch projects using Remotion with smooth transitions, zooming, and text overlays

ASoudy/AGS

Seek and analyze video content using Memories.ai Large Visual Memory Model for persistent video intelligence

ASoudy/AGS

Writes complete, structured landing pages optimized for SEO ranking, AEO citation, and visitor conversion. Activate when the user wants to write or generate a landing page for a product, service, or offer.

ASoudy/AGS

Three.js animation - keyframe animation, skeletal animation, morph targets, animation mixing. Use when animating objects, playing GLTF animations, creating procedural motion, or blending animations.

ASoudy/AGS

Skill for discovering and researching autonomous AI agents, tools, and ecosystems using the AgentFolio directory.

関連スキル