Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add warning when less than 2 data have WCS #13

Merged
merged 8 commits into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion jdaviz/configs/imviz/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ def link_image_data(app, link_type='pixels', wcs_fallback_scheme=None, wcs_use_a
at_least_one_data_have_wcs = len([
hasattr(d, 'coords') and isinstance(d.coords, (BaseHighLevelWCS, GWCS))
for d in app.data_collection
]) > 1
]) > 0
if not at_least_one_data_have_wcs:
if wcs_fallback_scheme is None:
if error_on_fail:
Expand Down
10 changes: 10 additions & 0 deletions jdaviz/configs/imviz/plugins/links_control/links_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ class LinksControl(PluginTemplateMixin, ViewerSelectMixin):
link_type_selected = Unicode().tag(sync=True)
wcs_use_fallback = Bool(True).tag(sync=True)
wcs_use_affine = Bool(True).tag(sync=True)
wcs_linking_available = Bool(False).tag(sync=True)


need_clear_markers = Bool(False).tag(sync=True)
linking_in_progress = Bool(False).tag(sync=True)
Expand Down Expand Up @@ -150,6 +152,13 @@ def _link_image_data(self):
error_on_fail=False,
update_plugin=False)

def _check_if_data_with_wcs_exists(self):
for data in self.app.data_collection:
if hasattr(data.coords, 'pixel_to_world'):
self.wcs_linking_available = True
return
self.wcs_linking_available = False

def _on_new_app_data(self, msg):
if self.app._jdaviz_helper._in_batch_load > 0:
return
Expand All @@ -163,6 +172,7 @@ def _on_new_app_data(self, msg):
# at which point this if-statement should be removed.
return
self._link_image_data()
self._check_if_data_with_wcs_exists()

def _on_markers_changed(self, msg):
self.need_clear_markers = msg.has_markers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,18 @@

<div style="display: grid"> <!-- overlay container -->
<div style="grid-area: 1/1">
<div v-if="!wcs_linking_available">
<v-alert type='warning' style="margin-left: -12px; margin-right: -12px">
Please add at least one data with valid WCS to link by WCS
</v-alert>
</div>
<v-row>
<v-radio-group
label="Link type"
hint="Type of linking to be done."
v-model="link_type_selected"
@change="delete_subsets($event)"
:disabled="!wcs_linking_available"
persistent-hint
row>
<v-radio
Expand Down