Skip to content

Commit

Permalink
Merge pull request #244 from mwcraig/fix-overscan-240
Browse files Browse the repository at this point in the history
Fix overscan subtraction on non-square image
  • Loading branch information
mwcraig committed Oct 21, 2015
2 parents aee0777 + 22327b2 commit 3c619e9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
5 changes: 4 additions & 1 deletion ccdproc/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,10 @@ def subtract_overscan(ccd, overscan=None, overscan_axis=1, fits_section=None,
else:
oscan = np.reshape(oscan, (1, oscan.size))
else:
oscan = np.reshape(oscan, oscan.shape + (1,))
if overscan_axis == 1:
oscan = np.reshape(oscan, oscan.shape + (1,))
else:
oscan = np.reshape(oscan, (1,) + oscan.shape)

subtracted = ccd.copy()

Expand Down
9 changes: 7 additions & 2 deletions ccdproc/tests/test_ccdproc.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,16 @@ def test_create_deviation_keywords_must_have_unit(ccd_data):


# tests for overscan
@pytest.mark.parametrize('data_rectangle', [False, True])
@pytest.mark.parametrize('median,transpose', [
(False, False),
(False, True),
(True, False), ])
def test_subtract_overscan(ccd_data, median, transpose):
def test_subtract_overscan(ccd_data, median, transpose, data_rectangle):
# Make data non-square if desired
if data_rectangle:
ccd_data.data = ccd_data.data[:, :-30]

# create the overscan region
oscan = 300.
oscan_region = (slice(None), slice(0, 10)) # indices 0 through 9
Expand Down Expand Up @@ -540,7 +545,7 @@ def test__overscan_schange(ccd_data):
assert not np.allclose(old_data.data, new_data.data)
np.testing.assert_array_equal(old_data.data, ccd_data.data)


def test_create_deviation_does_not_change_input(ccd_data):
original = ccd_data.copy()
ccd = create_deviation(ccd_data, gain=5 * u.electron / u.adu, readnoise=10 * u.electron)
Expand Down

0 comments on commit 3c619e9

Please sign in to comment.