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 2efeeba8e6..b8cca64c92 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 @@ -247,13 +247,6 @@ def vue_do_aper_phot(self, *args, **kwargs): sky_center = None aperture = regions2aperture(reg) - -# UNTIL HERE - pass in pixel region explicitly and see if answers are correct -# print("HERE 1", reg) -# print("HERE 2", aperture) -# if hasattr(reg, "to_pixel"): -# print("HERE 3", reg.to_pixel(data.coords)) - include_pixarea_fac = False include_counts_fac = False include_flux_scale = False diff --git a/jdaviz/configs/imviz/tests/test_simple_aper_phot.py b/jdaviz/configs/imviz/tests/test_simple_aper_phot.py index ddb75fcc2f..2b9953e54c 100644 --- a/jdaviz/configs/imviz/tests/test_simple_aper_phot.py +++ b/jdaviz/configs/imviz/tests/test_simple_aper_phot.py @@ -219,7 +219,6 @@ def setup_class(self, imviz_helper): self.imviz = imviz_helper self.viewer = imviz_helper.default_viewer self.phot_plugin = imviz_helper.plugins["Imviz Simple Aperture Photometry"]._obj - self.phot_plugin.bg_subset_selected = 'Manual' @pytest.mark.parametrize(('data_label', 'local_bkg'), [ ('gauss100_fits_wcs[PRIMARY,1]', 5.0), @@ -234,14 +233,35 @@ def setup_class(self, imviz_helper): def test_aperphot(self, data_label, local_bkg, subset_label, expected_sum): """All data should give similar result for the same Subset.""" self.phot_plugin.dataset_selected = data_label - self.phot_plugin.background_value = local_bkg self.phot_plugin.subset_selected = subset_label + self.phot_plugin.bg_subset_selected = 'Manual' + self.phot_plugin.background_value = local_bkg self.phot_plugin.vue_do_aper_phot() tbl = self.imviz.get_aperture_photometry_results() # Imperfect down-sampling and imperfect apertures, so 10% is good enough. assert_allclose(tbl['sum'][-1], expected_sum, rtol=0.1) + @pytest.mark.parametrize(('data_label', 'fac'), [ + ('gauss100_fits_wcs[PRIMARY,1]', 1), + ('gauss100_fits_wcs_block_reduced[PRIMARY,1]', 4), + ('gauss100_fits_wcs_block_reduced_rotated[PRIMARY,1]', 4), + ('no_wcs', 1)]) + @pytest.mark.parametrize(('bg_label', 'expected_bg'), [ + ('Subset 2', 12.269274711608887), + ('Subset 3', 7.935906410217285), + ('Subset 4', 11.120951652526855)]) + def test_sky_background(self, data_label, fac, bg_label, expected_bg): + """All background (median) should give similar result for the same Subset. + Down-sampled data has higher factor due to flux conservation. + """ + self.phot_plugin.dataset_selected = data_label + self.phot_plugin.subset_selected = "Subset 1" # Does not matter + self.phot_plugin.bg_subset_selected = bg_label + + # Imperfect down-sampling and abusing apertures, so 10% is good enough. + assert_allclose(float(self.phot_plugin.background_value), expected_bg * fac, rtol=0.1) + def test_annulus_background(imviz_helper): from photutils.datasets import make_4gaussians_image