dfcosmic documentation¶
Welcome to the documentation for dfcosmic – a PyTorch implementation of the LA Cosmic algorithm by van Dokkum 2001.
You can quickly run dfcosmic with the following:
from dfcosmic import lacosmic
clean, crmask = df_lacosmic(
image=imdata,
objlim=2,
sigfrac=1,
sigclip=6,
gain=1,
readnoise=10,
niter=1,
device="cuda",
)
Runtime Options¶
There are three runtime options. We list them below in order of speed from the slowest to the fastest implementation:
CPU pure PyTorch: this implementation uses only PyTorch for all functions and can be called by adding the argument use_cpp=False.
CPU Pytorch & C++: this implementation uses Pytorch combined with the median filter implemented in C++ for speed optimizations. This is the default behavior when device=’cpu’.
GPU: this implementation uses PyTorch only and runs on the GPU. This runs when device=’cuda’ is set.
Main Parameters¶
There are several key parameters that a user can set depending on their specific use case:
objlim: the contrast limit between cosmic rays and underlying objects
sigfrac: the fractional detection limit for neighboring pixels
sigclip: the detection limit for cosmic rays
Furthermore, the user can supply the gain and readnoise. If a gain is not supplied, then it will be estimated at each iteration.
Additional parameters can be found in the API call to lacosmic.
Timing Analysis¶
Timing analysis of dfcosmic versus lacosmic and astroscrappy. Note that dfcosmic exclusively uses a true median (i.e. sepmed=False).