API/Reference
LACosmic.lacosmic — Methodlacosmic(data::AbstractMatrix;
noise=nothing,
gain=1,
background=0,
readnoise=0,
mask=falses(size(data)),
sigma_clip=4.5,
contrast=5,
neighbor_thresh=0.3,
maxiter=4,
saturation_level=2^16,
block_size=2)Laplacian cosmic ray detection (LACosmic). This algorithm implements the algorithm presented in lacosmicx. The return values are the cleaned image and the bad pixel mask. The image cleaning is done via median interpolation.
Parameters
noiseis the pre-determined estimate of the data noise (square root of variance), if anygainis the image gain in electrons per data numberbackgroundis pre-determined image background, if anyreadnoiseis the read noise of the image in electronsmaskis an input bad pixel mask, wheretruerepresents a bad pixelsigma_clipis the Laplacian signal-to-noise ratio for flagging bad pixelscontrastis the minimum contrast required to flag a bad pixel in the ratio of the Laplacian image to the fine-structure imageneighbor_threshis the fractional detection limit for cosmic rays surrounding other cosmic rays. Should be a number between 0 and 1.maxiteris the maximum number of iterations used for detecting bad pixelssaturation_levelis the saturation value in electronsblock_sizeis the subsampling factor for the Laplacian filter image.
Examples
julia> image = 100 .* randn(1001, 1001) .+ 1000;
julia> clean_image, mask = lacosmic(image, gain=4);References
van Dokkum, P.G. (2001) - "Cosmic-Ray Rejection by Laplacian Edge Detection"
LACosmic.subsample — FunctionLACosmic.subsample(array, block_size=2)Subsample array by the given factor without copying or allocating. This effectively treats each pixel as block_size x block_size pixels. The value of each pixel is not normalized or averaged. This is a view into the parent array, and if the data was changed this view would change subsequently.
Examples
julia> arr = [1 2; 3 4]
2×2 Matrix{Int64}:
1 2
3 4
julia> sub = LACosmic.subsample(arr)
4×4 LACosmic.SubsampledArray{Int64, 2, Matrix{Int64}}:
1 1 2 2
1 1 2 2
3 3 4 4
3 3 4 4
julia> all(sub[1:2, 1:2] .=== arr[1, 1])
true
julia> sub[3, 3] = 5;
julia> sub
4×4 LACosmic.SubsampledArray{Int64, 2, Matrix{Int64}}:
1 1 2 2
1 1 2 2
3 3 5 5
3 3 5 5