astropy

Implements astronomical data analysis with Astropy units, coordinates, FITS I/O, tables, time, and cosmology.

Updated Sep 2, 2026
One-click install
npx skills add https://github.com/ricfulop/cba-agentic-engineering-bootstrap --skill astropy-ricfulop
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: astropy
Source: https://github.com/ricfulop/cba-agentic-engineering-bootstrap/tree/main/skills/astropy
Command: npx skills add https://github.com/ricfulop/cba-agentic-engineering-bootstrap --skill astropy-ricfulop

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires astropy, numpy, and includes references (resource) components.

What problem does it solve? Astronomical data analysis requires precise handling of physical units, celestial coordinate transformations, FITS file formats, time scales, and cosmological models, and writing this code from scratch is error-prone and slow. ## Core Features & Use Cases - Units and Coordinates: Convert physical quantities with dimensional consistency and transform positions between ICRS, Galactic, FK5, and AltAz frames, including catalog cross-matching. - FITS and Table I/O: Read, write, and manipulate FITS images and tables, plus unit-aware QTable operations like joins, grouping, and masking. - Time, WCS, and Cosmology: Handle precise time scales (UTC, TAI, TT, TDB), pixel-to-world WCS transformations, and distance/age calculations with Planck18 or custom cosmologies. - Use Case: Cross-match two source catalogs within 1 arcsecond, compute luminosity distances at z=1.5 with Planck18, and write the matched results to a new FITS file. ## Quick Start Use the astropy skill to convert these RA/Dec coordinates to Galactic frame and compute their luminosity distances at redshift 1.5.

Frequently Asked Questions about astropy

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

FAQPage Schema
How do I convert between celestial coordinate systems in Python?

Use astropy.coordinates.SkyCoord to create coordinates in one frame, then transform with attributes like .galactic or .transform_to(). For observer-dependent AltAz frames, also supply an EarthLocation and observation Time.

How do I read and write FITS files with Astropy?

Open files with astropy.io.fits.open() inside a context manager, access HDUs by index or name, and read data as NumPy arrays. Write new files with hdu.writeto() or the fits.writeto() convenience function.

How do I cross-match two astronomical catalogs?

Build SkyCoord objects from each catalog's RA and Dec columns, then call match_to_catalog_sky() to get indices and angular separations. Filter matches by a separation threshold such as 1 arcsecond.

Does Astropy support cosmological distance calculations?

Yes, astropy.cosmology provides built-in models like Planck18 and WMAP9 plus custom FlatLambdaCDM definitions. Methods include luminosity_distance, angular_diameter_distance, age, lookback_time, and z_at_value for inverse lookups.

What Python version does Astropy 7.2 require?

Astropy 7.2.0 requires Python 3.11 or newer and depends on NumPy, PyERFA, PyYAML, and packaging. Install it in an isolated virtual environment with a pinned version for reproducibility.

Why do Astropy time conversions sometimes need network access?

High-precision UT1 and polar-motion values use IERS Earth-rotation data, which Astropy may auto-download. Set iers.conf.auto_download = False for offline or privacy-sensitive runs, and avoid SkyCoord.from_name() with confidential target names.