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

Catalogs plugin results table #2915

Merged
merged 29 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
98b1051
Add file1 and file2
Jun 12, 2024
fa02476
added table to catalog plugin
Jun 24, 2024
3a153e9
fixed table in catalog search
Jun 25, 2024
1cfbe9e
Revert cubeviz.ipynb to its state from two commits ago
Jun 25, 2024
01703e4
Revert imviz.ipynb to its state from three commits ago
Jun 25, 2024
526a240
Added source IDs to the catalog table
Jun 25, 2024
ee32392
touch ups on the .py file
Jun 26, 2024
9a74df8
removed pandas import
Jun 26, 2024
9b836e5
updated the docs on the catalog search (that include information on t…
Jun 26, 2024
43bcfb4
Update docs/imviz/plugins.rst
kcarver1 Jul 1, 2024
c88d3b2
Update jdaviz/configs/default/plugins/markers/markers.py
kcarver1 Jul 1, 2024
1169b02
Update jdaviz/configs/imviz/plugins/catalogs/catalogs.py
kcarver1 Jul 1, 2024
a1ea441
fixing up code up for coding standards
Jul 1, 2024
b5e63b0
Merge branch 'main' of github.com:kcarver0/jdaviz
Jul 1, 2024
ad31221
Update docs/imviz/plugins.rst
kcarver1 Jul 1, 2024
29e6417
Update jdaviz/configs/imviz/plugins/catalogs/catalogs.py
kcarver1 Jul 1, 2024
453d275
some fixes
Jul 1, 2024
e2b4b72
Completed merge after resolving conflicts
Jul 1, 2024
9a02c98
attempt at fixing displaying issues- note I have the table displaying…
Jul 2, 2024
d5b186f
fixed bottom table displaying issues
Jul 2, 2024
8bd791f
fixing things that cause test failures
Jul 2, 2024
e383c6c
fixing code style issues
Jul 3, 2024
63c08de
fixing whitespace
Jul 3, 2024
692199a
fixing the loading files error
Jul 8, 2024
ae319f8
codestyle fix
Jul 8, 2024
bb33159
addressing failed tests
Jul 8, 2024
c21bff3
fixing whitespace
Jul 8, 2024
214e6b2
addressing Kyle's comments
Jul 15, 2024
a662b76
fixed codestyle
Jul 16, 2024
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 @@ -30,6 +30,8 @@ Cubeviz
Imviz
^^^^^

- Added a table with catalog search results. [#2915]

Mosviz
^^^^^^

Expand Down
2 changes: 2 additions & 0 deletions docs/imviz/plugins.rst
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,8 @@ are not stored. To save the current result before submitting a new query, you ca
The table returned from the API above may cover more sources than shown in the currently zoomed-in
portion of the image. Additional steps will be needed to filter out these points, if necessary.

Performing a search populates a table that contains the
right ascension, declination, and the object ID of the found sources.

.. _imviz-footprints:

Expand Down
1 change: 1 addition & 0 deletions jdaviz/configs/default/plugins/markers/markers.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ def _on_is_active_changed(self, *args):
else:
viewer.remove_event_callback(callback)

# this is where items are being added to the table
def _on_viewer_key_event(self, viewer, data):
if data['event'] == 'keydown' and data['key'] == 'm':
row_info = self.coords_info.as_dict()
Expand Down
41 changes: 37 additions & 4 deletions jdaviz/configs/imviz/plugins/catalogs/catalogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@
FileImportSelectPluginComponent, HasFileImportSelect,
with_spinner)

from jdaviz.core.template_mixin import TableMixin
from jdaviz.core.user_api import PluginUserApi

__all__ = ['Catalogs']


@tray_registry('imviz-catalogs', label="Catalog Search")
class Catalogs(PluginTemplateMixin, ViewerSelectMixin, HasFileImportSelect):
class Catalogs(PluginTemplateMixin, ViewerSelectMixin, HasFileImportSelect, TableMixin):
"""
See the :ref:`Catalog Search Plugin Documentation <imviz-catalogs>` for more details.

Expand All @@ -32,19 +35,34 @@
results_available = Bool(False).tag(sync=True)
number_of_results = Int(0).tag(sync=True)

# setting the default table headers and values
_default_table_values = {
'Right Ascension (degrees)': np.nan,
'Declination (degrees)': np.nan,
'Object ID': np.nan}

@property
def user_api(self):
return PluginUserApi(self, expose=('clear_table', 'export_table',))

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

self.catalog = FileImportSelectPluginComponent(self,
items='catalog_items',
selected='catalog_selected',
manual_options=['SDSS', 'From File...'])

# set the custom file parser for importing catalogs
self.catalog._file_parser = self._file_parser

self._marker_name = 'catalog_results'

# initializing the headers in the table that is displayed in the UI
headers = ['Right Ascension (degrees)', 'Declination (degrees)', 'Object ID']

self.table.headers_avail = headers
self.table.headers_visible = headers
self.table._default_values_by_colname = self._default_table_values

@staticmethod
def _file_parser(path):
try:
Expand Down Expand Up @@ -142,13 +160,28 @@
query_region_result['dec'],
unit='deg')

# adding in coords + Id's into table
for row in self.app._catalog_source_table:
row_info = {'Right Ascension (degrees)': row['ra'],

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

View check run for this annotation

Codecov / codecov/patch

jdaviz/configs/imviz/plugins/catalogs/catalogs.py#L164-L165

Added lines #L164 - L165 were not covered by tests
'Declination (degrees)': row['dec'],
'Object ID': row['objid']}
self.table.add_item(row_info)

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

View check run for this annotation

Codecov / codecov/patch

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

Added line #L168 was not covered by tests

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
table = self.catalog.selected_obj
self.app._catalog_source_table = table
skycoord_table = table['sky_centroid']

for row in self.app._catalog_source_table:
# find new to add in a way to append the source id to the table
# 'Object ID': row['label']} ; 'label' is failing tests
row_info = {'Right Ascension (degrees)': row['sky_centroid'].ra,
'Declination (degrees)': row['sky_centroid'].dec,
'Object ID': row.get('label', '')}
self.table.add_item(row_info)

else:
self.results_available = False
self.number_of_results = 0
Expand Down Expand Up @@ -180,8 +213,8 @@

# QTable stores all the filtered sky coordinate points to be marked
catalog_results = QTable({'coord': filtered_skycoord_table})
self.number_of_results = len(catalog_results)

self.number_of_results = len(catalog_results)
# markers are added to the viewer based on the table
viewer.marker = {'color': 'red', 'alpha': 0.8, 'markersize': 5, 'fill': False}
viewer.add_markers(table=catalog_results, use_skycoord=True, marker_name=self._marker_name)
Expand Down
7 changes: 5 additions & 2 deletions jdaviz/configs/imviz/plugins/catalogs/catalogs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@
<v-row>
<p class="font-weight-bold">Results:</p>
<span style='padding-left: 4px' v-if="results_available">{{number_of_results}}</span>
<v-row>
</v-row>

<jupyter-widget :widget="table_widget"></jupyter-widget>


</j-tray-plugin>
</template>
</template>
Loading