From 6f98781d41ebeade54cf94b89cb5a7e438bb3222 Mon Sep 17 00:00:00 2001 From: gibsongreen Date: Fri, 13 Dec 2024 14:40:41 -0500 Subject: [PATCH] resolve test failure --- .../imviz/plugins/catalogs/catalogs.py | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/jdaviz/configs/imviz/plugins/catalogs/catalogs.py b/jdaviz/configs/imviz/plugins/catalogs/catalogs.py index 0b3308a169..38d56afc50 100644 --- a/jdaviz/configs/imviz/plugins/catalogs/catalogs.py +++ b/jdaviz/configs/imviz/plugins/catalogs/catalogs.py @@ -244,7 +244,7 @@ def search(self, error_on_fail=False): # NOTE: If performance becomes a problem, see # https://docs.astropy.org/en/stable/table/index.html#performance-tips - if self.catalog_selected in ["SDSS", "Gaia", "From File..."]: + if self.catalog_selected in ["SDSS", "Gaia"]: # for single source convert table information to lists for zipping if len(self.app._catalog_source_table) == 1 or self.max_sources == 1: x_coordinates = [x_coordinates] @@ -256,8 +256,6 @@ def search(self, error_on_fail=False): row_id = row["objid"] elif self.catalog_selected == "Gaia": row_id = row["SOURCE_ID"] - elif self.catalog_selected == "From File...": - row_id = len(self.table) # Check if the row contains the required keys row_info = {'Right Ascension (degrees)': row['ra'], 'Declination (degrees)': row['dec'], @@ -266,6 +264,22 @@ def search(self, error_on_fail=False): 'x_coord': x_coord.item() if x_coord.size == 1 else x_coord, 'y_coord': y_coord.item() if y_coord.size == 1 else y_coord} self.table.add_item(row_info) + elif self.catalog_selected in ["From File..."]: + # for single source convert table information to lists for zipping + if len(self.app._catalog_source_table) == 1 or self.max_sources == 1: + x_coordinates = [x_coordinates] + y_coordinates = [y_coordinates] + + for row, x_coord, y_coord in zip(self.app._catalog_source_table, + x_coordinates, y_coordinates): + # Check if the row contains the required keys + row_info = {'Right Ascension (degrees)': row['sky_centroid'].ra.deg, + 'Declination (degrees)': row['sky_centroid'].dec.deg, + 'Object ID': str(row.get('label', 'N/A')), + 'id': len(self.table), + 'x_coord': x_coord.item() if x_coord.size == 1 else x_coord, + 'y_coord': y_coord.item() if y_coord.size == 1 else y_coord} + self.table.add_item(row_info) filtered_skycoord_table = viewer.state.reference_data.coords.pixel_to_world(x_coordinates, y_coordinates)