io.fits

pywi.io.fits.load_fits_image(input_file_path, hdu_index=0)[source]

Return the image array contained in the given HDU of the given FITS file.

Parameters:
  • input_file_path (str) – The path of the FITS file to load
  • hdu_index (int) – The HDU to load within the FITS file (one FITS file can contain several images stored in different HDU)
Returns:

The loaded image

Return type:

ndarray

Raises:
  • WrongHDUError – If input_file_path doesn’t contain the HDU hdu_index
  • NotAnImageError – If input_file_path doesn’t contain a valid image in the HDU hdu_index
pywi.io.fits.save_fits_image(image_array, output_file_path)[source]

Save the image_array image (array_like) to the output_file_path FITS file.

Parameters:
  • image_array (array_like) – The image to save (should be a 2D or a 3D numpy array)
  • output_file_path (str) – The path of the FITS file where to save the image_array
Raises:

WrongDimensionError – If image_array has more than 3 dimensions or less than 2 dimensions.