Skip to content

Commit

Permalink
BUG: source_id is lowercase in Gaia output (sometimes) (spacetelescop…
Browse files Browse the repository at this point in the history
…e#3400)

* Gaia source_id case could flip

* Add change log
  • Loading branch information
pllim authored Jan 22, 2025
1 parent 3107b87 commit ed09c31
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 @@ -97,6 +97,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 @@ -156,6 +156,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 @@ -200,6 +201,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"
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 @@ -261,10 +266,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 ed09c31

Please sign in to comment.