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 7 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
21 changes: 20 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_gaia_sources = 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,22 @@
'Object ID': row['objid']}
self.table.add_item(row_info)

elif self.catalog_selected == 'Gaia':
from astroquery.gaia import Gaia
from astroquery.gaia import conf
javerbukh marked this conversation as resolved.
Show resolved Hide resolved

with conf.set_temp("ROW_LIMIT", self.max_gaia_sources):

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
sources = Gaia.query_object(skycoord_center, radius=zoom_radius,
columns=('source_id', 'ra', 'dec'))
self.app._catalog_source_table = sources

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
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:

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
row_info = {'Right Ascension (degrees)': row['ra'],
'Declination (degrees)': row['dec'],
'Source ID': row['SOURCE_ID']}

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#L185-L186

Added lines #L185 - L186 were not covered by tests
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 other configurable features.
Copy link
Member

Choose a reason for hiding this comment

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

but do we allow for passing any of those optional arguments?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We do not, but maybe a particularly knowledgeable user could use the astroquery api to enable them?

Copy link
Member

Choose a reason for hiding this comment

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

ok, since this is UI only, that is easy enough to increment on later if it causes any confusion.

javerbukh marked this conversation as resolved.
Show resolved Hide resolved
</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