diff --git a/CHANGES.rst b/CHANGES.rst index 4dc4210e3a..93d90669b5 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -78,6 +78,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] diff --git a/docs/imviz/plugins.rst b/docs/imviz/plugins.rst index c6cf9daa3f..66cd58cad5 100644 --- a/docs/imviz/plugins.rst +++ b/docs/imviz/plugins.rst @@ -210,8 +210,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 diff --git a/jdaviz/configs/imviz/plugins/aper_phot_simple/aper_phot_simple.py b/jdaviz/configs/imviz/plugins/aper_phot_simple/aper_phot_simple.py index bff9e4b3a6..2aca9f8c69 100644 --- a/jdaviz/configs/imviz/plugins/aper_phot_simple/aper_phot_simple.py +++ b/jdaviz/configs/imviz/plugins/aper_phot_simple/aper_phot_simple.py @@ -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 diff --git a/jdaviz/configs/imviz/tests/test_parser.py b/jdaviz/configs/imviz/tests/test_parser.py index e5f2a69f38..c24ee58351 100644 --- a/jdaviz/configs/imviz/tests/test_parser.py +++ b/jdaviz/configs/imviz/tests/test_parser.py @@ -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))