Skip to content

Commit

Permalink
Update test
Browse files Browse the repository at this point in the history
  • Loading branch information
rosteen committed Aug 26, 2024
1 parent c8f07ef commit 4556ff7
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions jdaviz/configs/imviz/tests/test_simple_aper_phot.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,18 +498,26 @@ def test_cubeviz_batch(cubeviz_helper, spectrum1d_cube_fluxunit_jy_per_steradian
phot_plugin = cubeviz_helper.plugins['Aperture Photometry']._obj
uc_plugin = cubeviz_helper.plugins['Unit Conversion']

fv = cubeviz_helper.app.get_viewer('flux-viewer')
fv.apply_roi(CircularROI(xc=5, yc=5, radius=2))

subset_plugin.subset_selected = 'Create New'
fv.apply_roi(CircularROI(xc=3, yc=3, radius=2))
cubeviz_helper.load_regions(CirclePixelRegion(center=PixCoord(x=5, y=5), radius=2))
cubeviz_helper.load_regions(CirclePixelRegion(center=PixCoord(x=3, y=3), radius=2))

phot_plugin.dataset_selected = 'test[FLUX]'
phot_plugin.multiselect = True
phot_plugin.aperture.selected = ['Subset 1', 'Subset 2']

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

# Test that it still works after unit conversion
uc_plugin.flux_unit = 'MJy'

phot_plugin.calculate_batch_photometry()
phot_plugin.calculate_batch_photometry(full_exceptions=True)

assert len(phot_plugin.table) == 2
assert len(phot_plugin.table) == 4
tbl = cubeviz_helper.get_aperture_photometry_results()
# 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,
rtol=1e-4)

0 comments on commit 4556ff7

Please sign in to comment.