How to use the astroplan.target.get_skycoord function in astroplan

To help you get started, we’ve selected a few astroplan examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github astropy / astroplan / astroplan / scheduling.py View on Github external
Parameters
        ----------
        blocks : list of `~astroplan.scheduling.ObservingBlock` objects
            list of blocks that need to be scored
        observer : `~astroplan.Observer`
            the observer
        schedule : `~astroplan.scheduling.Schedule`
            The schedule inside which the blocks should fit
        global_constraints : list of `~astroplan.Constraint` objects
            any ``Constraint`` that applies to all the blocks
        """
        self.blocks = blocks
        self.observer = observer
        self.schedule = schedule
        self.global_constraints = global_constraints
        self.targets = get_skycoord([block.target for block in self.blocks])
github astropy / astroplan / astroplan / observer.py View on Github external
grid_times_targets: bool
            If True, the target object will have extra dimensions packed onto
            the end, so that calculations with M targets and N times will
            return an (M, N) shaped result. Otherwise, we rely on broadcasting
            the shapes together using standard numpy rules. Useful for grid
            searches for rise/set times etc.
        """
        # make sure we have a non-scalar time
        if not isinstance(time, Time):
            time = Time(time)

        if target is None:
            return time, None

        # convert any kind of target argument to non-scalar SkyCoord
        target = get_skycoord(target)
        if grid_times_targets:
            if target.isscalar:
                # ensure we have a (1, 1) shape coord
                target = SkyCoord(np.tile(target, 1))[:, np.newaxis]
            else:
                while target.ndim <= time.ndim:
                    target = target[:, np.newaxis]

        elif not self._is_broadcastable(target.shape, time.shape):
            raise ValueError('Time and Target arguments cannot be broadcast '
                             'against each other with shapes {} and {}'
                             .format(time.shape, target.shape))
        return time, target
github astropy / astroplan / astroplan / scheduling.py View on Github external
The observer at the time

        Returns
        -------
        transition : `~astroplan.scheduling.TransitionBlock` or None
            A transition to get from ``oldblock`` to ``newblock`` or `None` if
            no transition is necessary
        """
        components = {}
        if (self.slew_rate is not None and (oldblock is not None) and (newblock is not None)):
            # use the constraints cache for now, but should move that machinery
            # to observer
            from .constraints import _get_altaz
            from .target import get_skycoord
            if oldblock.target != newblock.target:
                targets = get_skycoord([oldblock.target, newblock.target])
                aaz = _get_altaz(start_time, observer, targets)['altaz']
                sep = aaz[0].separation(aaz[1])
                if sep/self.slew_rate > 1 * u.second:
                    components['slew_time'] = sep / self.slew_rate

        if self.instrument_reconfig_times is not None:
            components.update(self.compute_instrument_transitions(oldblock, newblock))

        if components:
            return TransitionBlock(components, start_time)
        else:
            return None
github astropy / astroplan / astroplan / constraints.py View on Github external
if True, grids the constraint result with targets along the first
            index and times along the second. Otherwise, we rely on broadcasting
            the shapes together using standard numpy rules.
        Returns
        -------
        constraint_result : 1D or 2D array of float or bool
            The constraints. If 2D with targets along the first index and times along
            the second.
        """

        if times is None and time_range is not None:
            times = time_grid_from_range(time_range,
                                         time_resolution=time_grid_resolution)

        if grid_times_targets:
            targets = get_skycoord(targets)
            # TODO: these broadcasting operations are relatively slow
            # but there is potential for huge speedup if the end user
            # disables gridding and re-shapes the coords themselves
            # prior to evaluating multiple constraints.
            if targets.isscalar:
                # ensure we have a (1, 1) shape coord
                targets = SkyCoord(np.tile(targets, 1))[:, np.newaxis]
            else:
                targets = targets[..., np.newaxis]
        times, targets = observer._preprocess_inputs(times, targets, grid_times_targets=False)
        result = self.compute_constraint(times, observer, targets)

        # make sure the output has the same shape as would result from
        # broadcasting times and targets against each other
        if targets is not None:
            # broadcasting times v targets is slow due to