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 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: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ Imviz

- Added a table with catalog search results. [#2915]

- Added Gaia catalog to Catalog plugin. [#3090]

Mosviz
^^^^^^

Expand Down
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 @@ 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_gaia_sources = 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,21 @@ 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, conf

with conf.set_temp("ROW_LIMIT", self.max_gaia_sources):
sources = Gaia.query_object(skycoord_center, radius=zoom_radius,
columns=('source_id', 'ra', 'dec'))
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')
# adding in coords + Id's into table
for row in sources:
row_info = {'Right Ascension (degrees)': row['ra'],
'Declination (degrees)': row['dec'],
'Source ID': row['SOURCE_ID']}
self.table.add_item(row_info)

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
18 changes: 18 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,24 @@
<g-file-import id="file-uploader"></g-file-import>
</plugin-file-import-select>

<v-row v-if="catalog_selected === 'Gaia'">
<j-docs-link>
See the <j-external-link link='https://astroquery.readthedocs.io/en/latest/gaia/gaia.html' linktext='astropy.gaia docs'></j-external-link> for details on the query defaults.
</j-docs-link>
</v-row>

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

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