Class WindowArrayImpl

java.lang.Object
uk.ac.starlink.array.WrapperArrayImpl
uk.ac.starlink.array.WindowArrayImpl
All Implemented Interfaces:
ArrayImpl

public class WindowArrayImpl extends WrapperArrayImpl
Wraps an NDArray to produce a virtual ArrayImpl with a different shape. The result is a 'window' on the base array; a given position (coordinate vector) refers to the same pixel in both base and wrapping array, but pixels outside the window will not exist in the wrapping array and pixels in the window which do not fall within the bounds of the base array are given the bad value (for a readable array) or ignored (for a writable array).

The window may fall wholly or partially within or without the bounds of the base array, but must be of the same dimensionality as it.

Author:
Mark Taylor (Starlink)
  • Constructor Details

    • WindowArrayImpl

      public WindowArrayImpl(NDArray nda, NDShape window)
      Constructs a new ArrayImpl from a base NDArray and a given window shape.
      Parameters:
      nda - the base NDArray which supplies the original pixel values
      window - the shape of the window through which the base array will be viewed. Must have the same number of dimensions as nda
      Throws:
      IllegalArgumentException - if window has a different number of dimensions from nda
  • Method Details

    • getShape

      public OrderedNDShape getShape()
      Description copied from interface: ArrayImpl
      Returns an object representing the shape (origin and dimensions) and pixel sequence of this object. The return value must not change over the lifetime of the object.
      Specified by:
      getShape in interface ArrayImpl
      Overrides:
      getShape in class WrapperArrayImpl
      Returns:
      the ordered shape
    • getBadHandler

      public BadHandler getBadHandler()
    • getAccess

      public AccessImpl getAccess() throws IOException
      Description copied from interface: ArrayImpl
      Returns an object which can access the pixels of this ArrayImpl. Each call to this method returns a new and independent AccessImpl, with an offset initialised to 0 (the start of the array data).

      This method will only be called after the sole call to open and before the sole call to close.

      This method will only be called more than once if the multipleAccess method returns true.

      It is the responsibility of the caller to close the returned AccessImpl when it is no longer required; this enables resources it may hold to be released.

      Specified by:
      getAccess in interface ArrayImpl
      Overrides:
      getAccess in class WrapperArrayImpl
      Returns:
      an accessor for the pixel data
      Throws:
      IOException - if there is an IO error