despike#
- named_arrays.despike(array, axis, where=None, inbkg=None, invar=None, sigclip=4.5, sigfrac=0.3, objlim=5.0, gain=1.0, readnoise=6.5, satlevel=65536.0, niter=4, sepmed=True, cleantype='meanmask', fsmode='median', psfmodel='gauss', psffwhm=2.5, psfsize=7, psfk=None, psfbeta=4.765, verbose=False)#
A thin wrapper around
astroscrappy.detect_cosmics()[van Dokkum, 2001], which removes cosmic ray spikes from a series of images.- Parameters:
array (ArrayT) – Input data array that will be used for cosmic ray detection. This should include the sky background (or a mean background level, added back in after sky subtraction), so that noise can be estimated correctly from the data values. This should be in units of “counts”.
axis (tuple[str, str]) – The two axes defining the logical axes of each image.
where (None | bool | AbstractArray) – A boolean array of which pixels to consider during the cleaning process. The inverse of inmask used in
astroscrappy.detect_cosmics().inbkg (None | AbstractArray) – A pre-determined background image, to be subtracted from array before running the main detection algorithm. This is used primarily with spectroscopic data, to remove sky lines and the cross-section of an object continuum during iteration, “protecting” them from spurious rejection (see the above paper). This background is not removed from the final, cleaned output (cleanarr). This should be in units of “counts”, the same units of array. This inbkg should be free from cosmic rays. When estimating the cosmic-ray free noise of the image, we will treat
inbkgas a constant Poisson contribution to the variance.invar (None | float | ArrayT) – A pre-determined estimate of the data variance (ie. noise squared) in each pixel, generated by previous processing of array. If provided, this is used in place of an internal noise model based on array,
gainandreadnoise. This still gets median filtered and cleaned internally, to estimate what the noise in each pixel would be in the absence of cosmic rays. This should be in units of “counts” squared.sigclip (float) – Laplacian-to-noise limit for cosmic ray detection. Lower values will flag more pixels as cosmic rays. Default: 4.5.
sigfrac (float) – Fractional detection limit for neighboring pixels. For cosmic ray neighbor pixels, a lapacian-to-noise detection limit of sigfrac * sigclip will be used. Default: 0.3.
objlim (float) – Minimum contrast between Laplacian image and the fine structure image. Increase this value if cores of bright stars are flagged as cosmic rays. Default: 5.0.
gain (float) – Gain of the image (electrons / ADU). We always need to work in electrons for cosmic ray detection. Default: 1.0
readnoise (float) – Read noise of the image (electrons). Used to generate the noise model of the image. Default: 6.5.
satlevel (float) – Saturation of level of the image (electrons). This value is used to detect saturated stars and pixels at or above this level are added to the mask. Default: 65536.0.
niter (int) – Number of iterations of the LA Cosmic algorithm to perform. Default: 4.
sepmed (bool) – Use the separable median filter instead of the full median filter. The separable median is not identical to the full median filter, but they are approximately the same and the separable median filter is significantly faster and still detects cosmic rays well. Default: True
cleantype (Literal['median', 'medmask', 'meanmask', 'idw']) –
Set which clean algorithm is used:
’median’: An umasked 5x5 median filter
’medmask’: A masked 5x5 median filter
’meanmask’: A masked 5x5 mean filter
’idw’: A masked 5x5 inverse distance weighted interpolation
Default: “meanmask”.
fsmode (Literal['median', 'convolve']) –
Method to build the fine structure image:
’median’: Use the median filter in the standard LA Cosmic algorithm ‘convolve’: Convolve the image with the psf kernel to calculate the fine structure image using a matched filter technique. Default: ‘median’.
psfmodel (Literal['gauss', 'gaussx', 'gaussy', 'moffat']) – Model to use to generate the psf kernel if fsmode == ‘convolve’ and psfk is None. The current choices are Gaussian and Moffat profiles. ‘gauss’ and ‘moffat’ produce circular PSF kernels. The ‘gaussx’ and ‘gaussy’ produce Gaussian kernels in the x and y directions respectively. Default: “gauss”.
psffwhm (float) – Full Width Half Maximum of the PSF to use to generate the kernel. Default: 2.5.
psfsize (int) – Size of the kernel to calculate. Returned kernel will have size psfsize x psfsize. psfsize should be odd. Default: 7.
psfk (None | AbstractArray) – PSF kernel array to use for the fine structure image if fsmode == ‘convolve’. If None and fsmode == ‘convolve’, we calculate the psf kernel using ‘psfmodel’. Default: None.
psfbeta (float) – Moffat beta parameter. Only used if fsmode==’convolve’ and psfmodel==’moffat’. Default: 4.765.
verbose (bool) – Print to the screen or not. Default: False.
- Return type:
ArrayT