Communitygithub.com

Astropy

Astropy는 천문학 연구와 데이터 분석에 필수적인 기능을 제공하는 천문학용 핵심 Python 패키지입니다.

Astropy란 무엇인가요?

Astropy는 천문학 연구를 위한 핵심 Python 패키지로, 좌표 변환, 단위 및 물리량 계산, FITS 파일 처리, 우주론 계산, 정밀 시간 처리, 테이블 데이터 조작, 천문 이미지 처리 등 다양한 기능을 제공합니다. 이 스킬은 Claude Code, Cursor, Codex 등 AI 에이전트가 천문학 관련 작업을 수행할 때 유용합니다. `astropy.units`를 통한 단위 변환, `astropy.coordinates`의 `SkyCoord`를 사용한 다양한 천체 좌표계 간 변환, `astropy.io.fits`를 사용한 FITS 파일 읽기/쓰기, `astropy.cosmology`의 Planck18 모델 등을 활용한 우주론 계산, `astropy.time`을 사용한 여러 시간 척도 간 변환, `astropy.table`을 사용한 카탈로그 처리 및 교차 매칭을 지원합니다. AI 에이전트는 이 스킬을 통해 코드 생성 시 자동으로 적절한 단위를 첨부하고, FITS 파일을 안전하게 처리하며, 배열 기반 연산을 통해 성능을 최적화하는 모범 사례를 따를 수 있습니다. 또한 WCS 변환, NDData, 모델링, 시각화 등 추가 기능을 위한 참조 파일도 제공합니다.

지원 대상~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/AbobakrDiara61/railway-system/tree/HEAD/frontend/skills/astropy

즐겨 사용하는 AI에게 물어보기

이 에이전트 스킬이 미리 로드된 새 채팅을 엽니다.

문서

Astropy은(는) 무엇을 하나요?

개요

Astropy는 천문학 연구와 데이터 분석에 필수적인 기능을 제공하는 천문학용 핵심 Python 패키지입니다. astropy를 사용하여 좌표 변환, 단위 및 물리량 계산, FITS 파일 처리, 우주론 계산, 정밀 시간 처리, 테이블 데이터 조작, 천문 이미지 처리 등을 수행할 수 있습니다.

이 스킬을 사용해야 할 때

다음과 같은 작업에 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 좌표 연산을 위한 거리 포함
  • 고유 운동과 시선 속도 처리
  • 온라인 데이터베이스에서 명명된 객체 조회

참고: 자세한 좌표 프레임 설명, 변환, 관측자 의존 프레임(AltAz), 카탈로그 매칭 및 성능 팁은 references/coordinates.md를 참조하세요.

3. 우주론 계산 (astropy.cosmology)

표준 우주론 모델을 사용하여 우주론 계산을 수행합니다.

주요 연산:

  • 내장 우주론 모델(Planck18, WMAP9 등) 사용
  • 사용자 정의 우주론 모델 생성
  • 거리 계산(광도, 공변, 각지름)
  • 나이와 후퇴 시간 계산
  • 임의 적색편이에서 허블 매개변수 결정
  • 밀도 매개변수와 부피 계산
  • 역 계산(주어진 거리에 대한 z 찾기)

참고: 사용 가능한 모델, 거리 계산, 시간 계산, 밀도 매개변수 및 중성미자 효과는 references/cosmology.md를 참조하세요.

4. FITS 파일 처리 (astropy.io.fits)

FITS 파일을 읽고, 쓰고, 조작합니다.

주요 연산:

  • 컨텍스트 관리자로 FITS 파일 열기
  • 인덱스나 이름으로 HDU(Header Data Unit) 접근
  • 헤더 읽기 및 수정(키워드, 주석, 이력)
  • 이미지 데이터(NumPy 배열) 작업
  • 테이블 데이터(이진 및 ASCII 테이블) 처리
  • 새 FITS 파일 생성(단일 또는 다중 확장)
  • 대용량 파일을 위한 메모리 매핑 사용
  • 원격 FITS 파일(S3, HTTP) 접근

