astropy / astropy/ccdproc

Cosmic Ray Correction Gives NaN Values on Flats

Open
#800 3 comments 0 reactions 0 assignees View on GitHub
astroscrappy
Dominant language
Python
Stars
93
Forks
92
Avg merge
14h 44m
Merged PRs (30d)
30

Description

Using these versions `ccdproc 2.4.0`, `astropy 5.1.1`, and `numpy 1.22.3`. I go through the whole process of overscan, trimming, bias, dark, and flat field correction. However, after the flats are combined to their respective filters and I run the following code:

```
good_flat = combined_flats[light.header['filter']]
reduced = ccdp.ccd_process(light, oscan=overscan_region, trim=trim_region, master_bias=zero,
master_flat=good_flat, dark_scale=True, gain=gain*u.electron/u.adu,
readnoise=rdnoise*u.electron, dark_frame=combined_dark, exposure_key='EXPTIME',
exposure_unit=u.second, gain_corrected=True, min_value=1.0)
```

It runs through the code no problem but the output for the science image is completely blank and the values that are given are NaN's across the whole image. However, when I don't do flat correction the science image is produced. I have also tried doing things more manually like as follows:

```
# Subtract the overscan, ccd[columns, rows] I think?
ccd = ccdp.subtract_overscan(ccd, fits_section=overscan_region, median=True, overscan_axis=1)

# Trim the overscan
ccd = ccdp.trim_image(ccd, fits_section=trim_region)

# cosmic ray reject above 5 sigmas and gain_apply is set to false because it changes the units of the image
new_ccd = ccdp.cosmicray_lacosmic(ccd, gain_apply=False, readnoise=rdnoise, gain=gain, sigclip=sigclip)

# Subtract bias
sub_ccd = ccdp.subtract_bias(new_ccd, zero)

# Subtract the dark current
reduced = ccdp.subtract_dark(sub_ccd, combined_dark, exposure_time='exptime', exposure_unit=u.second,
scale=True)

# flat field correct the science image based on filter
good_flat = combined_flats[reduced.header['filter']]
reduced = ccdp.flat_correct(ccd=reduced, flat=good_flat, min_value=1.0)
```

However, the same issue arises where the final science image is all NaN values and without flat correcting is a fine image without flat correction though. I have tested to make the sure the program is pulling the correct flat and only the master flats, and from the looks of things it is using the correct master flat image and only the master flat.

Contributor guide

Open the contributing guide

Research direction

The reported entry points are ccdp.ccd_process and ccdp.flat_correct, using the provided reduction sequence and package versions. Reproduce the all-NaN result, then compare the intermediate master flat and reduced image around flat correction, including min_value=1.0. Done means flat correction produces finite science-image values while the no-flat path remains valid.

Written by the indexing model from the issue text.

Assessment

Tech stack
numpy, python
Domain
data
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.