Skip to content

Commit

Permalink
adding part of a test
Browse files Browse the repository at this point in the history
  • Loading branch information
cshanahan1 committed Aug 9, 2024
1 parent cd67777 commit 6ac80f6
Showing 1 changed file with 53 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,11 @@ def test_sb_unit_conversion(cubeviz_helper):
viewer_1d = cubeviz_helper.app.get_viewer(
cubeviz_helper._default_spectrum_viewer_reference_name)

assert label_mouseover.as_text() == (
"Pixel x=00010.0 y=00008.0 Value +1.00000e+06 MJy / sr",
"World 13h39m59.7037s +27d00m03.2400s (ICRS)",
"204.9987654313 27.0008999946 (deg)")

uc_plg.flux_or_sb.selected = 'Surface Brightness'

# Surface Brightness conversion
Expand Down Expand Up @@ -251,3 +256,51 @@ def test_sb_unit_conversion(cubeviz_helper):

la = cubeviz_helper.plugins['Line Analysis']._obj
assert la.dataset.get_selected_spectrum(use_display_units=True)

def test_mouseover_display_unit(cubeviz_helper):

# custom cube to have Surface Brightness units
wcs_dict = {"CTYPE1": "WAVE-LOG", "CTYPE2": "DEC--TAN", "CTYPE3": "RA---TAN",
"CRVAL1": 4.622e-7, "CRVAL2": 27, "CRVAL3": 205,
"CDELT1": 8e-11, "CDELT2": 0.0001, "CDELT3": -0.0001,
"CRPIX1": 0, "CRPIX2": 0, "CRPIX3": 0, "PIXAR_SR": 8e-11}
w = WCS(wcs_dict)
flux = np.zeros((30, 20, 3001), dtype=np.float32)
flux[5:15, 1:11, :] = 1
cube = Spectrum1D(flux=flux * (u.MJy / u.sr), wcs=w, meta=wcs_dict)
cubeviz_helper.load_data(cube, data_label="test")

uc_plg = cubeviz_helper.plugins['Unit Conversion']
uc_plg.open_in_tray()

# ensure that per solid angle cube defaults to Flux spectrum
assert uc_plg.flux_or_sb == 'Flux'

# make sure the mouseover display unit for a cube loaded in surface
# brighntess units reflects the selected 'flux' unit


# test mouseover while spectral y axis is in 'Flux'
# coords_info should pick up the selected flux unit to display the
# data unit, which is in surface brightness
label_mouseover._viewer_mouse_event(
flux_viewer, {"event": "mousemove", "domain": {"x": 10, "y": 8}}
)

assert label_mouseover.as_text() == (
"Pixel x=00010.0 y=00008.0 Value +1.00000e+00 MJy / sr",
"World 13h39m59.7037s +27d00m03.2400s (ICRS)",
"204.9987654313 27.0008999946 (deg)")

# change unit, but spectral y axis is still in 'flux'
# make sure surface brightness display unit still updates
# accordingly
uc_plg.flux_unit = 'Jy'

assert label_mouseover.as_text() == (
"Pixel x=00010.0 y=00008.0 Value +1.00000e+06 Jy / sr",
"World 13h39m59.7037s +27d00m03.2400s (ICRS)",
"204.9987654313 27.0008999946 (deg)")



0 comments on commit 6ac80f6

Please sign in to comment.