Package noaa.coastwatch.util
Class SubsetGrid
java.lang.Object
noaa.coastwatch.util.MetadataContainer
noaa.coastwatch.util.DataVariable
noaa.coastwatch.util.Grid
noaa.coastwatch.util.SubsetGrid
- All Implemented Interfaces:
Cloneable,ValueSource
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
-
Nested Class Summary
Nested classes/interfaces inherited from class noaa.coastwatch.util.DataVariable
DataVariable.AccessType -
Field Summary
Fields inherited from class noaa.coastwatch.util.DataVariable
data, dims, isUnsigned, lookup, unsignedType -
Constructor Summary
ConstructorsConstructorDescriptionSubsetGrid(Grid grid, int[] start, int[] dims) Creates a new subset based on the specified grid and parameters. -
Method Summary
Modifier and TypeMethodDescriptiongetData()Gets the variable data array.getData(int[] start, int[] count) Gets a subset of grid data values.doublegetValue(int index) Reads a scaled data value.doublegetValue(int row, int col) Reads a scaled data value with no navigation.doublegetValue(DataLocation loc) Reads a scaled data value with navigation.doubleinterpolate(DataLocation loc) Reads an interpolated data value.voidsetValue(int index, double val) Writes a scaled data value.voidsetValue(int row, int col, double val) Writes a scaled data value with no navigation.voidsetValue(DataLocation loc, double val) Writes a scaled data value with navigation.Methods inherited from class noaa.coastwatch.util.Grid
arraycopy, checkSubset, getNavigation, getSubset, getTilingScheme, main, navigate, setData, setNavigationMethods inherited from class noaa.coastwatch.util.DataVariable
convertUnits, dispose, format, format, format, getClassBits, getDataClass, getDecimals, getDimensions, getFormat, getLongName, getMissing, getName, getOptimalStride, getRank, getScaling, getStatistics, getStatistics, getStatistics, getStatistics, getUnits, getUnsigned, getValue, getValues, setAccessHint, setAccessType, setData, setFormat, setLongName, setLookup, setMissing, setName, setUnits, setUnsigned, setValue, toStringMethods inherited from class noaa.coastwatch.util.MetadataContainer
clone, getMetadataMap
-
Constructor Details
-
SubsetGrid
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:GridWrites 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. -
getValue
public double getValue(int row, int col) Description copied from class:GridReads 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. -
setValue
Description copied from class:GridWrites 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:
setValuein classGrid- 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 isDouble.NaNand the missing value is non-null, the missing value is written to the array.- See Also:
-
getValue
Description copied from class:GridReads 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:
getValuein interfaceValueSource- Overrides:
getValuein classGrid- Parameters:
loc- the data value location.- Returns:
- the scaled data value as a
double. TheDouble.NaNvalue 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:DataVariableWrites a scaled data value. The data value is scaled according to the scaling factor and offset and written to the data array.- Overrides:
setValuein classDataVariable- Parameters:
index- the index into the data array.val- the data value as a double. If the data value isDouble.NaNand 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:DataVariableReads a scaled data value. The data value is read from the data array and scaled according to the scaling factor and offset.- Overrides:
getValuein classDataVariable- Parameters:
index- the index into the data array.- Returns:
- the scaled data value as a
double. TheDouble.NaNvalue is used if the data value is missing. - See Also:
-
interpolate
Description copied from class:DataVariableReads an interpolated data value.- Overrides:
interpolatein classGrid- Parameters:
loc- the data value location.- Returns:
- the scaled data value as a
double. TheDouble.NaNvalue is used if the data value is missing. - See Also:
-
getData
Description copied from class:DataVariableGets the variable data array. The returned data is read-only -- the result of attempting to set values in the data is undefined.- Overrides:
getDatain classDataVariable
-
getData
Description copied from class:GridGets a subset of grid data values. This method is similar toGrid.getData(int[], int[]), but retrieves only a subset of data values in the raw, unscaled form.
-