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 Gaia catalog to plugin #3090

Merged
merged 8 commits into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
20 changes: 19 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 @@
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 @@
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,21 @@
'Object ID': row['objid']}
self.table.add_item(row_info)

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

Check warning on line 174 in jdaviz/configs/imviz/plugins/catalogs/catalogs.py

View check run for this annotation

Codecov / codecov/patch

jdaviz/configs/imviz/plugins/catalogs/catalogs.py#L174

Added line #L174 was not covered by tests

Gaia.ROW_LIMIT = self.max_rows
sources = Gaia.query_object(skycoord_center, radius=zoom_radius,

Check warning on line 177 in jdaviz/configs/imviz/plugins/catalogs/catalogs.py

View check run for this annotation

Codecov / codecov/patch

jdaviz/configs/imviz/plugins/catalogs/catalogs.py#L176-L177

Added lines #L176 - L177 were not covered by tests
columns=('source_id', 'ra', 'dec'))
javerbukh marked this conversation as resolved.
Show resolved Hide resolved
self.app._catalog_source_table = sources
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make this public in the user API?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason making self.app._catalog_source_table public API belongs in a PR for enabling Gaia catalogs? I'm not really sure why we would do this so genuinely curious.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking more closely, I realize that this attr is on app and not the plugin, and the plugin has a table attr – I agree with you, let's not do that. Apologies 🙊

skycoord_table = SkyCoord(sources['ra'], sources['dec'], unit='deg')

Check warning on line 180 in jdaviz/configs/imviz/plugins/catalogs/catalogs.py

View check run for this annotation

Codecov / codecov/patch

jdaviz/configs/imviz/plugins/catalogs/catalogs.py#L179-L180

Added lines #L179 - L180 were not covered by tests
# adding in coords + Id's into table
for row in sources:
row_info = {'Right Ascension (degrees)': row['ra'],

Check warning on line 183 in jdaviz/configs/imviz/plugins/catalogs/catalogs.py

View check run for this annotation

Codecov / codecov/patch

jdaviz/configs/imviz/plugins/catalogs/catalogs.py#L182-L183

Added lines #L182 - L183 were not covered by tests
'Declination (degrees)': row['dec'],
'Object ID': row['SOURCE_ID']}
javerbukh marked this conversation as resolved.
Show resolved Hide resolved
self.table.add_item(row_info)

Check warning on line 186 in jdaviz/configs/imviz/plugins/catalogs/catalogs.py

View check run for this annotation

Codecov / codecov/patch

jdaviz/configs/imviz/plugins/catalogs/catalogs.py#L186

Added line #L186 was not covered by tests

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>

javerbukh marked this conversation as resolved.
Show resolved Hide resolved
<v-row class="row-no-outside-padding">
<v-col>
<plugin-action-button
Expand Down
Loading