API/Reference


LACosmic.lacosmicMethod
lacosmic(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

  • noise is the pre-determined estimate of the data noise (square root of variance), if any
  • gain is the image gain in electrons per data number
  • background is pre-determined image background, if any
  • readnoise is the read noise of the image in electrons
  • mask is an input bad pixel mask, where true represents a bad pixel
  • sigma_clip is the Laplacian signal-to-noise ratio for flagging bad pixels
  • contrast is the minimum contrast required to flag a bad pixel in the ratio of the Laplacian image to the fine-structure image
  • neighbor_thresh is the fractional detection limit for cosmic rays surrounding other cosmic rays. Should be a number between 0 and 1.
  • maxiter is the maximum number of iterations used for detecting bad pixels
  • saturation_level is the saturation value in electrons
  • block_size is 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"

source
LACosmic.subsampleFunction
LACosmic.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
source