Skip to content

Commit

Permalink
Add Gaia catalog to plugin
Browse files Browse the repository at this point in the history
Address review comments

Add max rows option for Gaia
  • Loading branch information
javerbukh committed Jul 16, 2024
1 parent 23b3edd commit 4d45bf5
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
14 changes: 13 additions & 1 deletion jdaviz/configs/imviz/plugins/catalogs/catalogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from jdaviz.core.template_mixin import (PluginTemplateMixin, ViewerSelectMixin,
FileImportSelectPluginComponent, HasFileImportSelect,
with_spinner)
from jdaviz.core.custom_traitlets import IntHandleEmpty

from jdaviz.core.template_mixin import TableMixin
from jdaviz.core.user_api import PluginUserApi
Expand All @@ -34,6 +35,7 @@ class Catalogs(PluginTemplateMixin, ViewerSelectMixin, HasFileImportSelect, Tabl
catalog_selected = Unicode("").tag(sync=True)
results_available = Bool(False).tag(sync=True)
number_of_results = Int(0).tag(sync=True)
max_rows = IntHandleEmpty(1000).tag(sync=True)

# setting the default table headers and values
_default_table_values = {
Expand All @@ -50,7 +52,8 @@ def __init__(self, *args, **kwargs):
self.catalog = FileImportSelectPluginComponent(self,
items='catalog_items',
selected='catalog_selected',
manual_options=['SDSS', 'From File...'])
manual_options=['SDSS', 'Gaia',
'From File...'])

# set the custom file parser for importing catalogs
self.catalog._file_parser = self._file_parser
Expand Down Expand Up @@ -167,6 +170,15 @@ def search(self, error_on_fail=False):
'Object ID': row['objid']}
self.table.add_item(row_info)

elif self.catalog_selected == 'Gaia':
from astroquery.gaia import Gaia

Gaia.ROW_LIMIT = self.max_rows
sources = Gaia.query_object(skycoord_center, radius=zoom_radius,
columns=('source_id', 'ra', 'dec'))
self.app._catalog_source_table = sources
skycoord_table = SkyCoord(sources['ra'], sources['dec'], unit='deg')

elif self.catalog_selected == 'From File...':
# all exceptions when going through the UI should have prevented setting this path
# but this exceptions might be raised here if setting from_file from the UI
Expand Down
12 changes: 12 additions & 0 deletions jdaviz/configs/imviz/plugins/catalogs/catalogs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,18 @@
<g-file-import id="file-uploader"></g-file-import>
</plugin-file-import-select>

<v-row v-if="catalog_selected === 'Gaia'">
<v-text-field
v-model.number="max_rows"
type="number"
step="10"
:rules="[() => max_rows!=='' || 'This field is required']"
label="Max rows"
hint="Maximum amount of rows."
persistent-hint
></v-text-field>
</v-row>

<v-row class="row-no-outside-padding">
<v-col>
<plugin-action-button
Expand Down

0 comments on commit 4d45bf5

Please sign in to comment.