Skip to content

Commit

Permalink
replace get_aperture_photometry_results in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kecnry committed Jan 14, 2025
1 parent 7445e97 commit aec30c3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions jdaviz/configs/cubeviz/plugins/tests/test_cubeviz_aperphot.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def test_cubeviz_aperphot_generated_3d_gaussian_smooth(cubeviz_helper, image_cub
plg.dataset_selected = "test[FLUX] spatial-smooth stddev-1.0"
plg.aperture_selected = "Subset 1"
plg.vue_do_aper_phot()
row = cubeviz_helper.get_aperture_photometry_results()[0]
row = cubeviz_helper.plugins['Aperture Photometry'].export_table()[0]

# Basically, we should recover the input rectangle here.
assert_allclose(row["xcenter"], 1 * u.pix)
Expand Down Expand Up @@ -182,7 +182,7 @@ def test_cubeviz_aperphot_cube_sr_and_pix2(cubeviz_helper,
cube_unit = u.MJy / solid_angle_unit # cube unit in app is now per pix2

plg.vue_do_aper_phot()
row = cubeviz_helper.get_aperture_photometry_results()[0]
row = cubeviz_helper.plugins['Aperture Photometry'].export_table()[0]

# Basically, we should recover the input rectangle here, minus background.
assert_allclose(row["xcenter"], 3 * u.pix)
Expand Down Expand Up @@ -227,7 +227,7 @@ def test_cubeviz_aperphot_cube_orig_flux_mjysr(cubeviz_helper,
assert_allclose(plg.flux_scaling, 0.003631)

plg.vue_do_aper_phot()
row = cubeviz_helper.get_aperture_photometry_results()[0]
row = cubeviz_helper.plugins['Aperture Photometry'].export_table()[0]

# Basically, we should recover the input rectangle here, minus background.
assert_allclose(row["xcenter"], 3 * u.pix)
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 @@ -286,7 +286,7 @@ def test_parse_jwst_nircam_level2(self, imviz_helper):
assert_allclose(phot_plugin.counts_factor, 0.0036385915646798953)
assert_allclose(phot_plugin.flux_scaling, 0.003631)
phot_plugin.vue_do_aper_phot()
tbl = imviz_helper.get_aperture_photometry_results()
tbl = imviz_helper.plugins['Aperture Photometry'].export_table()
assert_quantity_allclose(tbl[0]['xcenter'], 970.95 * u.pix)
assert_quantity_allclose(tbl[0]['ycenter'], 1116.05 * u.pix)
sky = tbl[0]['sky_center']
Expand Down Expand Up @@ -412,7 +412,7 @@ def test_parse_hst_drz(self, imviz_helper):
phot_plugin.background_value = 0.0014 # Manual entry: Median on whole array
assert_allclose(phot_plugin.pixel_area, 0.0025) # Not used but still auto-populated
phot_plugin.vue_do_aper_phot()
tbl = imviz_helper.get_aperture_photometry_results()
tbl = imviz_helper.plugins['Aperture Photometry'].export_table()
assert_quantity_allclose(tbl[0]['xcenter'], 1488.5 * u.pix, atol=2 * u.pix)
assert_quantity_allclose(tbl[0]['ycenter'], 2576 * u.pix, atol=2 * u.pix)
sky = tbl[0]['sky_center']
Expand Down
6 changes: 3 additions & 3 deletions jdaviz/configs/imviz/tests/test_simple_aper_phot.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ def test_fit_radial_profile_with_nan(imviz_helper):
with warnings.catch_warnings():
warnings.simplefilter("ignore") # Fitter warnings do not matter, only want error.
phot_plugin.vue_do_aper_phot()
tbl = imviz_helper.get_aperture_photometry_results()
tbl = imviz_helper.plugins['Aperture Photometry'].export_table()

assert phot_plugin.result_failed_msg == ''
assert_allclose(tbl['sum'][0], 8590.419296)
Expand Down Expand Up @@ -541,7 +541,7 @@ def test_cubeviz_batch(cubeviz_helper, spectrum1d_cube_fluxunit_jy_per_steradian

phot_plugin.calculate_batch_photometry(full_exceptions=True)
assert len(phot_plugin.table) == 2
tbl = cubeviz_helper.get_aperture_photometry_results()
tbl = cubeviz_helper.plugins['Aperture Photometry'].export_table()
assert_quantity_allclose(tbl['sum'], [5.980836e-12, 2.037396e-10] * u.Jy, rtol=1e-4)

# Test that it still works after unit conversion
Expand All @@ -550,7 +550,7 @@ def test_cubeviz_batch(cubeviz_helper, spectrum1d_cube_fluxunit_jy_per_steradian
phot_plugin.calculate_batch_photometry(full_exceptions=True)

assert len(phot_plugin.table) == 4
tbl = cubeviz_helper.get_aperture_photometry_results()
tbl = cubeviz_helper.plugins['Aperture Photometry'].export_table()
# get_aperture_photometry_results converts all to the same units
assert_quantity_allclose(tbl['sum'],
[5.980836e-12, 2.037396e-10, 5.980836e-12, 2.037396e-10] * u.Jy,
Expand Down

0 comments on commit aec30c3

Please sign in to comment.