astropy/ccdproc

ccdproc.subtract_dark incorrectly raises TypeError on CCDData objects

Opened this issue · 6 comments

I am trying to automate my image reduction. I use the individual ccdproc functions (subtract_bias, subtract_dark, etc) since I need to do an image linearization between the bias and dark subtractions. I always get a TypeError from ccdproc.subtract_dark() saying that both image and dark need to be type CCDData. However, as you can see in the code below I've implemented the exact test from subtract_dark before calling and it never triggers. Bias subtraction works fine. If I comment out the isinstance test in ccdproc.subtract_dark everything works fine.
I can provide the images (~11MB total) and/or FITS headers if that would help.

Linux Fedora 27
Python 3.6.8 | Anaconda
astropy 3.1.2
ccdproc 1.3.0.post1
numpy 1.16.3

from astropy.nddata import CCDData
from astropy import units as u
# from astropy.time import Time, TimeDelta
# from astropy.utils import iers
# from astropy import coordinates as coord
import ccdproc

img = CCDData.read('UV_Hya-001B400s.fit', unit='adu')
dark = CCDData.read('Master_Dark_1_1600x1200_Bin1x1_Temp-15C_ExpTime400s.fit', unit='adu')
if not (isinstance(img, CCDData) and isinstance(dark, CCDData)):
    raise TypeError("This error never triggers")
img_dark = ccdproc.subtract_dark(img,dark,exposure_time='EXPOSURE',exposure_unit=u.s, scale=True)

Trace:

File "./darktester.py", line 19, in <module>
    img_dark = ccdproc.subtract_dark(img,dark,exposure_time='EXPOSURE',exposure_unit=u.s, scale=True)
  File "/usr/lib/python3.6/site-packages/ccdproc/log_meta.py", line 70, in wrapper
    result = func(*args, **kwd)
  File "/usr/lib/python3.6/site-packages/ccdproc/core.py", line 616, in subtract_dark
    raise TypeError("ccd and master must both be CCDData objects.")
TypeError: ccd and master must both be CCDData objects.

Hi @RLWagner and thank you for the report.

I will have a look at this later. But could you check what CCDData is ccdproc.core.CCDData returns?

I couldn't reproduce this with the provided versions. It would be very helpful if you could provide the output of CCDData is ccdproc.core.CCDData. I assume that somehow your installed ccdproc has a different CCDData class.

@MSeifert04 -- do you have time to follow up on this or should I take a look later today?

@mwcraig It would be great if you could follow up on this. I'm a bit at a loss what might cause the issue.

@RLWagner -- sorry for the delay. I'm not able to reproduce the bug, but I'm not on Ubuntu (not that it should make any difference).

Could you please send (or post here) the output of conda env export so I can try to reproduce your environment?