UseAllPixelsSubtraction

class psfsubtraction.fitpsf.UseAllPixelsSubtraction(psfbase, image=None)[source] [edit on github]

Bases: psfsubtraction.fitpsf.BasePSFFitter

Use all available pixels of the image.

For unmasked image pixel the maximal set of PSF templates that are unmasked at that position is used. Pixels are then group in regions that make use of the same PSF templates.

Methods Summary

findbase(region) Return all bases that are not masked in any pixel in region
fitpsfcoeff(image1d, psfbase) solve a linear algebra system for the best PSF
optregion(region, indpsf) Here we select the maximal region.
regions() Group pixels with the same valid bases into one region.

Methods Documentation

findbase(region) [edit on github]

Return all bases that are not masked in any pixel in region

fitpsfcoeff(image1d, psfbase) [edit on github]

solve a linear algebra system for the best PSF

Parameters:
image1d : array in 1 dim
psfbase : array in [M,N]

M = number of pixels in flattened image N = number of images that form the space of potential PSFs

Returns:
psf_coeff : array in 1 dim

Coefficients for a linear combination of psfbase elements that that give the optimal PSF.

Raises:
ValueError : If given masked data, because numpy.linalg.solve would silently

use the “values behind the mask”.

optregion(region, indpsf) [edit on github]

Here we select the maximal region.

The region is maximal in the sense that it includes all pixels that are not masked in the data or any of the bases.

Returns:
optregion : np.array of type bool

True for those pixels that should be included in the fit

regions() [edit on github]

Group pixels with the same valid bases into one region.

For each valid pixel in the image, this function checks which bases are valid at that pixel. It then groups pixels with the same valid bases into one region.

If self.min_number_of_bases is set to an integer, only regions with at least that many valid bases are returned (default is 1).

Theoretically, there could be 2^60 combinations of bases for 60 bases, but in practice the valid pixels in the bases are not randomly distributed, so that typically a much smaller number of regions is generated.

Returns:
regions : list of index arrays