astropy

Perform astronomical data analysis with Astropy APIs for units, coordinates, FITS, and cosmology.

13|3|Updated Jun 10, 2026
One-click install
npx skills add https://github.com/tassiovale/claude-code-kit --skill astropy-tassiovale
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: astropy
Source: https://github.com/tassiovale/claude-code-kit/tree/main/skills/astropy
Command: npx skills add https://github.com/tassiovale/claude-code-kit --skill astropy-tassiovale

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires astropy, numpy, scipy, matplotlib, and includes scripts (resource) and references (resource) and assets (resource) components.

What problem does it solve?

This Skill simplifies astronomical data analysis by providing access to Astropy APIs, enabling unit conversions, coordinate transformations, FITS file operations, and more, all within your code.

Core Features & Use Cases

  • Unit Conversions and Quantities: Handle physical quantities with units and perform unit conversions.
  • Coordinate Systems: Convert between celestial coordinate systems and calculate positions and separations.
  • Cosmological Calculations: Perform distance and time calculations using standard cosmological models.
  • FITS File Handling: Read, write, and manipulate FITS files for image and table data.
  • Table Operations: Work with tabular data, including reading, writing, and performing database-style operations.
  • Time Handling: Manipulate times and dates with support for various time scales and formats.
  • WCS Transformations: Convert between pixel coordinates in images and world coordinates.
  • Use Case: Suppose you need to analyze data from a FITS file obtained by an observatory. Use this Skill to read the file, convert celestial coordinates, perform cosmological calculations, and plot the results.

Quick Start

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

data = fits.getdata('image.fits')
header = fits.getheader('image.fits')

table = Table.read('catalog.fits')

d_L = Planck18.luminosity_distance(z=1.0)

Frequently Asked Questions about astropy

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I convert celestial coordinates between different systems for astronomical data analysis?

Celestial coordinate transformations use SkyCoord APIs to convert between ICRS, galactic, and other frames. You define coordinates with units like degrees, then access frame attributes such as `.galactic` to perform astronomical coordinate system transformations.

Can I read and manipulate FITS files for observatory image data within my code?

Yes, FITS file handling APIs read and write image and table data from observatory datasets. You can extract image arrays and header metadata using `fits.getdata` and `fits.getheader` to manipulate FITS files directly in Python.

Do I need numpy and scipy installed to perform cosmological distance calculations?

Cosmological calculations require the astropy dependency, while numpy, scipy, and matplotlib are optional. You can compute luminosity distances using standard cosmological models like Planck18 without strictly requiring scipy.

What is the best way to handle physical quantities with units in astrophysics research?

Handling physical quantities with units uses astropy units APIs to attach measurements like parsecs to values. You perform unit conversions by calling the `.to()` method, ensuring accurate physical quantity tracking in astrophysics research.

How do I convert pixel coordinates in astronomical images to world coordinates using WCS?

WCS transformations convert pixel coordinates in astronomical images to world coordinates. You utilize WCS APIs to map image pixel arrays to celestial coordinate systems, enabling accurate spatial analysis of observatory data.

How does time handling work for manipulating dates across various astronomical time scales?

Time handling works by using Time APIs to manipulate dates and times across various astronomical time scales and formats. You instantiate Time with a datetime string and access properties like `.jd` to retrieve Julian Dates for temporal analysis.