Skip to content
Back to top
View this page

# grid_from_bounding_box

gwcs.wcstools.grid_from_bounding_box(bounding_box, step=1, center=True, selector=None)

  Create a grid of input points from the WCS bounding_box.

  Note: If `bbox` is a tuple describing the range of an axis in `bounding_box`,

    `x.5` is considered part of the next pixel in `bbox[0]` and part of the previous pixel in `bbox[1]`. In this way if `bbox` describes the edges of an image the indexing includes only pixels within the image.

  Parameters:
    bounding_box tuple | ~astropy.modeling.bounding_box.ModelBoundingBox | ~astropy.modeling.bounding_box.CompoundBoundingBox

      The bounding_box of a WCS object, `bounding_box`.

    step scalar or tuple

      Step size for grid in each dimension. Scalar applies to all dimensions.

    center bool
    selector tuple | None

      If selector is set then it must be a selector tuple and bounding_box must be a CompoundBoundingBox.

    The bounding_box is in order of X, Y [, Z] and the output will be in the
    same order.
  Returns:
    x, y [, z]: ndarray

      Grid of points.

  Examples

      >>> bb = ((-1, 2.9), (6, 7.5))
      >>> grid_from_bounding_box(bb, step=(1, .5), center=False)
      array([[[-1. ,  0. ,  1. ,  2. ,  3. ],
              [-1. ,  0. ,  1. ,  2. ,  3. ],
              [-1. ,  0. ,  1. ,  2. ,  3. ],
              [-1. ,  0. ,  1. ,  2. ,  3. ]],
             [[ 6. ,  6. ,  6. ,  6. ,  6. ],
              [ 6.5,  6.5,  6.5,  6.5,  6.5],
              [ 7. ,  7. ,  7. ,  7. ,  7. ],
              [ 7.5,  7.5,  7.5,  7.5,  7.5]]])

      >>> bb = ((-1, 2.9), (6, 7.5))
      >>> grid_from_bounding_box(bb)
      array([[[-1.,  0.,  1.,  2.,  3.],
              [-1.,  0.,  1.,  2.,  3.]],
             [[ 6.,  6.,  6.,  6.,  6.],
              [ 7.,  7.,  7.,  7.,  7.]]])