-
Notifications
You must be signed in to change notification settings - Fork 76
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
Enhance From File catalog loading to support more columns and improve Clear Table functionality #3359
Enhance From File catalog loading to support more columns and improve Clear Table functionality #3359
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
Already exists and probably still relevant: https://jdaviz.readthedocs.io/en/latest/imviz/plugins.html#catalog-search. Any specific changes you think are needed? |
Re: doc -- OK I was confused by the title of PR and change log. Nvm |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some technical comments/questions.
I like the new test you added that uses local data. Thanks!
|
||
if 'sky_centroid' not in table.colnames: | ||
return 'Table does not contain required sky_centroid column', {} | ||
if 'sky_centroid' not in table.colnames: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does this have to be within try
? This check should never fail if table
is successfully read and we already have a blanket except
for that. It would only result in a bool.
In fact, I think all the if
after .read
can be after the try-except block. Unless I missed something here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for catching that! Honestly, I don’t know what I was thinking when I moved those checks inside the try-except block. You’re absolutely right that they belong outside since they’re not handling exceptions from QTable.read. I’ve fixed it now, and I appreciate your sharp eye for detail!
@@ -204,6 +207,11 @@ def search(self, error_on_fail=False): | |||
# 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 | |||
table = self.catalog.selected_obj | |||
column_names = list(table.colnames) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
column_names = list(table.colnames) | |
column_names = table.colnames |
I think it is always a list. No need to recast.
'Right Ascension (degrees)': row['sky_centroid'].ra.deg, | ||
'Declination (degrees)': row['sky_centroid'].dec.deg, | ||
'Object ID': str(row.get('label', f"{idx + 1}")), | ||
'id': idx+1, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't grok why there is "Object ID" and then there is "id" but cleaning that up is out of scope here.
That said, I noticed that "id" here is now idx + 1
but still len(self.table)
on L271 above. Should this inconsistency be addressed in this PR or is this also out of scope?
Somehow the changes here cause ResourceWarning in a catalog test. Unclosed file somewhere? Should investigate.
|
@@ -271,16 +279,19 @@ def search(self, error_on_fail=False): | |||
if len(self.app._catalog_source_table) == 1 or self.max_sources == 1: | |||
x_coordinates = [x_coordinates] | |||
y_coordinates = [y_coordinates] | |||
for idx, (row, x_coord, y_coord) in enumerate(zip(self.app._catalog_source_table, x_coordinates, y_coordinates)): # noqa:E501 | |||
row_info = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the loaded table has to have a 'sky centroid' column, but it is then broken up into ra and dec, which means when its written back out it cant be read back in because it doesn't have 'sky centroid'. would it be possible to add a check when loading if the table already contains a ra and dec column rather than unpacking sky centroid? as it is, a table written out by the app can not be read back in
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does that problem pre-date this PR? Just wondering if round-tripping is in scope here (e.g., writing it out back as sky centroid as a single column in ECSV format).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
export_table
is ultimately called which will treat the the TableMixin
columns as a QTable
jdaviz/jdaviz/core/template_mixin.py
Line 4790 in 48be154
self._qtable.write(filename, overwrite=overwrite) |
sky_centroid
, you wouldn't be able to read it back in after exporting. This is also true if you try exporting Gaia or SDSS.
In the case of 'from file', we already have the sky_centroid
column, so we could add the sky_centroid column with the same name to our table, export the table, and then the exported file is able to be reloaded into Imviz.
The other catalogs options could be added in a follow up effort for either writing the sky_centroid
column to the loaded catalog table or handle it on export.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was trying to keep it aligned with the other Search
options, but I didn't think of the export functionality then. Thanks for the additional context, all; I will keep the existing sky_centroid
column in the table.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3359 +/- ##
==========================================
- Coverage 88.12% 88.12% -0.01%
==========================================
Files 127 127
Lines 19702 19727 +25
==========================================
+ Hits 17362 17384 +22
- Misses 2340 2343 +3 ☔ View full report in Codecov by Sentry. |
Co-authored-by: P. L. Lim <[email protected]>
Co-authored-by: P. L. Lim <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything looks good to me, great work!
… Clear Table functionality (spacetelescope#3359) * Add functionality to load catalogs from a file * Fix table and viewer clearing functionality * Remove redundant 'Clear' button and combine its functionality with 'Clear Table' for intuitive behavior * Codestyle * Add change log * Update tests * Fix failing test * Fix the test, ensuring to first select a row before zooming in. * Update change log * Preserve the unit when serializing * Generate default Object IDs when label column is missing * Update docs related to label column in catalogs * Update tests after merge * Update test * Move changelog to correct milestone * Adjust test assertions * Add test for loading catalogs with additional columns * Update change log * Update based on feedback * Apply suggestions from code review Co-authored-by: P. L. Lim <[email protected]> * Update CHANGES.rst Co-authored-by: P. L. Lim <[email protected]> * Adjust test tolerance --------- Co-authored-by: P. L. Lim <[email protected]>
Description
This pull request introduces:
Catalog Loading from File:
- Users can now load catalog data (e.g., .ecsv files) directly into the table.
Improved Clear Table Functionality:
- The "Clear Table" button now clears the table, removes markers, and resets selected rows in the viewer.
Screen.Recording.2024-12-15.at.10.42.00.PM.mov
Fixes #
Change log entry
CHANGES.rst
? If you want to avoid merge conflicts,list the proposed change log here for review and add to
CHANGES.rst
before merge. If no, maintainershould add a
no-changelog-entry-needed
label.Checklist for package maintainer(s)
This checklist is meant to remind the package maintainer(s) who will review this pull request of some common things to look for. This list is not exhaustive.
trivial
label.