Class SubsetGrid

All Implemented Interfaces:
Cloneable, ValueSource

public class SubsetGrid extends Grid
The SubsetGrid class uses an existing Grid object to provide a subset view of its data. For example, if the original grid has dimensions (1024,1024) and the subset is defined to show only a small section starting at (100,100) of dimensions (512,512), then accessing location (0,0) in the subset is the same as accessing location (100,100) in the original grid. All other properties of the original grid are the same.
Since:
3.1.7
Author:
Peter Hollemans
  • Constructor Details

    • SubsetGrid

      public SubsetGrid(Grid grid, int[] start, int[] dims)
      Creates a new subset based on the specified grid and parameters.
      Parameters:
      grid - the grid to subset.
      start - the starting data location for the subset as [row, column].
      dims - the subset dimensions as [rows, columns].
  • Method Details

    • setValue

      public void setValue(int row, int col, double val)
      Description copied from class: Grid
      Writes a scaled data value with no navigation. The data value is scaled according to the scaling factor and offset and written to the data array. No navigation transform is applied to correct the data location.
      Overrides:
      setValue in class Grid
      Parameters:
      row - the data location row.
      col - the data location column.
      val - the data value as a double. If the data value is Double.NaN and the missing value is non-null, the missing value is written to the array.
      See Also:
    • getValue

      public double getValue(int row, int col)
      Description copied from class: Grid
      Reads a scaled data value with no navigation. The data value is read from the data array and scaled according to the scaling factor and offset. No navigation transform is applied to correct the data location.
      Overrides:
      getValue in class Grid
      Parameters:
      row - the data location row.
      col - the data location column.
      Returns:
      the scaled data value as a double. The Double.NaN value is used if the data value is missing or data coordinate is not valid.
      See Also:
    • setValue

      public void setValue(DataLocation loc, double val)
      Description copied from class: Grid
      Writes a scaled data value with navigation. The data value is scaled according to the scaling factor and offset and written to the data array. The navigation transform is applied to correct the data location prior to writing the data value.
      Overrides:
      setValue in class Grid
      Parameters:
      loc - the data location. If the location does not navigate to a valid data coordinate, no value is written.
      val - the data value as a double. If the data value is Double.NaN and the missing value is non-null, the missing value is written to the array.
      See Also:
    • getValue

      public double getValue(DataLocation loc)
      Description copied from class: Grid
      Reads a scaled data value with navigation. The data value is read from the data array and scaled according to the scaling factor and offset. The navigation transform is applied to correct the data location prior to reading the data value.
      Specified by:
      getValue in interface ValueSource
      Overrides:
      getValue in class Grid
      Parameters:
      loc - the data value location.
      Returns:
      the scaled data value as a double. The Double.NaN value is used if the data value is missing or navigated data coordinate is not valid.
      See Also:
    • setValue

      public void setValue(int index, double val)
      Description copied from class: DataVariable
      Writes a scaled data value. The data value is scaled according to the scaling factor and offset and written to the data array.
      Overrides:
      setValue in class DataVariable
      Parameters:
      index - the index into the data array.
      val - the data value as a double. If the data value is Double.NaN and the missing value is non-null, the missing value is written to the array.
      See Also:
    • getValue

      public double getValue(int index)
      Description copied from class: DataVariable
      Reads a scaled data value. The data value is read from the data array and scaled according to the scaling factor and offset.
      Overrides:
      getValue in class DataVariable
      Parameters:
      index - the index into the data array.
      Returns:
      the scaled data value as a double. The Double.NaN value is used if the data value is missing.
      See Also:
    • interpolate

      public double interpolate(DataLocation loc)
      Description copied from class: DataVariable
      Reads an interpolated data value.
      Overrides:
      interpolate in class Grid
      Parameters:
      loc - the data value location.
      Returns:
      the scaled data value as a double. The Double.NaN value is used if the data value is missing.
      See Also:
    • getData

      public Object getData()
      Description copied from class: DataVariable
      Gets the variable data array. The returned data is read-only -- the result of attempting to set values in the data is undefined.
      Overrides:
      getData in class DataVariable
    • getData

      public Object getData(int[] start, int[] count)
      Description copied from class: Grid
      Gets a subset of grid data values. This method is similar to Grid.getData(int[], int[]), but retrieves only a subset of data values in the raw, unscaled form.
      Overrides:
      getData in class Grid
      Parameters:
      start - the subset starting [row, column].
      count - the subset dimension [rows, columns].
      Returns:
      an array containing the unscaled data values.
      See Also: