Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion astropy_helpers
Submodule astropy_helpers updated 94 files
+0 −39 .circleci/config.yml
+2 −3 .gitignore
+0 −10 .readthedocs.yml
+25 −68 .travis.yml
+1 −142 CHANGES.rst
+1 −0 MANIFEST.in
+42 −17 README.rst
+98 −108 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
+433 −165 astropy_helpers/commands/build_ext.py
+39 −0 astropy_helpers/commands/build_py.py
+124 −120 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
+5 −0 astropy_helpers/commands/setup_package.py
+28 −15 astropy_helpers/commands/src/compiler.c
+12 −17 astropy_helpers/commands/test.py
+12 −0 astropy_helpers/compat/__init__.py
+3 −9 astropy_helpers/conftest.py
+0 −6 astropy_helpers/distutils_helpers.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
+0 −2 astropy_helpers/git_helpers.py
+30 −231 astropy_helpers/openmp_helpers.py
+83 −97 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
+16 −57 astropy_helpers/tests/test_git_helpers.py
+3 −32 astropy_helpers/tests/test_openmp_helpers.py
+177 −39 astropy_helpers/tests/test_setup_helpers.py
+566 −16 astropy_helpers/utils.py
+37 −102 astropy_helpers/version_helpers.py
+0 −19 docs/Makefile
+0 −22 docs/advanced.rst
+0 −14 docs/api.rst
+0 −273 docs/basic.rst
+0 −52 docs/conf.py
+0 −29 docs/developers.rst
+0 −36 docs/index.rst
+0 −12 docs/known_issues.rst
+0 −35 docs/make.bat
+0 −28 docs/updating.rst
+0 −53 docs/using.rst
+414 −0 ez_setup.py
+50 −0 licenses/LICENSE_COPYBUTTON.rst
+94 −0 licenses/LICENSE_NUMPYDOC.rst
+0 −35 setup.cfg
+44 −12 setup.py
40 changes: 38 additions & 2 deletions photutils/aperture/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,42 @@ def to_mask(self, method='exact', subpixels=5):
def _do_photometry(self, data, variance, method='exact', subpixels=5,
unit=None):


"""
data = np.asanyarray(data)

if mask is not None:
mask = np.asanyarray(mask)

data = copy.deepcopy(data) # do not modify input data
data[mask] = 0

if error is not None:
# do not modify input data
error = copy.deepcopy(np.asanyarray(error))
error[mask] = 0.

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.repeat(np.nan, output_shape))
else:
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.repeat(np.nan, output_shape))
else:
aperture_var = np.sum(error_cutout ** 2 * mask.data, axis=(-2,-1))
aperture_sum_errs.append(np.sqrt(aperture_var))
"""

aperture_sums = []
aperture_sum_errs = []

Expand Down Expand Up @@ -773,8 +809,8 @@ def _validate_inputs(data, error):
"""

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 error is not None:
error = np.asanyarray(error)
Expand Down
17 changes: 9 additions & 8 deletions photutils/aperture/mask.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,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 @@ -188,20 +188,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 = data[self.bbox.slices].copy() # preserves Quantity
cutout = data[(Ellipsis,)+self.bbox.slices].copy() # preserves Quantity
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
Loading