참고: 포괄적인 파일 작업, 헤더 조작, 이미지 및 테이블 처리, 다중 확장 파일 및 성능 고려 사항은 references/fits.md를 참조하세요.

5. 테이블 연산 (astropy.table)

단위, 메타데이터 및 다양한 파일 형식을 지원하는 테이블 형식 데이터 작업.

주요 연산:

  • 배열, 리스트 또는 사전에서 테이블 생성
  • 여러 형식(FITS, CSV, HDF5, VOTable)으로 테이블 읽기/쓰기
  • 열과 행 접근 및 수정
  • 테이블 정렬, 필터링, 인덱싱
  • 데이터베이스 스타일 연산(조인, 그룹화, 집계)
  • 테이블 쌓기 및 연결
  • 단위 인식 열 작업 (QTable)
  • 마스킹으로 결측 데이터 처리

참고: 테이블 생성, I/O 연산, 데이터 조작, 정렬, 필터링, 조인, 그룹화 및 성능 팁은 references/tables.md를 참조하세요.

6. 시간 처리 (astropy.time)

정밀 시간 표현 및 시간 척도와 형식 간 변환.

주요 연산:

  • 다양한 형식(ISO, JD, MJD, Unix 등)으로 Time 객체 생성
  • 시간 척도 간 변환(UTC, TAI, TT, TDB 등)
  • TimeDelta를 사용한 시간 산술 연산
  • 관측자를 위한 항성시 계산
  • 광행시간 보정(질량중심, 태양중심) 계산
  • 시간 배열 효율적으로 작업
  • 마스킹된(결측) 시간 처리

참고: 시간 형식, 시간 척도, 변환, 산술 연산, 관측 기능 및 정밀도 처리는 references/time.md를 참조하세요.

7. 세계 좌표계 (astropy.wcs)

이미지의 픽셀 좌표와 세계 좌표 간 변환.

주요 연산:

  • FITS 헤더에서 WCS 읽기
  • 픽셀 좌표를 세계 좌표로 변환(그 반대도 가능)
  • 이미지 풋프린트 계산
  • WCS 매개변수(참조 픽셀, 투영, 축척) 접근
  • 사용자 정의 WCS 객체 생성

참고: WCS 연산 및 변환은 references/wcs_and_other_modules.md를 참조하세요.

추가 기능

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"고도={c_altaz.alt.deg}, 방위각={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.

AbobakrDiara61/railway-system

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

AbobakrDiara61/railway-system

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

AbobakrDiara61/railway-system

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

AbobakrDiara61/railway-system

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.

AbobakrDiara61/railway-system

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

AbobakrDiara61/railway-system

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.

AbobakrDiara61/railway-system

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.

AbobakrDiara61/railway-system

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

AbobakrDiara61/railway-system

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 悬停效果

AbobakrDiara61/railway-system

Best practices for Remotion - Video creation in React

AbobakrDiara61/railway-system

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

AbobakrDiara61/railway-system

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

AbobakrDiara61/railway-system

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.

AbobakrDiara61/railway-system

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

AbobakrDiara61/railway-system

Automate TikTok tasks via Rube MCP (Composio): upload/publish videos, post photos, manage content, and view user profiles/stats. Always search tools first for current schemas.

AbobakrDiara61/railway-system

Video and audio perception, indexing, and editing. Ingest files/URLs/live streams, build visual/spoken indexes, search with timestamps, edit timelines, add overlays/subtitles, generate media, and create real-time alerts.

AbobakrDiara61/railway-system

Upload, stream, search, edit, transcribe, and generate AI video and audio using the VideoDB SDK.

AbobakrDiara61/railway-system

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

AbobakrDiara61/railway-system

Automate YouTube tasks via Rube MCP (Composio): upload videos, manage playlists, search content, get analytics, and handle comments. Always search tools first for current schemas.

AbobakrDiara61/railway-system

Extract transcripts from YouTube videos and generate comprehensive, detailed summaries using intelligent analysis frameworks

관련 스킬