MUSE Pipeline Reference Manual  2.1.1
Functions
Artifact handling

Functions

int muse_cosmics_dcr (muse_image *aImage, unsigned int aXBox, unsigned int aYBox, unsigned int aPasses, float aThres)
 Quickly mark cosmic rays in an image using the DCR algorithm. More...
 

Detailed Description

This group implements a few functions to be used to remove artifacts from MUSE data at the level of single CCDs.

Function Documentation

int muse_cosmics_dcr ( muse_image aImage,
unsigned int  aXBox,
unsigned int  aYBox,
unsigned int  aPasses,
float  aThres 
)

Quickly mark cosmic rays in an image using the DCR algorithm.

Parameters
aImageimage on which to replace cosmic rays
aXBoxsearch box size in x
aYBoxsearch box size in y
aPassesmaximum number of cleaning passes
aThresdetection gap threshold in factors of standard deviation
Returns
the integer number of cosmic rays found or a negative value on error
Remarks
The result is directly applied to the input image: the cosmic rays are marked in the dq extension of the input image. The data and stat components of the input image are not changed.
This routine should only be used for quick reduction or in the case that only a single exposure of one target is available.

This uses the DCR algorithm of Pych, 2004, PASP, 116, 148. From Sect. 2 ("The Algorithm") of the paper:

  1. Select small sized subframes that cover the whole frame, with substantial overlap. (This implementation overlaps 50% of each subframe with the next subframe, more around the top and right edges of the image. Pych recommends to have at least 100 pixels within each subframe for good statistics.)

In each subframe:

  1. Calculate the standard deviation of the distribution of counts: sigma = sqrt((sum(ci^2) - (sum(ci))^2 / n) / n)
  2. Apply a single sigma-clipping step to correct the estimate of standard deviation for outlying pixels.
  3. Construct a histogram of the distribution of counts.
  4. Find the mode of the distribution of counts (i.e., the peak of the histogram).
  5. In the interval of counts higher than the mode, find gaps in the histogram (i.e., bins with zero data points).
  6. Find the first gap that is wider than a threshold, which is the standard deviation multiplied by an arbitrary number (usually 3.0).
  7. If such a gap exists, flag pixels with counts lying above the gap as affected by cosmic rays.
Exceptions
set CPL_ERROR_NULL_INPUT, return -1input image is NULL
set CPL_ERROR_ILLEGAL_INPUT, return -2aThres is not positive
set CPL_ERROR_ILLEGAL_INPUT, return -3aPasses is not positive
set CPL_ERROR_ILLEGAL_INPUT, return -4aXBox is larger than the horizontal image size
set CPL_ERROR_ILLEGAL_INPUT, return -5aYBox is larger than the horizontal image size
print warningsize of a subframe is less than 100pix

Definition at line 275 of file muse_artifacts.c.

References muse_image::data.

Referenced by muse_basicproc_params_delete(), and muse_quadrants_overscan_stats().