Skip to content

Commit

Permalink
Merge pull request #2115 from meeseeksmachine/auto-backport-of-pr-211…
Browse files Browse the repository at this point in the history
…2-on-v3.4.x

Backport PR #2112 on branch v3.4.x (aperture photometry: do not hide prev results when resetting)
  • Loading branch information
pllim authored Mar 27, 2023
2 parents 88a7e15 + fd219cc commit bd28042
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 18 deletions.
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ Cubeviz
Imviz
^^^^^

* Do not hide previous results in aperture photometry when there is a failure, but rather show
the failure message within the plugin UI to indicate the shown results are "out of date". [#2112]

Mosviz
^^^^^^

Expand Down
26 changes: 8 additions & 18 deletions jdaviz/configs/imviz/plugins/aper_phot_simple/aper_phot_simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class SimpleAperturePhotometry(PluginTemplateMixin, DatasetSelectMixin, TableMix
counts_factor = Any(0).tag(sync=True)
flux_scaling = Any(0).tag(sync=True)
result_available = Bool(False).tag(sync=True)
result_failed_msg = Unicode("").tag(sync=True)
results = List().tag(sync=True)
plot_types = List([]).tag(sync=True)
current_plot_type = Unicode().tag(sync=True)
Expand Down Expand Up @@ -90,19 +91,11 @@ def __init__(self, *args, **kwargs):
self.session.hub.subscribe(self, SubsetUpdateMessage, handler=self._on_subset_update)
self.session.hub.subscribe(self, LinkUpdatedMessage, handler=self._on_link_update)

def reset_results(self):
self.result_available = False
self.results = []
self.plot_available = False
self.radial_plot = ''
bqplot_clear_figure(self._fig)

@observe('dataset_selected')
def _dataset_selected_changed(self, event={}):
try:
self._selected_data = self.dataset.selected_dc_item
if self._selected_data is None:
self.reset_results()
return
self.counts_factor = 0
self.pixel_area = 0
Expand Down Expand Up @@ -143,7 +136,6 @@ def _dataset_selected_changed(self, event={}):
self.pixel_area = 0.04 * 0.04

except Exception as e:
self.reset_results()
self._selected_data = None
self.hub.broadcast(SnackbarMessage(
f"Failed to extract {self.dataset_selected}: {repr(e)}",
Expand Down Expand Up @@ -174,7 +166,6 @@ def _on_link_update(self, msg):
def _subset_selected_changed(self, event={}):
subset_selected = event.get('new', self.subset_selected)
if self._selected_data is None or subset_selected == '':
self.reset_results()
return

try:
Expand All @@ -196,7 +187,6 @@ def _subset_selected_changed(self, event={}):

except Exception as e:
self._selected_subset = None
self.reset_results()
self.hub.broadcast(SnackbarMessage(
f"Failed to extract {subset_selected}: {repr(e)}", color='error', sender=self))

Expand Down Expand Up @@ -249,7 +239,6 @@ def _bg_subset_selected_changed(self, event={}):

def vue_do_aper_phot(self, *args, **kwargs):
if self._selected_data is None or self._selected_subset is None:
self.reset_results()
self.hub.broadcast(SnackbarMessage(
"No data for aperture photometry", color='error', sender=self))
return
Expand Down Expand Up @@ -430,14 +419,15 @@ def vue_do_aper_phot(self, *args, **kwargs):
else:
bqplot_marks = [bqplot_line]

self._fig.marks = bqplot_marks

except Exception as e: # pragma: no cover
self.reset_results()
self.hub.broadcast(SnackbarMessage(
f"Aperture photometry failed: {repr(e)}", color='error', sender=self))

bqplot_clear_figure(self._fig)
msg = f"Aperture photometry failed: {repr(e)}"
self.hub.broadcast(SnackbarMessage(msg, color='error', sender=self))
self.result_failed_msg = msg
else:
self.result_failed_msg = ''
self._fig.marks = bqplot_marks

# Parse results for GUI.
tmp = []
for key in phot_table.colnames:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,12 @@
</div>
</div>

<v-row v-if="result_failed_msg.length > 0">
<span class="v-messages v-messages__message text--secondary" style="color: red !important">
<b>WARNING</b>: {{result_failed_msg}}
</span>
</v-row>

<v-row v-if="plot_available">
<!-- NOTE: the internal bqplot widget defaults to 480 pixels, so if choosing something else,
we will likely need to override that with custom CSS rules in order to avoid the initial
Expand Down

0 comments on commit bd28042

Please sign in to comment.