Skip to content

Cannot pass one target to is_observable(); "FixedTarget object is not Iterable" #296

Closed

Description

@sealauren
from astroplan import (AltitudeConstraint, AirmassConstraint,
                       AtNightConstraint)
constraints = [AltitudeConstraint(10*u.deg, 80*u.deg),
               AirmassConstraint(5), AtNightConstraint.twilight_civil()]
from astroplan import is_observable, is_always_observable, months_observable
ever_observable = is_observable(constraints, gemini, trappist1, time_range=np.array(ttv_f.jd))

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-192-e65ff56ff8a5> in <module>()
      4                AirmassConstraint(5), AtNightConstraint.twilight_civil()]
      5 from astroplan import is_observable, is_always_observable, months_observable
----> 6 ever_observable = is_observable(constraints, gemini, trappist1, time_range=np.array(ttv_f.jd))

/Users/lweiss/anaconda/lib/python2.7/site-packages/astroplan/constraints.pyc in is_observable(constraints, observer, targets, times, time_range, time_grid_resolution)
    855                                       time_range=time_range,
    856                                       time_grid_resolution=time_grid_resolution)
--> 857                            for constraint in constraints]
    858     constraint_arr = np.logical_and.reduce(applied_constraints)
    859     return np.any(constraint_arr, axis=1)

/Users/lweiss/anaconda/lib/python2.7/site-packages/astroplan/constraints.pyc in __call__(self, observer, targets, times, time_range, time_grid_resolution)
    221                 targets = FixedTarget(coord=targets)
    222 
--> 223         return self.compute_constraint(times, observer, targets)
    224 
    225     @abstractmethod

/Users/lweiss/anaconda/lib/python2.7/site-packages/astroplan/constraints.pyc in compute_constraint(self, times, observer, targets)
    281 
    282     def compute_constraint(self, times, observer, targets):
--> 283         cached_altaz = _get_altaz(times, observer, targets)
    284         alt = cached_altaz['altaz'].alt
    285         if self.boolean_constraint:

/Users/lweiss/anaconda/lib/python2.7/site-packages/astroplan/constraints.pyc in _get_altaz(times, observer, targets, force_zero_pressure)
     67 
     68     # convert times, targets to tuple for hashing
---> 69     aakey = (tuple(times.jd), tuple(targets))
     70 
     71     if aakey not in observer._altaz_cache:

TypeError: 'FixedTarget' object is not utterable

Activity

  1. bsipocz commented on Mar 31, 2017

    @bsipocz
    Member

    @sealauren - Could you please give some more information? What version of astroplan and astropy do you use to get this traceback?

  2. StuartLittlefair commented on Apr 5, 2017

    @StuartLittlefair
    Contributor

    @sealauren this may well get fixed in later versions of astroplan, but for now you can just wrap your target in a list, e.g:

    from astroplan import (AltitudeConstraint, AirmassConstraint, AtNightConstraint)
    constraints = [AltitudeConstraint(10*u.deg, 80*u.deg), AirmassConstraint(5), AtNightConstraint.twilight_civil()]
    from astroplan import is_observable, is_always_observable, months_observable
    ever_observable = is_observable(constraints, gemini, [trappist1], time_range=ttv_f)
  3. bmorris3 commented on Dec 5, 2018

    @bmorris3
    Contributor

    Hey @sealauren – I wanted to follow up on this issue and see if it's still an issue?

  4. sealauren commented on Dec 5, 2018

    @sealauren
    Author
  5. wtgee commented on Oct 26, 2020

    @wtgee
    Contributor

    Marking Issue as stale and closing. Please re-open if still affected by this Issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions