FITS - EranOfek/AstroPack GitHub Wiki

Reading data from a FITS file

Reading headers into an AstroHeader object

> AH = AstroHeader('myfile.fits');     % read the first header 
> AH = AstroHeader('myfile.fits', 2);  % read from the second header
> AH = AstroHeader('LAST*Ima*.fits');  % read from file name template

It is possible to read a header from a compressed FITS file (fits.gz) without decompression:

> AH = AstroHeader('myfile.fits.gz');     

It is also possible to read a header from a natively compressed FITS file (fits.fz) without decompression, however:

  • one needs to read the second header, even if the original data is single-layered
  • in the compressed header NAXIS1,2 are changed, while their original values are placed into ZNAXIS1,2
> AH =  AstroHeader('myfile.fits.fz', 2);  
> AH.replaceVal('NAXIS1',AH.getVal('ZNAXIS1'));  
> AH.replaceVal('NAXIS2',AH.getVal('ZNAXIS2'));

Currently, it is not possible to read neither FITS.bz2 nor FITS.xz