Skip to main content
`Ctrl`+`K`

# TimeConstraint

class astroplan.TimeConstraint(min=None, max=None)

  Bases: `Constraint`

  Constrain the observing time to be within certain time limits.

  An example use case for this class would be to associate an acceptable time range with a specific observing block. This can be useful if not all observing blocks are valid over the time limits used in calls to `is_observable` or `is_always_observable`.

  Parameters:
    min `Time`

      Earliest time (inclusive). `None` indicates no limit.

    max `Time`

      Latest time (inclusive). `None` indicates no limit.

  Examples

  Constrain the observations to targets that are observable between 2016-03-28 and 2016-03-30:

      >>> from astroplan import Observer
      >>> from astropy.time import Time
      >>> subaru = Observer.at_site("Subaru")
      >>> t1 = Time("2016-03-28T12:00:00")
      >>> t2 = Time("2016-03-30T12:00:00")
      >>> constraint = TimeConstraint(t1,t2)

  Methods Summary

  `compute_constraint`(times, observer, targets) | Actually do the real work of computing the constraint.

  Methods Documentation

  compute_constraint(times, observer, targets)

    Actually do the real work of computing the constraint. Subclasses override this.

    Parameters:
      times `Time`

        The times to compute the constraint

      observer `Observer`

        the observaton location from which to apply the constraints

      targets sequence of `Target`

        The targets on which to apply the constraints.

    Returns:
      constraint_result 2D array of float or bool

        The constraints, with targets along the first index and times along the second.