Communitygithub.com

Anhvu1107/astropy-全技能

リクエストがAstropyに該当する場合に必ず使用します。Astropyは天文学研究とデータ解析に不可欠な機能を提供する、天文学のためのコアPythonパッケージです。

astropy-全技能 とは?

このスキルは、天文学研究とデータ解析のためのコアPythonパッケージであるAstropyを利用する際の包括的なガイドを提供します。座標変換、単位と物理量の計算、FITSファイル操作、宇宙論的計算、精密な時間処理、表形式データ操作、天文画像処理など、主要な機能をカバーしています。このスキルは、Claude Code、Cursor、CodexなどのAIエージェントが、ユーザーのタスクに応じて適切なAstropyモジュールとAPIを素早く特定し、効率的なコードを生成するのに役立ちます。また、ベストプラクティスや参考ファイルへのリンクも含まれており、AIエージェントがプロジェクトのルールに従い、高品質なコードを提供できるように設計されています。

対応~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/Anhvu1107/all-agent-skill/tree/HEAD/.agent/skills/astropy

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

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

ドキュメント

Astropy

選択的読み込みルール

以下のファイルから始めてください:

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

次に、ユーザーの実際のタスクに一致する継承されたドキュメント、スクリプト、アセット、または例のみを読み込んでください。

概要

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など)の使用
  • カスタム宇宙モデルの作成
  • 距離の計算(光度距離、共動距離、角直径距離)
  • 年齢とルックバックタイムの計算
  • 任意の赤方偏移におけるハッブルパラメータの決定
  • 密度パラメータと体積の計算
  • 逆計算(与えられた距離からzを求める)

参照: 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.

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.

関連スキル