def compute_constraint(self, times, observer, targets): targets = [ target.coord if hasattr(target, 'coord') else target for target in targets ] # TODO: when astropy/astropy#5069 is resolved, replace this workaround which # handles scalar and non-scalar time inputs differently if times.isscalar: moon = get_moon(times, location=observer.location, ephemeris=self.ephemeris) moon_separation = Angle( [moon.separation(target) for target in targets]).T else: moon_separation = [] for t in times: moon_coord = get_moon(t, location=observer.location, ephemeris=self.ephemeris) sep = [moon_coord.separation(target) for target in targets] moon_separation.append(sep) moon_separation = Angle(moon_separation).T if self.min is None and self.max is not None: mask = self.max >= moon_separation elif self.max is None and self.min is not None: mask = self.min <= moon_separation elif self.min is not None and self.max is not None: mask = ((self.min <= moon_separation) & (moon_separation <= self.max)) else: raise ValueError("No max and/or min specified in " "MoonSeparationConstraint.") return mask