public class Grid extends DataVariable
(r,c)
is desired.
Then the actual coordinate in the variable data array is
calculated as (r',c') = affine ((r,c))
where
affine()
is the application of the affine transform to
the data coordinate.Modifier and Type | Field and Description |
---|---|
static int |
COLS
Index of columns dimension.
|
static int |
ROWS
Index of rows dimension.
|
data, dims, isUnsigned, lookup, unsignedType
Constructor and Description |
---|
Grid(Grid grid)
Constructs a new 2D grid from the specified grid.
|
Grid(Grid grid,
int rows,
int cols)
Constructs a new 2D grid from the specified grid and dimensions.
|
Grid(java.lang.String name,
java.lang.String longName,
java.lang.String units,
int rows,
int cols,
java.lang.Object data,
java.text.NumberFormat format,
double[] scaling,
java.lang.Object missing)
Constructs a new 2D grid with the specified properties.
|
Modifier and Type | Method and Description |
---|---|
static void |
arraycopy(java.lang.Object src,
int[] srcDims,
int[] srcPos,
java.lang.Object dest,
int[] destDims,
int[] destPos,
int[] length)
Performs an array copy of 2D data stored in 1D arrays.
|
boolean |
checkSubset(int[] start,
int[] count)
Checks the subset specification for errors.
|
java.lang.Object |
getData(int[] start,
int[] count)
Gets a subset of grid data values.
|
java.awt.geom.AffineTransform |
getNavigation()
Gets the navigation correction affine transform.
|
Grid |
getSubset(int[] start,
int[] dims)
Gets a new subset of this grid using the specified parameters.
|
TilingScheme |
getTilingScheme()
Gets the tiling scheme for this grid if one is available.
|
double |
getValue(DataLocation loc)
Reads a scaled data value with navigation.
|
double |
getValue(int row,
int col)
Reads a scaled data value with no navigation.
|
double |
interpolate(DataLocation loc)
Reads an interpolated data value.
|
static void |
main(java.lang.String[] argv)
Tests this class.
|
DataLocation |
navigate(DataLocation loc)
Applies the navigation transform to the specified data coordinate.
|
void |
setData(java.lang.Object subset,
int[] start,
int[] count)
Sets a subset of grid data values.
|
void |
setNavigation(java.awt.geom.AffineTransform nav)
Sets the navigation correction affine transform.
|
void |
setValue(DataLocation loc,
double val)
Writes a scaled data value with navigation.
|
void |
setValue(int row,
int col,
double val)
Writes a scaled data value with no navigation.
|
convertUnits, dispose, format, format, format, getClassBits, getData, getDataClass, getDecimals, getDimensions, getFormat, getLongName, getMissing, getName, getOptimalStride, getRank, getScaling, getStatistics, getStatistics, getStatistics, getStatistics, getUnits, getUnsigned, getValue, getValue, getValues, setAccessHint, setData, setFormat, setLongName, setLookup, setMissing, setName, setUnits, setUnsigned, setValue, setValue, toString
clone, getMetadataMap
public static final int ROWS
public static final int COLS
public Grid(java.lang.String name, java.lang.String longName, java.lang.String units, int rows, int cols, java.lang.Object data, java.text.NumberFormat format, double[] scaling, java.lang.Object missing)
rows
and cols
specify the grid
dimensions. The inital affine transform is set to the identity.DataVariable
public Grid(Grid grid)
grid
- the grid to use for properties.public Grid(Grid grid, int rows, int cols)
grid
- the grid to use for properties.rows
- the grid rows dimension.cols
- the grid columns dimension.public TilingScheme getTilingScheme()
public java.awt.geom.AffineTransform getNavigation()
public void setNavigation(java.awt.geom.AffineTransform nav)
public void setValue(int row, int col, double val)
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.setValue(DataLocation,double)
public double getValue(int row, int col)
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.getValue(DataLocation)
public void setValue(DataLocation loc, double val)
setValue
in class DataVariable
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.setValue(int,int,double)
public double getValue(DataLocation loc)
getValue
in interface ValueSource
getValue
in class DataVariable
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.getValue(int,int)
public DataLocation navigate(DataLocation loc)
loc
- the data coordinate to navigate.public double interpolate(DataLocation loc)
DataVariable
interpolate
in class DataVariable
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 boolean checkSubset(int[] start, int[] count)
start
- the starting [row, column].count
- the subset dimension [rows, columns].public static void arraycopy(java.lang.Object src, int[] srcDims, int[] srcPos, java.lang.Object dest, int[] destDims, int[] destPos, int[] length)
System.arraycopy
but works
with 2D data stored in 1D arrays in row-major order.src
- the source array.srcDims
- the source array dimensions as [rows, columns].srcPos
- the source starting position as [row, column].dest
- the destination array.destDims
- the destination array dimensions as [rows, columns].destPos
- the destination starting position as [row, column].length
- the copy length as [rows, columns].public void setData(java.lang.Object subset, int[] start, int[] count)
DataVariable.setData(Object)
, but sets only a subset of data
values in the raw, unscaled form.subset
- the subset array of unscaled data values.start
- the subset starting [row, column].count
- the subset dimensions [rows, columns].java.lang.IndexOutOfBoundsException
- if the subset falls outside the
grid dimensions.public java.lang.Object getData(int[] start, int[] count)
getData(int[], int[])
, but retrieves only a subset of data
values in the raw, unscaled form.start
- the subset starting [row, column].count
- the subset dimension [rows, columns].java.lang.IndexOutOfBoundsException
- if the subset falls outside the
grid dimensions.DataVariable.getData()
public Grid getSubset(int[] start, int[] dims)
start
- the starting data location for the subset as
[row, column]
.dims
- the subset dimensions as [rows,
columns]
.public static void main(java.lang.String[] argv) throws java.lang.Exception
argv
- the array of command line parameters.java.lang.Exception