Skip to content

Commit

Permalink
Backport PR #3400: BUG: source_id is lowercase in Gaia output (someti…
Browse files Browse the repository at this point in the history
…mes)
  • Loading branch information
pllim authored and meeseeksmachine committed Jan 22, 2025
1 parent d85b35c commit 0cc1ce0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ Imviz

- Spatial subsets no longer show as having mixed visibility (in the legend and plot options tab) when aligned by WCS. [#3373]

- Fixed Gaia catalog search sometimes failing with invalid ``SOURCE_ID`` look-up. [#3400]

Mosviz
^^^^^^

Expand Down
10 changes: 6 additions & 4 deletions jdaviz/configs/imviz/plugins/catalogs/catalogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ def search(self, error_on_fail=False):
if self.catalog_selected == "SDSS":
from astroquery.sdss import SDSS
r_max = 3 * u.arcmin
src_id_colname = "objid"

# queries the region (based on the provided center point and radius)
# finds all the sources in that region
Expand Down Expand Up @@ -195,6 +196,10 @@ def search(self, error_on_fail=False):
sources = Gaia.query_object(skycoord_center, radius=zoom_radius,
columns=('source_id', 'ra', 'dec')
)
if "SOURCE_ID" in sources.colnames: # Case could flip non-deterministically
src_id_colname = "SOURCE_ID"

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

View check run for this annotation

Codecov / codecov/patch

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

Added line #L200 was not covered by tests
else:
src_id_colname = "source_id"
if len(sources) == self.max_sources:
max_sources_used = True
self.app._catalog_source_table = sources
Expand Down Expand Up @@ -252,10 +257,7 @@ def search(self, error_on_fail=False):

for row, x_coord, y_coord in zip(self.app._catalog_source_table,
x_coordinates, y_coordinates):
if self.catalog_selected == "SDSS":
row_id = row["objid"]
elif self.catalog_selected == "Gaia":
row_id = row["SOURCE_ID"]
row_id = row[src_id_colname]
# Check if the row contains the required keys
row_info = {'Right Ascension (degrees)': row['ra'],
'Declination (degrees)': row['dec'],
Expand Down

0 comments on commit 0cc1ce0

Please sign in to comment.