Extract and simple classify cosmic-ray hits from FITS files with dark frames. Supports removing hot pixels based on next frame when is necessary.
The algorithm:
- (optional) remove hot pixels based on next frame by
ccdproc
library. - Finding hits by
source_properties
function fromphotutils
library. - Classify hits to
dots
,comets
andworms
usingellipticity
parameter fromsource_properties
function:- when
ellipticity <= 0.2
then classified asdot
, - when
ellipticity >= 0.6
then classified ascomet
, - otherwise
ellipticity <= 0.2
was classified asworm
.
- when
- Detect group of hits. Hits are in groups where distance of pair of hits is less than 30px.
- Counting all groups by number of groups formed in a graph of friends algorithm.
- Print stats for each FITS file contains count of hits and area of hits by each class and count of groups.
virtualenv -p python3 env
source env/bin/activate
pip install -r requirements.txt
- Unpack FITS with dark frames with hot pixels or dark frames with hot pixels
removed to
image_dir
directory. - In file
filter_ccd.py
change:image_dir
- path to directory where you unpack FITS files,output_dir
- path where product of algorithm will be stored,files
- array of array of file name with frames with hot pixels, one array is the series of on observation, hot pixels will be removed based on next file, finding of hits is doing on 1 to N-1 files from the array,darks
- array of files with hit pixels removed.
- Run:
python filter_ccd.py
The filter_ccd.py
print gnuplot's friendly dat
file format output to stdout
.
Columns:
- FITS file name
- count of hits classified as dot
- area of hits classified as dot
- count of hits classified as comet
- area of hits classified as comet
- count of hits classified as worm
- area of hits classified as worm
- count of all hits
- area of all hits
- count of hits in groups
- area of hits in groups
- count of all groups
- exposure time from FITS metadata
- date of start of exposure from FITS metadata
- and other metadata from FITS configured in
metadata
const infilter_ccd.py
In output_dir
you get:
cleared-{file_from_files}.fits
- FITS file with removed hot pixelscleared-{file_from_files_or_darks}.png
- PNG export with pixels bright mapped from[A,B]
to[0,255]
by linear function andA
is percentile 25%,B
is percentile 99.999%,detections/{file_from_files_or_darks}/
- result of detection:./{a}-{b}-{c}-{d}-{e}-{f}.fits
- cut hit, wherea
- area of hit in pixels,b
- XY of hit,c
- class of hit,d
- ellipticity,e
- elongation,f
- eccentricity,./{a}-{b}-{c}-{d}-{e}-{f}.png
- PNG export of above fromcleared-{file_from_files_or_darks}.png
,
detections/{file_from_files_or_darks}/classes/{a}-{b}-{c}-{d}-{e}-{f}.png
- marked area by find_hits function.
Download full source input from here, compressed by zip.
Download full output from here, compresesed by xz and tar.
SC79423 after hot pixel removal:
SC79424 after hot pixel removal:
SC79425 after hot pixel removal:
Michał Niedźwiecki, MSc.
Cracow University of Technology, Poland, 2018-10-05