public class SubsetGrid extends Grid
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.data, dims, isUnsigned, lookup, unsignedType
Constructor and Description |
---|
SubsetGrid(Grid grid,
int[] start,
int[] dims)
Creates a new subset based on the specified grid and parameters.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
getData()
Gets the variable data array.
|
java.lang.Object |
getData(int[] start,
int[] count)
Gets a subset of grid data values.
|
double |
getValue(DataLocation loc)
Reads a scaled data value with navigation.
|
double |
getValue(int index)
Reads a scaled data value.
|
double |
getValue(int row,
int col)
Reads a scaled data value with no navigation.
|
double |
interpolate(DataLocation loc)
Reads an interpolated data value.
|
void |
setValue(DataLocation loc,
double val)
Writes a scaled data value with navigation.
|
void |
setValue(int index,
double val)
Writes a scaled data value.
|
void |
setValue(int row,
int col,
double val)
Writes a scaled data value with no navigation.
|
arraycopy, checkSubset, getNavigation, getSubset, getTilingScheme, main, navigate, setData, setNavigation
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, setData, setFormat, setLongName, setLookup, setMissing, setName, setUnits, setUnsigned, setValue, toString
clone, getMetadataMap
public SubsetGrid(Grid grid, int[] start, int[] dims)
grid
- the grid to subset.start
- the starting data location for the subset as
[row, column]
.dims
- the subset dimensions as [rows,
columns]
.public void setValue(int row, int col, double val)
Grid
setValue
in class Grid
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.Grid.setValue(DataLocation,double)
public double getValue(int row, int col)
Grid
getValue
in class Grid
row
- the data location row.col
- the data location column.double
. The
Double.NaN
value is used if the data value is
missing or data coordinate is not valid.Grid.getValue(DataLocation)
public void setValue(DataLocation loc, double val)
Grid
setValue
in class Grid
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.Grid.setValue(int,int,double)
public double getValue(DataLocation loc)
Grid
getValue
in interface ValueSource
getValue
in class Grid
loc
- the data value location.double
. The
Double.NaN
value is used if the data value is
missing or navigated data coordinate is not valid.Grid.getValue(int,int)
public void setValue(int index, double val)
DataVariable
setValue
in class DataVariable
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.DataVariable.setValue(DataLocation,double)
public double getValue(int index)
DataVariable
getValue
in class DataVariable
index
- the index into the data array.double
. The
Double.NaN
value is used if the data value is
missing.DataVariable.getValue(DataLocation)
public double interpolate(DataLocation loc)
DataVariable
interpolate
in class Grid
loc
- the data value location.double
. The
Double.NaN
value is used if the data value is
missing.DataVariable.getValue(int)
,
DataVariable.getValue(DataLocation)
public java.lang.Object getData()
DataVariable
getData
in class DataVariable
public java.lang.Object getData(int[] start, int[] count)
Grid
Grid.getData(int[], int[])
, but retrieves only a subset of data
values in the raw, unscaled form.getData
in class Grid
start
- the subset starting [row, column].count
- the subset dimension [rows, columns].DataVariable.getData()