Skip to content

Commit

Permalink
🎨 Make target property return BaseBodycentricRepresentation when surv…
Browse files Browse the repository at this point in the history
…ey body is a planetary body
  • Loading branch information
Xen0Xys committed Aug 1, 2024
1 parent 7ca319a commit 4d15929
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/ipyaladin/widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import warnings

import anywidget
from astropy.coordinates import SkyCoord, Angle
from astropy.coordinates import SkyCoord, Angle, BaseBodycentricRepresentation
from astropy.coordinates.name_resolve import NameResolveError
from astropy.table.table import QTable
from astropy.table import Table
Expand Down Expand Up @@ -354,7 +354,7 @@ def fov(self, fov: Union[float, Angle]) -> None:
self._wcs = {}

@property
def target(self) -> SkyCoord:
def target(self) -> Union[SkyCoord, BaseBodycentricRepresentation]:
"""The target of the Aladin Lite widget.
It can be set with either a string or an `astropy.coordinates.SkyCoord` object.
Expand All @@ -365,13 +365,15 @@ def target(self) -> SkyCoord:
An `astropy.coordinates.SkyCoord` object representing the target.
"""
ra, dec = self._target.split(" ")
return SkyCoord(
ra=ra,
dec=dec,
frame="icrs",
unit="deg",
)
lon, lat = self._target.split(" ")
if self._survey_body == "sky":
return SkyCoord(
ra=lon,
dec=lat,
frame="icrs",
unit="deg",
)
return BaseBodycentricRepresentation(lon, lat)

@target.setter
def target(self, target: Union[str, SkyCoord]) -> None:
Expand Down

0 comments on commit 4d15929

Please sign in to comment.