combine#

ccdproc.combine(img_list, output_file=None, method='average', weights=None, scale=None, mem_limit=16000000000.0, clip_extrema=False, nlow=1, nhigh=1, minmax_clip=False, minmax_clip_min=None, minmax_clip_max=None, sigma_clip=False, sigma_clip_low_thresh=3, sigma_clip_high_thresh=3, sigma_clip_func=None, sigma_clip_dev_func=None, dtype=None, combine_uncertainty_function=None, overwrite_output=False, array_package=None, **ccdkwargs)[source]#

Convenience function for combining multiple images.

Parameters:
img_listnumpy.ndarray, list or str

A list of fits filenames or CCDData objects, or a mix of the two, that will be combined together. Or a string of fits filenames separated by comma “,”.

output_filestr or None, optional

Optional output fits file-name to which the final output can be directly written. Default is None.

methodstr, optional

Method to combine images:

  • 'average' : To combine by calculating the average.

  • 'median' : To combine by calculating the median.

  • 'sum' : To combine by calculating the sum.

Default is 'average'.

weightsnumpy.ndarray or None, optional

Weights to be used when combining images. An array with the weight values. The dimensions should match the the dimensions of the data arrays being combined. Default is None.

scalefunction or numpy.ndarray-like or None, optional

Scaling factor to be used when combining images. Images are multiplied by scaling prior to combining them. Scaling may be either a function, which will be applied to each image to determine the scaling factor, or a list or array whose length is the number of images in the Combiner. Default is None.

mem_limitfloat, optional

Maximum memory which should be used while combining (in bytes). Default is 16e9.

clip_extremabool, optional

Set to True if you want to mask pixels using an IRAF-like minmax clipping algorithm. The algorithm will mask the lowest nlow values and the highest nhigh values before combining the values to make up a single pixel in the resulting image. For example, the image will be a combination of Nimages-low-nhigh pixel values instead of the combination of Nimages.

Parameters below are valid only when clip_extrema is set to True, see Combiner.clip_extrema() for the parameter description:

  • nlow : int or None, optional

  • nhigh : int or None, optional

minmax_clipbool, optional

Set to True if you want to mask all pixels that are below minmax_clip_min or above minmax_clip_max before combining. Default is False.

Parameters below are valid only when minmax_clip is set to True, see Combiner.minmax_clipping() for the parameter description:

  • minmax_clip_min : float or None, optional

  • minmax_clip_max : float or None, optional

sigma_clipbool, optional

Set to True if you want to reject pixels which have deviations greater than those set by the threshold values. The algorithm will first calculated a baseline value using the function specified in func and deviation based on sigma_clip_dev_func and the input data array. Any pixel with a deviation from the baseline value greater than that set by sigma_clip_high_thresh or lower than that set by sigma_clip_low_thresh will be rejected. Default is False.

Parameters below are valid only when sigma_clip is set to True. See Combiner.sigma_clipping() for the parameter description.

  • sigma_clip_low_thresh : positive float or None, optional

  • sigma_clip_high_thresh : positive float or None, optional

  • sigma_clip_func : function, optional

  • sigma_clip_dev_func : function, optional

dtypedtype-like or None, optional

The intermediate and resulting dtype for the combined CCDs; see ccdproc.Combiner for the accepted forms. If None this is set to the namespace’s float64. Default is None.

combine_uncertainty_functioncallable, None, optional

If None use the default uncertainty func when using average, median or sum combine, otherwise use the function provided. Default is None.

overwrite_outputbool, optional

If output_file is specified, this is passed to the astropy.nddata.fits_ccddata_writer under the keyword overwrite; has no effect otherwise. Default is False.

array_packagearray namespace or module, optional

The array package to read files into. Either an array namespace or a plain module that follows the array API standard (e.g. numpy or dask.array); it is normalised to its array-api-compat namespace. Default is the array package of the CCDData objects in img_list, or NumPy if there are none; see Notes.

ccdkwargsOther keyword arguments for astropy.nddata.fits_ccddata_reader.
Returns:
combined_imageCCDData

CCDData object based on the combined input of CCDData objects.

Raises:
TypeError

If the data of the CCDData objects in img_list come from different array libraries, or from a different one than array_package.

ValueError

If the data of the CCDData objects in img_list are on different devices.

Notes

Files in img_list are read into the array package, and onto the device, of the CCDData objects in it, so a list that mixes file names and images in memory combines in the array package of the images in memory. An array_package that disagrees with an image in memory raises rather than converting the image, since the conversion could be a silent copy through host memory.