downsample_header#

mufasa.utils.fits_utils.downsample_header(header, factor, axis)[source]#

Downsample a FITS header along a specified axis.

This function downsamples the provided FITS header along the specified axis using the FITS convention for axis numbering. The CDELT and CRPIX keywords are adjusted accordingly to reflect the downsampling.

Parameters:
  • header (astropy.io.fits.Header) – The FITS header to be downsampled. This is typically obtained from a FITS file.

  • factor (float) – The downsampling factor. Must be greater than 0.

  • axis (int) – The axis along which to apply the downsampling. Follows the FITS convention for axis numbering (1-based indexing).

Returns:

A copy of the FITS header with adjusted CDELT and CRPIX values to account for the downsampling.

Return type:

astropy.io.fits.Header

Notes

  • The function modifies a copy of the input header, leaving the original header unchanged.

  • The code here is borrowed from FITS_tools.downsample.

Examples

>>> from astropy.io import fits
>>> header = fits.Header()
>>> header['CDELT1'] = 0.1
>>> header['CRPIX1'] = 50
>>> downsampled_header = downsample_header(header, factor=2, axis=1)
>>> print(downsampled_header['CDELT1'], downsampled_header['CRPIX1'])
0.2 25.5