avg_fits#

pyscope.reduction.avg_fits(fnames, pre_normalize=False, mode='0', datatype=<class 'numpy.float32'>, outfile=None, verbose=0)[source]#

Averages a list of FITS images into a single output image.

Averages multiple FITS images into a single output image, with options for pre-normalization, averaging mode, and output data type.

Parameters:
fnameslist of str

Paths to FITS files to average.

pre_normalizebool, default=`False`

Normalize each image by its own mean before combining.

modestr, default=`”0”`

Averaging mode: "0" for median, "1" for mean.

datatypestr, default=`”float32”`

Data type for the averaged image. Defaults to "float32" unless pre-normalizing, where "float64" is used.

outfilestr, optional

Output path for the averaged image. Defaults to using the first input file name with "_avg.fts" appended.

verboseint, default=`0`

Logging verbosity level. Use -v for INFO and -vv for DEBUG.

Returns:
None

The averaged FITS image is saved to the specified output file or the default location.

Raises:
KeyError

If required FITS header keywords (e.g., FRAMETYP, EXPTIME) are missing.

ValueError

If the input images have incompatible dimensions or data types.