Skip to content

Commit

Permalink
Merge pull request #677 from crawfordsm/subtract_dark
Browse files Browse the repository at this point in the history
add error in subtract_dark for array differences
  • Loading branch information
mwcraig committed Jul 26, 2019
2 parents 5de14c7 + 7f9417a commit 4a3dd68
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGES.rst
Expand Up @@ -26,6 +26,9 @@ Bug Fixes

- Function ``combine`` avoids keeping files open unnecessarily. [#629, #630]

- Raise ``ValueError`` error in ``subtract_dark`` for when the errors have
different shapes [#674, #677]

1.3.0 (2017-11-1)
-----------------

Expand Down
4 changes: 4 additions & 0 deletions ccdproc/core.py
Expand Up @@ -617,6 +617,10 @@ def subtract_dark(ccd, master, dark_exposure=None, data_exposure=None,
result : `~astropy.nddata.CCDData`
Dark-subtracted image.
"""
if ccd.shape != master.shape:
err_str = "operands could not be subtracted with shapes {} {}".format(ccd.shape, master.shape)
raise ValueError(err_str)

if not (isinstance(ccd, CCDData) and isinstance(master, CCDData)):
raise TypeError("ccd and master must both be CCDData objects.")

Expand Down
6 changes: 6 additions & 0 deletions ccdproc/tests/test_ccdproc.py
Expand Up @@ -401,6 +401,12 @@ def test_subtract_dark_fails(ccd_data):
exposure_unit=u.second)
assert "uncalibrated image" in str(e.value)

# fail when the arrays are not the same size
with pytest.raises(ValueError):
small_master = CCDData(ccd_data)
small_master.data = np.zeros((1, 1))
subtract_dark(ccd_data, small_master)


def test_unit_mismatch_behaves_as_expected(ccd_data):
"""
Expand Down

0 comments on commit 4a3dd68

Please sign in to comment.