Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: aperture sum counted npix twice #1332

Merged
merged 1 commit into from
May 24, 2022
Merged
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
6 changes: 6 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ Imviz
- Radial profile plot in Simple Aperture Photometry plugin
no longer shows masked aperture data. [#1224]

- Aperture sum in Simple Aperture Photometry plugin no longer reports
the wrong value in MJy when input data is in MJy/sr. Previously,
it applied number of pixels twice in the calculations, so sum in MJy
with 10-pixel aperture would be off by a factor of 10. This bug did not
affect data in any other units. [#1332]

- Markers API now handles GWCS with ICRS Lon/Lat defined instead of
Right Ascension and Declination. [#1314]

Expand Down
4 changes: 2 additions & 2 deletions docs/imviz/plugins.rst
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,8 @@ The columns are as follow:
* :attr:`~photutils.aperture.ApertureStats.sum_aper_area`: The pixel area
covered by the region. Partial coverage is reported as fraction.
* ``pixarea_tot``: If per steradian is in input data unit and pixel area is
provided, this contains the total pixel area covered by the aperture in
steradian. Otherwise, it is `None`.
provided, this contains the conversion factor for the *sum* to take out
the steradian unit. Otherwise, it is `None`.
* ``aperture_sum_counts``: This is the aperture sum converted to counts,
if :guilabel:`Counts conversion factor` was set. Otherwise, it is `None`.
This calculation is done without taking account of ``pixarea_tot``, even
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,11 +263,11 @@ def vue_do_aper_phot(self, *args, **kwargs):
phot_table['xcentroid'].unit = u.pix # photutils only assumes, we make it real
phot_table['ycentroid'].unit = u.pix
rawsum = phot_table['sum'][0]
npix = phot_table['sum_aper_area'][0]

if include_pixarea_fac:
pixarea = pixarea * (u.arcsec * u.arcsec / (u.pix * u.pix))
pixarea_fac = npix * pixarea.to(u.sr / (u.pix * u.pix))
# NOTE: Sum already has npix value encoded, so we simply apply the npix unit here.
pixarea_fac = (u.pix * u.pix) * pixarea.to(u.sr / (u.pix * u.pix))
phot_table['sum'] = [rawsum * pixarea_fac]
else:
pixarea_fac = None
Expand Down
4 changes: 2 additions & 2 deletions jdaviz/configs/imviz/tests/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,9 +280,9 @@ def test_parse_jwst_nircam_level2(self, imviz_helper):
assert_allclose(sky.dec.deg, -69.494592)
data_unit = u.MJy / u.sr
assert_quantity_allclose(tbl[0]['background'], 0.1741226315498352 * data_unit)
assert_quantity_allclose(tbl[0]['sum'], 4.989882e-09 * u.MJy)
assert_quantity_allclose(tbl[0]['sum'], 4.486487e-11 * u.MJy, rtol=1e-6)
assert_quantity_allclose(tbl[0]['sum_aper_area'], 111.220234 * (u.pix * u.pix))
assert_quantity_allclose(tbl[0]['pixarea_tot'], 1.038438e-11 * u.sr, atol=1e-15 * u.sr)
assert_quantity_allclose(tbl[0]['pixarea_tot'], 9.33677e-14 * u.sr, rtol=1e-6)
assert_quantity_allclose(tbl[0]['aperture_sum_counts'], 132061.576643 * u.count, rtol=1e-6)
assert_quantity_allclose(tbl[0]['aperture_sum_counts_err'], 363.402775 * u.count)
assert_quantity_allclose(tbl[0]['counts_fac'], 0.0036385915646798953 * (data_unit / u.ct))
Expand Down