Skip to content

"Tried to do is_equivalent_frame on something that isn't frame-like" error from MoonSeparationConstraint().compute_constraint() #567

@pmaxted

Description

@pmaxted

astropy-5.3.3
astroplan-0.9

import astroplan as ap
from astropy.time import Time
import astropy.units as u
from astropy.coordinates import SkyCoord

observer = ap.Observer.at_site('lasilla')
targets = [ap.FixedTarget(SkyCoord.from_name('Sirius'), name='Sirius')]
noon = Time("2023-06-06 12:00:00")
time_grid = ap.time_grid_from_range([noon,noon+1*u.day])
moon_constraint = ap.MoonSeparationConstraint(30*u.degree)
moon_ok_grid = moon_constraint.compute_constraint(time_grid, observer, [targets])

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
/var/folders/dl/tc85r2_j2v94kqhby3hvz4n00000gn/T/ipykernel_86529/2961427994.py in <module>
      9 time_grid = ap.time_grid_from_range([noon,noon+1*u.day])
     10 moon_constraint = ap.MoonSeparationConstraint(30*u.degree)
---> 11 moon_ok_grid = moon_constraint.compute_constraint(time_grid, observer, target)

~/miniconda3/lib/python3.9/site-packages/astroplan/constraints.py in compute_constraint(self, times, observer, targets)
    596         # the former calculates the separation in the frame of the moon coord
    597         # which is GCRS, and that is what we want.
--> 598         moon_separation = moon.separation(targets)
    599 
    600         if self.min is None and self.max is not None:

~/miniconda3/lib/python3.9/site-packages/astropy/coordinates/sky_coordinate.py in separation(self, other)
   1170         from .angle_utilities import angular_separation
   1171 
-> 1172         if not self.is_equivalent_frame(other):
   1173             try:
   1174                 kwargs = (

~/miniconda3/lib/python3.9/site-packages/astropy/coordinates/sky_coordinate.py in is_equivalent_frame(self, other)
   1129         else:
   1130             # not a BaseCoordinateFrame nor a SkyCoord object
-> 1131             raise TypeError(
   1132                 "Tried to do is_equivalent_frame on something that isn't frame-like"
   1133             )

TypeError: Tried to do is_equivalent_frame on something that isn't frame-like

I can get this working for a single target if I replace line 598 of constraints.py with ...

moon_separation = moon.separation(SkyCoord([target.coord for target in targets]))

... but I'm not sure why, and this does not work if targets is a list of more than one target.

-Pierre

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions