QuickstartΒΆ

Most code in this guide is included from a runnable script under examples/ at the repository root, so the page and the script cannot drift apart. A few short snippets are written inline.

The image used throughout the guide is a 1948 photographic-plate scan of NGC 2403. It holds 1448 by 2172 pixels and a TAN WCS with SIP distortion, and it is bundled at examples/data/ngc2403.fits.gz.

Run any example with:

python examples/python/quickstart.py     # Python
cargo run --example wcs                  # Rust
"""Quickstart: open a FITS file, read its pixels, and use its WCS.

Run from the repository root:

    python examples/python/quickstart.py
"""

import fitsy

with fitsy.open("examples/data/ngc2403.fits.gz") as f:
    hdu = f[0]
    print(hdu.bitpix, hdu.axes)  # 16  [1448, 2172]
    data = hdu.data  # numpy.ndarray, shape (2172, 1448)
    print("data shape:", data.shape, "dtype:", data.dtype)

    wcs = hdu.wcs()  # Wcs (TAN + SIP)
    if wcs is not None:
        ra, dec = wcs.pixel_to_world([724.0, 1086.0])
        print(f"center: RA={ra:.4f}  Dec={dec:.4f}")

Writing files and reading tables are covered in their own sections; see Writing FITS files and Reading images.