Skip to content

Commit

Permalink
Allow URL only override
Browse files Browse the repository at this point in the history
  • Loading branch information
duytnguyendtn committed May 16, 2024
1 parent c903948 commit c6a4d9d
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions jdaviz/configs/default/plugins/virtual_observatory/vo_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def __init__(self, *args, **kwargs):

self.table.headers_avail = ["Title", "Instrument", "DateObs", "URL"]
self.table.headers_visible = ["Title", "Instrument", "DateObs"]
self._populate_url_only = False

self.table.show_rowselect = True
self.table.item_key = "URL"
Expand Down Expand Up @@ -117,11 +118,18 @@ def vue_query_resource(self, *args, **kwargs):
self.results_loading = False # Stop loading spinner

try:
if self._populate_url_only:
self.table.headers_visible = ["URL"]
else:
self.table.headers_visible = ["Title", "Instrument", "DateObs"]
for result in sia_results:
self.table.add_item({"Title": str(result.title),
"URL": str(result.getdataurl()),
"Instrument": str(result.instr),
"DateObs": str(result.dateobs)})
if self._populate_url_only:
self.table.add_item({"URL": str(result.getdataurl())})
else:
self.table.add_item({"Title": str(result.title),
"URL": str(result.getdataurl()),
"Instrument": str(result.instr),
"DateObs": str(result.dateobs)})
self.hub.broadcast(SnackbarMessage(
f"{len(sia_results)} SIA results populated!", sender=self, color="success"))
except Exception as e:
Expand All @@ -134,9 +142,13 @@ def vue_load_selected_data(self,event):
self.data_loading = True # Start loading spinner
for entry in self.table.selected_rows:
try:
if self._populate_url_only:
data_label = f"{self.source}_{self.resource_selected}_{entry['URL']}"
else:
data_label = f"{self.source}_{self.resource_selected}_{entry['Title']}"
self.app._jdaviz_helper.load_data(
fits.open(str(entry["URL"])), # Open URL as FITS object
data_label=f"{self.source}_{self.resource_selected}_{entry['Title']}")
data_label=data_label)
except Exception as e:
self.hub.broadcast(SnackbarMessage(
f"Unable to load file to viewer: {entry['URL']}: {e}", sender=self, color="error"))
Expand Down

0 comments on commit c6a4d9d

Please sign in to comment.