dfcosmic.core¶
Functions¶
|
Remove cosmic rays from an image using the LA Cosmic algorithm by Pieter van Dokkum. |
Module Contents¶
- dfcosmic.core.lacosmic(image: torch.Tensor | numpy.ndarray, sigclip: float = 4.5, sigfrac: float = 0.5, objlim: float = 1.0, niter: int = 1, gain: float = 0.0, readnoise: float = 0.0, device: str = 'cpu', cpu_threads: int | None = None, use_cpp: bool = True, verbose: bool = False, rss_debug: bool = False) tuple[numpy.ndarray, numpy.ndarray]¶
Remove cosmic rays from an image using the LA Cosmic algorithm by Pieter van Dokkum.
The paper can be found at the following URL https://ui.adsabs.harvard.edu/abs/2001PASP..113.1420V/abstract
Parameters¶
- imagetorch.Tensor|np.ndarray
The input image.
- sigclipfloat
The detection limit for cosmic rays (sigma). Default is 4.5.
- sigfracfloat
The fractional detection limit for neighboring pixels. Default is 0.5.
- objlimfloat
The contrast limit between CR and underlying objects. Default is 1.0.
- niterint
The number of iterations to perform. Default is 1.0.
- gainfloat
The gain of the image in electrons/ADU. Default is 0.0.
- readnoisefloat
The read noise of the image in electrons. Default is 0.0.
- devicestr
The device to use for computation. Default is “cpu”.
- cpu_threadsint | None
Number of cpu threads to use. Default is None.
- use_cppbool
Boolean to use cpp optimized median filter and dilation algorithms. Default is True.
- verbosebool
Print iteration progress. Default is False.
- rss_debugbool
Print RSS memory at key steps. Default is False.
Returns¶
- np.ndarray
The image with cosmic rays removed.
- np.ndarray
The mask indicating the cosmic rays.
Notes¶
If the gain is set to zero (or not provided), then we compute it assuming sky-dominated noise and poisson statistics.
Performance Tips¶
For CPU performance: - Use gain parameter if known to avoid gain estimation overhead - Set niter=1 for faster processing (at cost of potentially detecting fewer cosmic rays) - set use_cpp=True to enable C++ implementations of the median filter and dilation functions
For best performance, use CUDA-enabled GPU by setting device=’cuda’.