Skip to main content

Build Status codecov Documentation Status DOI arXiv

deepCR: Deep Learning Based Cosmic Ray Removal for Astronomical Images

Identify and remove cosmic rays from astronomical images using trained convolutional neural networks. Currently supports Hubble Space Telescope ACS-WFC and WFC3-UVIS cameras.

This package is implements the method described in the paper:

deepCR: Cosmic Ray Rejection with Deep Learning
Keming Zhang & Joshua Bloom 2020
Published in the Astrophysical Journal
arXiv:1907.09500

Documentation and tutorials

Currently Available Models

ACS-WFC: Kwon, Zhang & Bloom 2021

WFC3-UVIS: Chen et al. 2024

Installation

pip install deepCR

Or you can install from source:

git clone https://github.com/profjsb/deepCR.git
cd deepCR/
pip install .

Quick Start

Quick download of a HST ACS/WFC and a WFC3/UVIS image

wget -O jdba2sooq_flc.fits https://mast.stsci.edu/api/v0.1/Download/file?uri=mast:HST/product/jdba2sooq_flc.fits
wget -O ietx1ab1q_flc.fits https://mast.stsci.edu/api/v0.1/Download/file?uri=mast:HST/product/ietx1ab1q_flc.fits
from deepCR import deepCR
from astropy.io import fits
image = fits.getdata("jdba2sooq_flc.fits")[:512,:512]

# Create an instance of deepCR for ACS-WFC
mdl = deepCR(mask="ACS-WFC")
# mdl = deepCR(mask="WFC3-UVIS") for WFC3-UVIS

# Apply the model
mask = mdl.clean(image, threshold = 0.5)
# 0.5 threshold usually works for ACS/WFC
# 0.1-0.2 for WFC3/UVIS (see Chen et al. 2024)

# Probabilistic mask could be helpful in determining threshold
prob_mask = mdl.clean(image, binary=False)

# Optional inpainting with median filtering
mask, cleaned_image = mdl.clean(image, threshold = 0.5, inpaint=True)

For larger images you may want to enable mdl.clean(..., segment=True, patch=512) option to prevent memory overflow. This option segment your input image into small squares of 512 by 512 for input into the model, where the CR masks are stitched back together. In this case, you may also enable multiprocessing by specifying n_jobs>1. Note that this won't speed things up if you're using GPU!

Contributing

We are very interested in getting bug fixes, new functionality, and new trained models from the community (especially for ground-based imaging and spectroscopy). Please fork this repo and issue a PR with your changes. It will be especially helpful if you add some tests for your changes.

Metadata

Release files for deepCR 0.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for deepCR 0.3.1
File Size Uploaded
deepCR-0.3.1.tar.gz 6.5 MB Details

Release files / deepCR-0.3.1.tar.gz

Download URL deepCR-0.3.1.tar.gz
Size 6.5 MB
Tags Source
SHA-256 checksum
How to use checksums
ae38876514e8a44e5e96ee7edf6609a4baf25bc5c442363628b162d46f982e94
BLAKE2b-256 checksum
How to use checksums
cf6d6e0cc05a40596101dc421b9d19172c0a482eb2eec01390af4e47a193898f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.11.4

Release history Release notifications | RSS feed

This release

0.3.1 This release

1 release file

0.1.5

1 release file

0.1.4

1 release file

0.1.3

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page