Skip to main content

Speedy Cosmic Ray Annihilation Package in Python

Project description

Documentation Status CI Status AstroScrappy's Coverage Status

An optimized cosmic ray detector.

Author:Curtis McCully

Astro-SCRAPPY is designed to detect cosmic rays in images (numpy arrays), based on Pieter van Dokkum’s L.A.Cosmic algorithm.

Much of this was originally adapted from written by Malte Tewes. I have ported all of the slow functions to Cython/C, and optimized where I can. This is designed to be as fast as possible so some of the readability has been sacrificed, specifically in the C code.

If you use this code, please cite the Zendo DOI:

Please cite the original paper which can be found at:

van Dokkum 2001, PASP, 113, 789, 1420 (article :

This code requires Cython, preferably version >= 0.21.

Parallelization is achieved using OpenMP. This code should compile (although the Cython files may have issues) using a compiler that does not support OMP, e.g. clang.


There are some differences from original LA Cosmic:

  • Automatic recognition of saturated stars. This avoids treating such stars as large cosmic rays.
  • I have tried to optimize all of the code as much as possible while maintaining the integrity of the algorithm. One of the key speedups is to use a separable median filter instead of the true median filter. While these are not identical, they produce comparable results and the separable version is much faster.
  • This implementation is much faster than the Python by as much as a factor of ~17 depending on the given parameters, even without running multiple threads. With multiple threads, this can be increased easily by another factor of 2. This implementation is much faster than the original IRAF version, improvment by a factor of ~90.

The arrays always must be C-contiguous, thus all loops are y outer, x inner. This follows the (pyfits) convention.

scipy is required for certain tests to pass, but the code itself does not depend on scipy.


This project is Copyright (c) Astropy Developers and licensed under the terms of the BSD 3-Clause license. See the licenses folder for more information.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

astroscrappy-1.1.0.tar.gz (368.5 kB view hashes)

Uploaded source

Built Distributions

astroscrappy-1.1.0-cp39-cp39-win_amd64.whl (529.5 kB view hashes)

Uploaded cp39

astroscrappy-1.1.0-cp39-cp39-win32.whl (498.6 kB view hashes)

Uploaded cp39

astroscrappy-1.1.0-cp38-cp38-win_amd64.whl (531.7 kB view hashes)

Uploaded cp38

astroscrappy-1.1.0-cp38-cp38-win32.whl (501.0 kB view hashes)

Uploaded cp38

astroscrappy-1.1.0-cp37-cp37m-win_amd64.whl (527.6 kB view hashes)

Uploaded cp37

astroscrappy-1.1.0-cp37-cp37m-win32.whl (495.7 kB view hashes)

Uploaded cp37

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page