Skip to content

Fits reader

cutana.fits_reader

FITS file reader module for Cutana - handles FITS file loading and WCS extraction.

This module provides optimized FITS loading strategies: - For preview (< 200 sources): Memory-mapped lazy loading - For small batches (< 500 sources): Memory-mapped lazy loading - For large batches (>= 500 sources): fsspec-based partial loading - All using astropy for consistency

load_fits_file(fits_path, fits_extensions=None, n_sources=100, is_preview=False)

Load FITS file with optimized strategy based on source count and use case.

For NFS-based storage with ~1.4GB FITS files per extension: - Preview mode: Use memory mapping with lazy loading for fast response - Small batches (< 500 sources): Use memory mapping for efficiency - Large batches (>= 500 sources): Use fsspec for partial loading

Parameters:

Name Type Description Default
fits_path str

Path to the FITS file

required
fits_extensions Optional[List[str]]

List of extension names to process

None
n_sources int

Number of sources being processed (determines strategy)

100
is_preview bool

Whether this is for preview generation (affects strategy)

False

Returns:

Type Description
Tuple[HDUList, Dict[str, WCS]]

Tuple of (HDUList, WCS dictionary keyed by extension name)

Raises:

Type Description
FileNotFoundError

If FITS file doesn't exist

ValueError

If FITS file is corrupted or invalid