Skip to content

Commit

Permalink
Merge 16eb6f4 into ea1765b
Browse files Browse the repository at this point in the history
  • Loading branch information
fdeugenio committed Jan 11, 2019
2 parents ea1765b + 16eb6f4 commit 7fe7441
Show file tree
Hide file tree
Showing 5 changed files with 1,221 additions and 16 deletions.
2 changes: 1 addition & 1 deletion astropy_helpers
Submodule astropy_helpers updated 75 files
+25 −66 .travis.yml
+1 −65 CHANGES.rst
+1 −0 MANIFEST.in
+32 −329 README.rst
+44 −19 ah_bootstrap.py
+5 −8 appveyor.yml
+4 −1 astropy_helpers/__init__.py
+10 −2 astropy_helpers/commands/_dummy.py
+307 −0 astropy_helpers/commands/_test_compat.py
+5 −8 astropy_helpers/commands/build_ext.py
+39 −0 astropy_helpers/commands/build_py.py
+123 −135 astropy_helpers/commands/build_sphinx.py
+14 −0 astropy_helpers/commands/install.py
+14 −0 astropy_helpers/commands/install_lib.py
+53 −0 astropy_helpers/commands/register.py
+4 −1 astropy_helpers/commands/test.py
+12 −0 astropy_helpers/compat/__init__.py
+3 −9 astropy_helpers/conftest.py
+11 −0 astropy_helpers/extern/__init__.py
+1 −0 astropy_helpers/extern/automodapi/__init__.py
+135 −0 astropy_helpers/extern/automodapi/autodoc_enhancements.py
+423 −0 astropy_helpers/extern/automodapi/automodapi.py
+664 −0 astropy_helpers/extern/automodapi/automodsumm.py
+92 −0 astropy_helpers/extern/automodapi/smart_resolver.py
+10 −0 astropy_helpers/extern/automodapi/templates/autosummary_core/base.rst
+65 −0 astropy_helpers/extern/automodapi/templates/autosummary_core/class.rst
+41 −0 astropy_helpers/extern/automodapi/templates/autosummary_core/module.rst
+214 −0 astropy_helpers/extern/automodapi/utils.py
+5 −0 astropy_helpers/extern/numpydoc/__init__.py
+603 −0 astropy_helpers/extern/numpydoc/docscrape.py
+309 −0 astropy_helpers/extern/numpydoc/docscrape_sphinx.py
+271 −0 astropy_helpers/extern/numpydoc/numpydoc.py
+16 −0 astropy_helpers/extern/numpydoc/templates/numpydoc_docstring.rst
+4 −0 astropy_helpers/extern/setup_package.py
+29 −225 astropy_helpers/openmp_helpers.py
+54 −3 astropy_helpers/setup_helpers.py
+8 −0 astropy_helpers/sphinx/__init__.py
+341 −2 astropy_helpers/sphinx/conf.py
+2 −0 astropy_helpers/sphinx/ext/__init__.py
+82 −0 astropy_helpers/sphinx/ext/changelog_links.py
+56 −0 astropy_helpers/sphinx/ext/doctest.py
+168 −0 astropy_helpers/sphinx/ext/edit_on_github.py
+0 −0 astropy_helpers/sphinx/ext/tests/__init__.py
+22 −0 astropy_helpers/sphinx/ext/tocdepthfix.py
+ astropy_helpers/sphinx/local/python2_local_links.inv
+25 −0 astropy_helpers/sphinx/local/python2_local_links.txt
+ astropy_helpers/sphinx/local/python3_local_links.inv
+38 −0 astropy_helpers/sphinx/local/python3_local_links.txt
+10 −0 astropy_helpers/sphinx/setup_package.py
+3 −0 astropy_helpers/sphinx/themes/bootstrap-astropy/globaltoc.html
+96 −0 astropy_helpers/sphinx/themes/bootstrap-astropy/layout.html
+3 −0 astropy_helpers/sphinx/themes/bootstrap-astropy/localtoc.html
+7 −0 astropy_helpers/sphinx/themes/bootstrap-astropy/searchbox.html
+75 −0 astropy_helpers/sphinx/themes/bootstrap-astropy/static/astropy_linkout.svg
+ astropy_helpers/sphinx/themes/bootstrap-astropy/static/astropy_linkout_20.png
+ astropy_helpers/sphinx/themes/bootstrap-astropy/static/astropy_logo.ico
+87 −0 astropy_helpers/sphinx/themes/bootstrap-astropy/static/astropy_logo.svg
+ astropy_helpers/sphinx/themes/bootstrap-astropy/static/astropy_logo_32.png
+601 −0 astropy_helpers/sphinx/themes/bootstrap-astropy/static/bootstrap-astropy.css
+63 −0 astropy_helpers/sphinx/themes/bootstrap-astropy/static/copybutton.js
+160 −0 astropy_helpers/sphinx/themes/bootstrap-astropy/static/sidebar.js
+10 −0 astropy_helpers/sphinx/themes/bootstrap-astropy/theme.conf
+13 −0 astropy_helpers/test_helpers.py
+8 −16 astropy_helpers/tests/__init__.py
+5 −8 astropy_helpers/tests/coveragerc
+6 −4 astropy_helpers/tests/test_ah_bootstrap.py
+10 −1 astropy_helpers/tests/test_git_helpers.py
+3 −39 astropy_helpers/tests/test_openmp_helpers.py
+26 −19 astropy_helpers/tests/test_setup_helpers.py
+126 −55 astropy_helpers/utils.py
+12 −13 astropy_helpers/version_helpers.py
+414 −0 ez_setup.py
+50 −0 licenses/LICENSE_COPYBUTTON.rst
+94 −0 licenses/LICENSE_NUMPYDOC.rst
+1 −2 setup.py
13 changes: 7 additions & 6 deletions photutils/aperture/core.py
Expand Up @@ -384,21 +384,22 @@ def do_photometry(self, data, error=None, mask=None, method='exact',

aperture_sums = []
aperture_sum_errs = []
output_shape = (1,) if data.ndim==2 else data.shape[0]
for mask in self.to_mask(method=method, subpixels=subpixels):
data_cutout = mask.cutout(data)

if data_cutout is None:
aperture_sums.append(np.nan)
aperture_sums.append(np.repeat(np.nan, output_shape))
else:
aperture_sums.append(np.sum(data_cutout * mask.data))
aperture_sums.append(np.sum(data_cutout * mask.data, axis=(-2,-1)))

if error is not None:
error_cutout = mask.cutout(error)

if error_cutout is None:
aperture_sum_errs.append(np.nan)
aperture_sum_errs.append(np.repeat(np.nan, output_shape))
else:
aperture_var = np.sum(error_cutout ** 2 * mask.data)
aperture_var = np.sum(error_cutout ** 2 * mask.data, axis=(-2,-1))
aperture_sum_errs.append(np.sqrt(aperture_var))

# handle Quantity objects and input units
Expand Down Expand Up @@ -714,8 +715,8 @@ def _prepare_photometry_input(data, error, mask, wcs, unit):
pass

data = np.asanyarray(data)
if data.ndim != 2:
raise ValueError('data must be a 2D array.')
if (data.ndim != 2) and (data.ndim !=3):
raise ValueError('data must be a 2D or 3D array.')

if unit is not None:
unit = u.Unit(unit, parse_strict='warn')
Expand Down
17 changes: 9 additions & 8 deletions photutils/aperture/mask.py
Expand Up @@ -176,8 +176,8 @@ def cutout(self, data, fill_value=0., copy=False):
"""

data = np.asanyarray(data)
if data.ndim != 2:
raise ValueError('data must be a 2D array.')
if (data.ndim != 2) and (data.ndim != 3):
raise ValueError('data must be a 2D or 3D array.')

partial_overlap = False
if self.bbox.ixmin < 0 or self.bbox.iymin < 0:
Expand All @@ -187,20 +187,21 @@ def cutout(self, data, fill_value=0., copy=False):
# try this for speed -- the result may still be a partial
# overlap, in which case the next block will be triggered
if copy:
cutout = np.copy(data[self.bbox.slices])
cutout = np.copy(data[(Ellipsis,)+self.bbox.slices])
else:
cutout = data[self.bbox.slices]
cutout = data[(Ellipsis,)+self.bbox.slices]

if partial_overlap or (cutout.shape != self.shape):
slices_large, slices_small = self._overlap_slices(data.shape)
if partial_overlap or (cutout.shape[-2:] != self.shape):
slices_large, slices_small = self._overlap_slices(data.shape[-2:])

if slices_small is None:
return None # no overlap

# cutout is a copy
cutout = np.zeros(self.shape, dtype=data.dtype)
output_shape = self.shape if data.ndim==2 else (data.shape[0],)+self.shape
cutout = np.zeros(output_shape, dtype=data.dtype)
cutout[:] = fill_value
cutout[slices_small] = data[slices_large]
cutout[(Ellipsis,)+slices_small] = data[(Ellipsis,)+slices_large]

if isinstance(data, u.Quantity):
cutout = u.Quantity(cutout, unit=data.unit)
Expand Down

0 comments on commit 7fe7441

Please sign in to comment.