Package ucar.nc2.dt.grid
Class GeoGrid
- java.lang.Object
-
- ucar.nc2.dt.grid.GeoGrid
-
- All Implemented Interfaces:
Comparable<GridDatatype>
,IsMissingEvaluator
,GridDatatype
,NamedObject
public class GeoGrid extends Object implements NamedObject, GridDatatype
A georeferencing "gridded" VariableEnhanced, that has a GridCoordSys. In VisAD data model, it is a sampled Field. The dimension are put into canonical order: (rt, e, t, z, y, x).Implementation note: If the Horizontal axes are 2D, the x and y dimensions are arbitrarily chosen to be gcs.getXHorizAxis().getDimension(1), gcs.getXHorizAxis().getDimension(0) respectively.
-
-
Constructor Summary
Constructors Constructor Description GeoGrid(GridDataset dataset, VariableDS dsvar, GridCoordSys gcs)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description AttributeContainer
attributes()
int
compareTo(GridDatatype g)
boolean
equals(Object oo)
Instances which have same name and coordinate system are equal.Attribute
findAttributeIgnoreCase(String name)
Convenience function; lookup Attribute by name.String
findAttValueIgnoreCase(String attName, String defaultValue)
Convenience function; lookup Attribute value by name.List<Attribute>
getAttributes()
Deprecated.use attributes()GridCoordSystem
getCoordinateSystem()
get the GridCoordSys for this GeoGrid.Array
getDataSlice(int t, int z, int y, int x)
Deprecated.use readDataSliceDataType
getDataType()
get the data typeString
getDescription()
get the standardized description, or null if none.Dimension
getDimension(int i)
get the ith dimensionList<Dimension>
getDimensions()
Returns an ArrayList containing the dimensions used by this geoGrid.Dimension
getEnsembleDimension()
get the ensemble Dimension, if it existsint
getEnsembleDimensionIndex()
get the ensemble Dimension index in the geogrid (canonical order)String
getFullName()
Get the full, unescaped name of the GridString
getInfo()
nicely formatted informationList<NamedObject>
getLevels()
Deprecated.will move in ver 6MAMath.MinMax
getMinMaxSkipMissingData(Array a)
Get the minimum and the maximum data value of the previously read Array, skipping missing values as defined by isMissingData(double val).String
getName()
Get the object's nameProjectionImpl
getProjection()
Deprecated.this will return Projection, not ProjectionImpl in 6.int
getRank()
get the rankDimension
getRunTimeDimension()
get the run time Dimension, if it existsint
getRunTimeDimensionIndex()
get the runtime Dimension index in the geogrid (canonical order)int[]
getShape()
get the shapeString
getShortName()
Get the short name of the GridDimension
getTimeDimension()
get the time Dimension, if it existsint
getTimeDimensionIndex()
get the time Dimension index in the geogrid (canonical order), or -1 if noneList<NamedObject>
getTimes()
Deprecated.will move in ver 6String
getUnitsString()
get the unit as a stringString
getUnitString()
Deprecated.use getUnitsString()Object
getValue()
VariableDS
getVariable()
Get the underlying Variable, if it exists.Dimension
getXDimension()
get the x Dimension, if it existsint
getXDimensionIndex()
get the x Dimension index in the geogrid (canonical order)Dimension
getYDimension()
get the y Dimension, if it existsint
getYDimensionIndex()
get the y Dimension index in the geogrid (canonical order)Dimension
getZDimension()
get the z Dimension, if it existsint
getZDimensionIndex()
get the z Dimension index in the geogrid (canonical order), or -1 if noneint
hashCode()
Override Object.hashCode() to be consistent with equals.boolean
hasMissing()
true if there may be missing databoolean
hasMissingData()
true if there may be missing data, see VariableDS.hasMissing()boolean
isMissing(double val)
if val is a missing data valueboolean
isMissingData(double val)
if val is missing data, see VariableDS.isMissingData()GridDatatype
makeSubset(Range rt_range, Range e_range, Range t_range, Range z_range, Range y_range, Range x_range)
Create a new GeoGrid that is a logical subset of this GeoGrid.GridDatatype
makeSubset(Range t_range, Range z_range, LatLonRect bbox, int z_stride, int y_stride, int x_stride)
Create a new GeoGrid that is a logical subset of this GeoGrid.Array
readDataSlice(int t, int z, int y, int x)
This reads an arbitrary data slice, returning the data in canonical order (t-z-y-x).Array
readDataSlice(int rt, int e, int t, int z, int y, int x)
This reads an arbitrary data slice, returning the data in canonical order (rt-e-t-z-y-x).Array
readSubset(List<Range> subset)
Array
readVolumeData(int t)
Reads in the data "volume" at the given time index.Array
readYXData(int t, int z)
Reads a Y-X "horizontal slice" at the given time and vertical index.Array
readZYData(int t, int x)
Reads a Z-Y "vertical slice" at the given time and x index.float[]
setMissingToNaN(float[] values)
Convert (in place) all values in the given array that are considered as "missing" to Float.NaN, according to isMissingData(val).GeoGrid
subset(Range t_range, Range z_range, Range y_range, Range x_range)
Create a new GeoGrid that is a logical subset of this GeoGrid.GeoGrid
subset(Range t_range, Range z_range, LatLonRect bbox, int z_stride, int y_stride, int x_stride)
Create a new GeoGrid that is a logical subset of this GeoGrid.String
toString()
string representation
-
-
-
Constructor Detail
-
GeoGrid
public GeoGrid(GridDataset dataset, VariableDS dsvar, GridCoordSys gcs)
Constructor.- Parameters:
dataset
- belongs to this datasetdsvar
- wraps this Variablegcs
- has this grid coordinate system
-
-
Method Detail
-
getDimensions
public List<Dimension> getDimensions()
Returns an ArrayList containing the dimensions used by this geoGrid. The dimension are put into canonical order: (rt, e, t, z, y, x). Note that the z and t dimensions are optional. If the Horizontal axes are 2D, the x and y dimensions are arbitrarily chosen to be gcs.getXHorizAxis().getDimension(1), gcs.getXHorizAxis().getDimension(0), respectively.- Specified by:
getDimensions
in interfaceGridDatatype
- Returns:
- List with objects of type Dimension, in canonical order.
-
getDimension
public Dimension getDimension(int i)
get the ith dimension- Specified by:
getDimension
in interfaceGridDatatype
- Parameters:
i
- : which dimension- Returns:
- ith Dimension
-
getTimeDimension
public Dimension getTimeDimension()
get the time Dimension, if it exists- Specified by:
getTimeDimension
in interfaceGridDatatype
- Returns:
- the time Dimension, or null
-
getZDimension
public Dimension getZDimension()
get the z Dimension, if it exists- Specified by:
getZDimension
in interfaceGridDatatype
- Returns:
- the z Dimension, or null
-
getYDimension
public Dimension getYDimension()
get the y Dimension, if it exists- Specified by:
getYDimension
in interfaceGridDatatype
- Returns:
- the y Dimension, or null
-
getXDimension
public Dimension getXDimension()
get the x Dimension, if it exists- Specified by:
getXDimension
in interfaceGridDatatype
- Returns:
- the x Dimension, or null
-
getEnsembleDimension
public Dimension getEnsembleDimension()
get the ensemble Dimension, if it exists- Specified by:
getEnsembleDimension
in interfaceGridDatatype
- Returns:
- the ensemble Dimension, or null
-
getRunTimeDimension
public Dimension getRunTimeDimension()
get the run time Dimension, if it exists- Specified by:
getRunTimeDimension
in interfaceGridDatatype
- Returns:
- the runtime Dimension, or null
-
getTimeDimensionIndex
public int getTimeDimensionIndex()
get the time Dimension index in the geogrid (canonical order), or -1 if none- Specified by:
getTimeDimensionIndex
in interfaceGridDatatype
- Returns:
- the time Dimension index in canonical order, or -1
-
getZDimensionIndex
public int getZDimensionIndex()
get the z Dimension index in the geogrid (canonical order), or -1 if none- Specified by:
getZDimensionIndex
in interfaceGridDatatype
- Returns:
- the z Dimension index in canonical order, or -1
-
getYDimensionIndex
public int getYDimensionIndex()
get the y Dimension index in the geogrid (canonical order)- Specified by:
getYDimensionIndex
in interfaceGridDatatype
- Returns:
- the y Dimension index in canonical order, or -1
-
getXDimensionIndex
public int getXDimensionIndex()
get the x Dimension index in the geogrid (canonical order)- Specified by:
getXDimensionIndex
in interfaceGridDatatype
- Returns:
- the x Dimension index in canonical order, or -1
-
getEnsembleDimensionIndex
public int getEnsembleDimensionIndex()
get the ensemble Dimension index in the geogrid (canonical order)- Specified by:
getEnsembleDimensionIndex
in interfaceGridDatatype
- Returns:
- the ensemble Dimension index in canonical order, or -1
-
getRunTimeDimensionIndex
public int getRunTimeDimensionIndex()
get the runtime Dimension index in the geogrid (canonical order)- Specified by:
getRunTimeDimensionIndex
in interfaceGridDatatype
- Returns:
- the runtime Dimension index in canonical order, or -1
-
findAttributeIgnoreCase
public Attribute findAttributeIgnoreCase(String name)
Convenience function; lookup Attribute by name.- Specified by:
findAttributeIgnoreCase
in interfaceGridDatatype
- Parameters:
name
- the name of the attribute- Returns:
- the attribute, or null if not found
-
findAttValueIgnoreCase
public String findAttValueIgnoreCase(String attName, String defaultValue)
Convenience function; lookup Attribute value by name. Must be String valued- Specified by:
findAttValueIgnoreCase
in interfaceGridDatatype
- Parameters:
attName
- name of the attributedefaultValue
- if not found, use this as the default- Returns:
- Attribute string value, or default if not found.
-
getRank
public int getRank()
get the rank- Specified by:
getRank
in interfaceGridDatatype
- Returns:
- the rank
-
getShape
public int[] getShape()
get the shape- Specified by:
getShape
in interfaceGridDatatype
- Returns:
- the shape (canonical ordering)
-
getDataType
public DataType getDataType()
get the data type- Specified by:
getDataType
in interfaceGridDatatype
- Returns:
- the data type
-
attributes
public AttributeContainer attributes()
-
getAttributes
@Deprecated public List<Attribute> getAttributes()
Deprecated.use attributes()Description copied from interface:GridDatatype
Get a List of Attribute specific to the Grid- Specified by:
getAttributes
in interfaceGridDatatype
- Returns:
- a List of Attribute
-
getVariable
public VariableDS getVariable()
Description copied from interface:GridDatatype
Get the underlying Variable, if it exists.- Specified by:
getVariable
in interfaceGridDatatype
- Returns:
- the underlying Variable, if it exists, else null
-
getFullName
public String getFullName()
Description copied from interface:GridDatatype
Get the full, unescaped name of the Grid- Specified by:
getFullName
in interfaceGridDatatype
- Returns:
- the full, unescaped name of the Grid
-
getName
public String getName()
Description copied from interface:NamedObject
Get the object's name- Specified by:
getName
in interfaceGridDatatype
- Specified by:
getName
in interfaceNamedObject
- Returns:
- object's name
-
getShortName
public String getShortName()
Description copied from interface:GridDatatype
Get the short name of the Grid- Specified by:
getShortName
in interfaceGridDatatype
- Returns:
- the short name of the Grid
-
getCoordinateSystem
public GridCoordSystem getCoordinateSystem()
get the GridCoordSys for this GeoGrid.- Specified by:
getCoordinateSystem
in interfaceGridDatatype
- Returns:
- the Grid's Coordinate System.
-
getProjection
public ProjectionImpl getProjection()
Deprecated.this will return Projection, not ProjectionImpl in 6.get the Projection.- Specified by:
getProjection
in interfaceGridDatatype
- Returns:
- the Projection, or null
-
getLevels
@Deprecated public List<NamedObject> getLevels()
Deprecated.will move in ver 6- Returns:
- ArrayList of thredds.util.NamedObject, from the GridCoordSys.
-
getTimes
@Deprecated public List<NamedObject> getTimes()
Deprecated.will move in ver 6- Returns:
- ArrayList of thredds.util.NamedObject, from the GridCoordSys.
-
getDescription
public String getDescription()
get the standardized description, or null if none.- Specified by:
getDescription
in interfaceGridDatatype
- Specified by:
getDescription
in interfaceNamedObject
- Returns:
- object's description
-
getValue
public Object getValue()
- Specified by:
getValue
in interfaceNamedObject
-
getUnitsString
public String getUnitsString()
get the unit as a string- Specified by:
getUnitsString
in interfaceGridDatatype
- Returns:
- the unit string
-
getUnitString
public String getUnitString()
Deprecated.use getUnitsString()- Returns:
- getUnitsString()
-
hasMissingData
public boolean hasMissingData()
true if there may be missing data, see VariableDS.hasMissing()- Specified by:
hasMissingData
in interfaceGridDatatype
- Returns:
- true if there may be missing data
-
isMissingData
public boolean isMissingData(double val)
if val is missing data, see VariableDS.isMissingData()- Specified by:
isMissingData
in interfaceGridDatatype
- Parameters:
val
- test this value- Returns:
- true if val is missing data
-
hasMissing
public boolean hasMissing()
Description copied from interface:IsMissingEvaluator
true if there may be missing data- Specified by:
hasMissing
in interfaceIsMissingEvaluator
- Returns:
- true if there may be missing data
-
isMissing
public boolean isMissing(double val)
Description copied from interface:IsMissingEvaluator
if val is a missing data value- Specified by:
isMissing
in interfaceIsMissingEvaluator
- Parameters:
val
- test this value- Returns:
- true if val is missing data
-
setMissingToNaN
public float[] setMissingToNaN(float[] values)
Convert (in place) all values in the given array that are considered as "missing" to Float.NaN, according to isMissingData(val).- Specified by:
setMissingToNaN
in interfaceGridDatatype
- Parameters:
values
- input array- Returns:
- input array, with missing values converted to NaNs.
-
getMinMaxSkipMissingData
public MAMath.MinMax getMinMaxSkipMissingData(Array a)
Get the minimum and the maximum data value of the previously read Array, skipping missing values as defined by isMissingData(double val).- Specified by:
getMinMaxSkipMissingData
in interfaceGridDatatype
- Parameters:
a
- Array to get min/max values- Returns:
- both min and max value.
-
readVolumeData
public Array readVolumeData(int t) throws IOException
Reads in the data "volume" at the given time index. If its a product set, put into canonical order (z-y-x). If not a product set, reorder to (z,i,j), where i, j are from the original- Specified by:
readVolumeData
in interfaceGridDatatype
- Parameters:
t
- time index; ignored if no time axis.- Returns:
- data[z,y,x] or data[y,x] if no z axis.
- Throws:
IOException
- on io error
-
readYXData
public Array readYXData(int t, int z) throws IOException
Reads a Y-X "horizontal slice" at the given time and vertical index. If its a product set, put into canonical order (y-x).- Parameters:
t
- time index; ignored if no time axis.z
- vertical index; ignored if no z axis.- Returns:
- data[y,x]
- Throws:
IOException
- on read error
-
readZYData
public Array readZYData(int t, int x) throws IOException
Reads a Z-Y "vertical slice" at the given time and x index. If its a product set, put into canonical order (z-y).- Parameters:
t
- time index; ignored if no time axis.x
- x index; ignored if no x axis.- Returns:
- data[z,y]
- Throws:
IOException
- on read error
-
getDataSlice
public Array getDataSlice(int t, int z, int y, int x) throws IOException
Deprecated.use readDataSlice- Throws:
IOException
- on read error
-
readDataSlice
public Array readDataSlice(int t, int z, int y, int x) throws IOException
This reads an arbitrary data slice, returning the data in canonical order (t-z-y-x). If any dimension does not exist, ignore it.- Specified by:
readDataSlice
in interfaceGridDatatype
- Parameters:
t
- if < 0, get all of time dim; if valid index, fix slice to that value.z
- if < 0, get all of z dim; if valid index, fix slice to that value.y
- if < 0, get all of y dim; if valid index, fix slice to that value.x
- if < 0, get all of x dim; if valid index, fix slice to that value.- Returns:
- data[t,z,y,x], eliminating missing or fixed dimension.
- Throws:
IOException
- on io error
-
readDataSlice
public Array readDataSlice(int rt, int e, int t, int z, int y, int x) throws IOException
This reads an arbitrary data slice, returning the data in canonical order (rt-e-t-z-y-x). If any dimension does not exist, ignore it.- Specified by:
readDataSlice
in interfaceGridDatatype
- Parameters:
rt
- if < 0, get all of runtime dim; if valid index, fix slice to that value.e
- if < 0, get all of ensemble dim; if valid index, fix slice to that value.t
- if < 0, get all of time dim; if valid index, fix slice to that value.z
- if < 0, get all of z dim; if valid index, fix slice to that value.y
- if < 0, get all of y dim; if valid index, fix slice to that value.x
- if < 0, get all of x dim; if valid index, fix slice to that value.- Returns:
- data[rt,e,t,z,y,x], eliminating missing or fixed dimension.
- Throws:
IOException
- on io error
-
readSubset
public Array readSubset(List<Range> subset) throws InvalidRangeException, IOException
- Specified by:
readSubset
in interfaceGridDatatype
- Throws:
InvalidRangeException
IOException
-
subset
public GeoGrid subset(Range t_range, Range z_range, LatLonRect bbox, int z_stride, int y_stride, int x_stride) throws InvalidRangeException
Create a new GeoGrid that is a logical subset of this GeoGrid.- Parameters:
t_range
- subset the time dimension, or null if you want all of itz_range
- subset the vertical dimension, or null if you want all of itbbox
- a lat/lon bounding box, or null if you want all x,yz_stride
- use only if z_range is null, then take all z with this stride (1 means all)y_stride
- use this stride on the y coordinate (1 means all)x_stride
- use this stride on the x coordinate (1 means all)- Returns:
- subsetted GeoGrid
- Throws:
InvalidRangeException
- if bbox does not intersect GeoGrid
-
makeSubset
public GridDatatype makeSubset(Range t_range, Range z_range, LatLonRect bbox, int z_stride, int y_stride, int x_stride) throws InvalidRangeException
Description copied from interface:GridDatatype
Create a new GeoGrid that is a logical subset of this GeoGrid. For backwards compatibility for grids with no runtime or ensemble dimensions.- Specified by:
makeSubset
in interfaceGridDatatype
- Parameters:
t_range
- subset the time dimension, or null if you want all of itz_range
- subset the vertical dimension, or null if you want all of itbbox
- a lat/lon bounding box, or null if you want all x,yz_stride
- use only if z_range is null, then take all z with this stride (1 means all)y_stride
- use this stride on the y coordinate (1 means all)x_stride
- use this stride on the x coordinate (1 means all)- Returns:
- subsetted GeoGrid
- Throws:
InvalidRangeException
- if ranges are invlaid
-
subset
public GeoGrid subset(Range t_range, Range z_range, Range y_range, Range x_range) throws InvalidRangeException
Create a new GeoGrid that is a logical subset of this GeoGrid.- Parameters:
t_range
- subset the time dimension, or null if you want all of itz_range
- subset the vertical dimension, or null if you want all of ity_range
- subset the y dimension, or null if you want all of itx_range
- subset the x dimension, or null if you want all of it- Returns:
- subsetted GeoGrid
- Throws:
InvalidRangeException
- if any of the ranges are invalid
-
makeSubset
public GridDatatype makeSubset(Range rt_range, Range e_range, Range t_range, Range z_range, Range y_range, Range x_range) throws InvalidRangeException
Description copied from interface:GridDatatype
Create a new GeoGrid that is a logical subset of this GeoGrid.- Specified by:
makeSubset
in interfaceGridDatatype
- Parameters:
rt_range
- subset the runtime dimension, or null if you want all of ite_range
- subset the ensemble dimension, or null if you want all of itt_range
- subset the time dimension, or null if you want all of itz_range
- subset the vertical dimension, or null if you want all of ity_range
- subset the y dimension, or null if you want all of itx_range
- subset the x dimension, or null if you want all of it- Returns:
- subsetted GeoGrid
- Throws:
InvalidRangeException
- if ranges are invlaid
-
equals
public boolean equals(Object oo)
Instances which have same name and coordinate system are equal.
-
hashCode
public int hashCode()
Override Object.hashCode() to be consistent with equals.
-
getInfo
public String getInfo()
nicely formatted information- Specified by:
getInfo
in interfaceGridDatatype
- Returns:
- human readable information about this Grid.
-
compareTo
public int compareTo(GridDatatype g)
- Specified by:
compareTo
in interfaceComparable<GridDatatype>
-
-