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

Guess lat/lon columns for viewer when appropriate #110

Merged
merged 2 commits into from
May 13, 2024
Merged
Changes from 1 commit
Commits
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
11 changes: 11 additions & 0 deletions glue_wwt/viewer/data_viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from glue.core.coordinates import WCSCoordinates
from glue.logger import logger
from pywwt import ViewerNotAvailableError
from pywwt.layers import guess_lon_lat_columns

from .image_layer import WWTImageLayerArtist
from .table_layer import WWTTableLayerArtist
Expand Down Expand Up @@ -127,3 +128,13 @@
camera_kwargs["roll"] = roll * u.deg
viewer._wwt.center_on_coordinates(SkyCoord(ra, dec, unit=u.deg), **camera_kwargs)
return viewer

def add_data(self, data):
add = super().add_data(data)
if add and len(self.state.layers) == 1:
colnames = [c.label for c in data.components]
lon, lat = guess_lon_lat_columns(colnames)
if lon is not None and lat is not None:
self.state.lon_att = data.id[lon]
self.state.lat_att = data.id[lat]

Check warning on line 139 in glue_wwt/viewer/data_viewer.py

View check run for this annotation

Codecov / codecov/patch

glue_wwt/viewer/data_viewer.py#L138-L139

Added lines #L138 - L139 were not covered by tests
return add
Loading