|
52 | 52 | from jdaviz.utils import (SnackbarQueue, alpha_index, data_has_valid_wcs, layer_is_table_data, |
53 | 53 | MultiMaskSubsetState, _wcs_only_label, flux_conversion, |
54 | 54 | spectral_axis_conversion) |
55 | | -from jdaviz.core.validunits import check_if_unit_is_per_solid_angle |
56 | 55 |
|
57 | 56 | __all__ = ['Application', 'ALL_JDAVIZ_CONFIGS', 'UnitConverterWithSpectral'] |
58 | 57 |
|
@@ -1270,34 +1269,16 @@ def merge_func(spectral_region): # noop |
1270 | 1269 | return self._get_multi_mask_subset_definition(subset_state) |
1271 | 1270 |
|
1272 | 1271 | def _get_display_unit(self, axis): |
1273 | | - if self._jdaviz_helper is None or self._jdaviz_helper.plugins.get('Unit Conversion') is None: # noqa |
1274 | | - # fallback on native units (unit conversion is not enabled) |
1275 | | - if axis == 'spectral': |
1276 | | - sv = self.get_viewer(self._jdaviz_helper._default_spectrum_viewer_reference_name) |
1277 | | - return sv.data()[0].spectral_axis.unit |
1278 | | - elif axis in ('flux', 'sb', 'spectral_y'): |
1279 | | - sv = self.get_viewer(self._jdaviz_helper._default_spectrum_viewer_reference_name) |
1280 | | - sv_y_unit = sv.data()[0].flux.unit |
1281 | | - if axis == 'spectral_y': |
1282 | | - return sv_y_unit |
1283 | | - elif axis == 'flux': |
1284 | | - if check_if_unit_is_per_solid_angle(sv_y_unit): |
1285 | | - # TODO: this will need updating once solid-angle unit can be non-steradian |
1286 | | - return sv_y_unit * u.sr |
1287 | | - return sv_y_unit |
1288 | | - else: |
1289 | | - # surface_brightness |
1290 | | - if check_if_unit_is_per_solid_angle(sv_y_unit): |
1291 | | - return sv_y_unit |
1292 | | - return sv_y_unit / u.sr |
1293 | | - else: |
1294 | | - raise ValueError(f"could not find units for axis='{axis}'") |
1295 | | - uc = self._jdaviz_helper.plugins.get('Unit Conversion')._obj |
| 1272 | + if self._jdaviz_helper is None: |
| 1273 | + return '' |
| 1274 | + uc = self._jdaviz_helper.plugins.get('Unit Conversion', None) |
| 1275 | + if uc is None: |
| 1276 | + raise ValueError("unit conversion plugin is required to be loaded for display units") |
1296 | 1277 | if axis == 'spectral_y': |
1297 | 1278 | # translate options from uc.flux_or_sb to the prefix used in uc.??_unit_selected |
1298 | | - axis = {'Surface Brightness': 'sb', 'Flux': 'flux'}[uc.flux_or_sb_selected] |
| 1279 | + axis = {'Surface Brightness': 'sb', 'Flux': 'flux'}[uc._obj.flux_or_sb_selected] |
1299 | 1280 | try: |
1300 | | - return getattr(uc, f'{axis}_unit_selected') |
| 1281 | + return getattr(uc._obj, f'{axis}_unit_selected') |
1301 | 1282 | except AttributeError: |
1302 | 1283 | raise ValueError(f"could not find display unit for axis='{axis}'") |
1303 | 1284 |
|
|
0 commit comments