Skip to content

Commit

Permalink
Fix bg auto calc on link update
Browse files Browse the repository at this point in the history
  • Loading branch information
pllim committed Sep 7, 2022
1 parent b7c85ca commit 4b75709
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
6 changes: 1 addition & 5 deletions docs/imviz/plugins.rst
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,7 @@ an interactively selected region. A typical workflow is as follows:
4. Select the desired region using the :guilabel:`Subset` dropdown menu.
5. If you want to subtract background before performing photometry,
you have the following 3 options. Otherwise if your image is already
background subtracted, choose "Manual" and leave the background set at 0.
If you change the linking (see :ref:`imviz-link-control`) after you have
a background calculated from Annulus or Subset, you need to re-select
the aperture or background subset, respectively, to have it properly
recalculated:
background subtracted, choose "Manual" and leave the background set at 0:

* Manual: Enter the background value in the :guilabel:`Background value` field.
This value must be in the same unit as display data, if applicable.
Expand Down
9 changes: 5 additions & 4 deletions jdaviz/configs/imviz/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -500,10 +500,6 @@ def link_image_data(app, link_type='pixels', wcs_fallback_scheme='pixels', wcs_u
if update_plugin and 'imviz-links-control' in [item['name'] for item in app.state.tray_items]:
link_plugin = app.get_tray_item_from_name('imviz-links-control')
link_plugin.linking_in_progress = True
app.hub.broadcast(LinkUpdatedMessage(link_type,
wcs_fallback_scheme == 'pixels',
wcs_use_affine,
sender=app))
else:
link_plugin = None

Expand Down Expand Up @@ -573,5 +569,10 @@ def link_image_data(app, link_type='pixels', wcs_fallback_scheme='pixels', wcs_u
'Images successfully relinked', color='success', timeout=8000, sender=app))

if link_plugin is not None:
# Only broadcast after success.
app.hub.broadcast(LinkUpdatedMessage(link_type,
wcs_fallback_scheme == 'pixels',
wcs_use_affine,
sender=app))
# reset the progress spinner
link_plugin.linking_in_progress = False
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from traitlets import Any, Bool, List, Unicode, observe

from jdaviz.core.custom_traitlets import FloatHandleEmpty
from jdaviz.core.events import SnackbarMessage
from jdaviz.core.events import SnackbarMessage, LinkUpdatedMessage
from jdaviz.core.region_translators import regions2aperture
from jdaviz.core.registries import tray_registry
from jdaviz.core.template_mixin import PluginTemplateMixin, DatasetSelectMixin, SubsetSelect
Expand Down Expand Up @@ -76,6 +76,7 @@ def __init__(self, *args, **kwargs):
self._fitted_model_name = 'phot_radial_profile'

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
Expand Down Expand Up @@ -172,6 +173,13 @@ def _on_subset_update(self, msg):
elif sbst.label == self.bg_subset_selected and sbst.data.label == self.dataset_selected:
self._bg_subset_selected_changed()

def _on_link_update(self, msg):
if self.dataset_selected == '' or self.subset_selected == '':
return

# Force background auto-calculation to update when linking has changed.
self._bg_subset_selected_changed()

@observe('subset_selected')
def _subset_selected_changed(self, event={}):
subset_selected = event.get('new', self.subset_selected)
Expand Down

0 comments on commit 4b75709

Please sign in to comment.