Skip to content

Commit

Permalink
Guess lat/lon columns for viewer if there's only one layer.
Browse files Browse the repository at this point in the history
  • Loading branch information
Carifio24 committed May 9, 2024
1 parent a16c371 commit 817c34f
Showing 1 changed file with 11 additions and 0 deletions.
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 @@ def __setgluestate__(cls, rec, context):
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

0 comments on commit 817c34f

Please sign in to comment.