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 ef2ad585a6..0f8061f1c6 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 @@ -74,6 +74,7 @@ class SimpleAperturePhotometry(PluginTemplateMixin, DatasetMultiSelectMixin, Tab pixel_area = FloatHandleEmpty(0).tag(sync=True) counts_factor = FloatHandleEmpty(0).tag(sync=True) flux_scaling_multi_auto = Bool(True).tag(sync=True) + flux_scaling_warning = Unicode("").tag(sync=True) flux_scaling = FloatHandleEmpty(0).tag(sync=True) result_available = Bool(False).tag(sync=True) result_failed_msg = Unicode("").tag(sync=True) @@ -180,6 +181,21 @@ def _get_defaults_from_metadata(self, dataset=None): return defaults + @observe('flux_scaling_multi_auto') + def _multiselect_flux_scaling_warning(self, event={}): + if not self.flux_scaling_multi_auto: + self.flux_scaling_warning = '' + return + no_flux_scaling = [dataset for dataset in self.dataset.selected + if 'flux_scaling' not in self._get_defaults_from_metadata(dataset)] + if len(no_flux_scaling): + self.flux_scaling_warning = ('Could not determine flux scaling for ' + f'{", ".join(no_flux_scaling)}. Those entries will ' + 'default to zero. Turn off auto-mode to provide ' + 'flux-scaling manually.') + else: + self.flux_scaling_warning = '' + @observe('dataset_selected') def _dataset_selected_changed(self, event={}): if not hasattr(self, 'dataset'): @@ -188,7 +204,9 @@ def _dataset_selected_changed(self, event={}): if self.dataset.selected_dc_item is None: return if self.multiselect: - # defaults are applied within the loop if the auto-switches are enabled + # defaults are applied within the loop if the auto-switches are enabled, + # but we still need to update the flux-scaling warning + self._multiselect_flux_scaling_warning() return try: @@ -196,6 +214,10 @@ def _dataset_selected_changed(self, event={}): self.counts_factor = 0 self.pixel_area = defaults.get('pixel_area', 0) self.flux_scaling = defaults.get('flux_scaling', 0) + if 'flux_scaling' in defaults: + self.flux_scaling_warning = '' + else: + self.flux_scaling_warning = f'Could not determine flux scaling for {self.dataset.selected}, defaulting to zero.' except Exception as e: self.hub.broadcast(SnackbarMessage( diff --git a/jdaviz/configs/imviz/plugins/aper_phot_simple/aper_phot_simple.vue b/jdaviz/configs/imviz/plugins/aper_phot_simple/aper_phot_simple.vue index 7cc3aa340b..505cdcbfa1 100644 --- a/jdaviz/configs/imviz/plugins/aper_phot_simple/aper_phot_simple.vue +++ b/jdaviz/configs/imviz/plugins/aper_phot_simple/aper_phot_simple.vue @@ -119,6 +119,11 @@ > + + + {{flux_scaling_warning}} + +