Skip to content

Commit

Permalink
Merge 93c87e3 into 5de14c7
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael committed Jul 26, 2019
2 parents 5de14c7 + 93c87e3 commit 6901518
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
1 change: 1 addition & 0 deletions AUTHORS.rst
Expand Up @@ -27,6 +27,7 @@ Alphabetical list of contributors
* Hans Moritz Günther (@hamogu)
* Forrest Gasdia (@EP-Guy)
* Nathan Heidt (@heidtha)
* Michael Hlabathe (@hlabathems)
* Elias Holte (@Sondanaa)
* Anthony Horton (@AnthonyHorton)
* Jennifer Karr (@JenniferKarr)
Expand Down
2 changes: 2 additions & 0 deletions CHANGES.rst
Expand Up @@ -19,6 +19,8 @@ Other Changes and Additions

- Added support for .bz2, .Z and .zip file formats in ``ImageFileCollection``.

- Modified weights function to also accept 1D array in ``Combiner``. [#634, #670]

Bug Fixes
^^^^^^^^^
- Function ``median_combine`` now correctly calculates the uncertainty for
Expand Down
13 changes: 7 additions & 6 deletions ccdproc/combiner.py
Expand Up @@ -124,14 +124,15 @@ def weights(self):
return self._weights

@weights.setter
def weights(self, value):
def weights(self, value, axis=0):
if value is not None:
if isinstance(value, np.ndarray):
if value.shape == self.data_arr.data.shape:
self._weights = value
else:
raise ValueError(
"dimensions of weights do not match data.")
if value.shape != self.data_arr.data.shape:
if value.ndim != 1:
raise ValueError("1D weights expected when shapes of the data and weights differ.")
if value.shape[0] != self.data_arr.data.shape[axis]:
raise ValueError("Length of weights not compatible with specified axis.")
self._weights = value
else:
raise TypeError("weights must be a numpy.ndarray.")
else:
Expand Down
11 changes: 11 additions & 0 deletions ccdproc/tests/test_combiner.py
Expand Up @@ -101,6 +101,17 @@ def test_weights_shape(ccd_data):
c.weights = ccd_data.data


def test_1Dweights():
ccd_list = [CCDData(np.zeros((10, 10)), unit=u.adu),
CCDData(np.zeros((10, 10)) - 1000, unit=u.adu),
CCDData(np.zeros((10, 10)) + 1000, unit=u.adu)]

c = Combiner(ccd_list)
c.weights = np.array([1, 5, 10])
ccd = c.average_combine()
np.testing.assert_almost_equal(ccd.data, 312.5)


# test the min-max rejection
def test_combiner_minmax():
ccd_list = [CCDData(np.zeros((10, 10)), unit=u.adu),
Expand Down

0 comments on commit 6901518

Please sign in to comment.