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 AttributeContainerattributes()intcompareTo(GridDatatype g)booleanequals(Object oo)Instances which have same name and coordinate system are equal.AttributefindAttributeIgnoreCase(String name)Convenience function; lookup Attribute by name.StringfindAttValueIgnoreCase(String attName, String defaultValue)Convenience function; lookup Attribute value by name.List<Attribute>getAttributes()Deprecated.use attributes()GridCoordSystemgetCoordinateSystem()get the GridCoordSys for this GeoGrid.ArraygetDataSlice(int t, int z, int y, int x)Deprecated.use readDataSliceDataTypegetDataType()get the data typeStringgetDescription()get the standardized description, or null if none.DimensiongetDimension(int i)get the ith dimensionList<Dimension>getDimensions()Returns an ArrayList containing the dimensions used by this geoGrid.DimensiongetEnsembleDimension()get the ensemble Dimension, if it existsintgetEnsembleDimensionIndex()get the ensemble Dimension index in the geogrid (canonical order)StringgetFullName()Get the full, unescaped name of the GridStringgetInfo()nicely formatted informationList<NamedObject>getLevels()Deprecated.will move in ver 6MAMath.MinMaxgetMinMaxSkipMissingData(Array a)Get the minimum and the maximum data value of the previously read Array, skipping missing values as defined by isMissingData(double val).StringgetName()Get the object's nameProjectionImplgetProjection()Deprecated.this will return Projection, not ProjectionImpl in 6.intgetRank()get the rankDimensiongetRunTimeDimension()get the run time Dimension, if it existsintgetRunTimeDimensionIndex()get the runtime Dimension index in the geogrid (canonical order)int[]getShape()get the shapeStringgetShortName()Get the short name of the GridDimensiongetTimeDimension()get the time Dimension, if it existsintgetTimeDimensionIndex()get the time Dimension index in the geogrid (canonical order), or -1 if noneList<NamedObject>getTimes()Deprecated.will move in ver 6StringgetUnitsString()get the unit as a stringStringgetUnitString()Deprecated.use getUnitsString()ObjectgetValue()VariableDSgetVariable()Get the underlying Variable, if it exists.DimensiongetXDimension()get the x Dimension, if it existsintgetXDimensionIndex()get the x Dimension index in the geogrid (canonical order)DimensiongetYDimension()get the y Dimension, if it existsintgetYDimensionIndex()get the y Dimension index in the geogrid (canonical order)DimensiongetZDimension()get the z Dimension, if it existsintgetZDimensionIndex()get the z Dimension index in the geogrid (canonical order), or -1 if noneinthashCode()Override Object.hashCode() to be consistent with equals.booleanhasMissing()true if there may be missing databooleanhasMissingData()true if there may be missing data, see VariableDS.hasMissing()booleanisMissing(double val)if val is a missing data valuebooleanisMissingData(double val)if val is missing data, see VariableDS.isMissingData()GridDatatypemakeSubset(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.GridDatatypemakeSubset(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.ArrayreadDataSlice(int t, int z, int y, int x)This reads an arbitrary data slice, returning the data in canonical order (t-z-y-x).ArrayreadDataSlice(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).ArrayreadSubset(List<Range> subset)ArrayreadVolumeData(int t)Reads in the data "volume" at the given time index.ArrayreadYXData(int t, int z)Reads a Y-X "horizontal slice" at the given time and vertical index.ArrayreadZYData(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).GeoGridsubset(Range t_range, Range z_range, Range y_range, Range x_range)Create a new GeoGrid that is a logical subset of this GeoGrid.GeoGridsubset(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.StringtoString()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:
getDimensionsin interfaceGridDatatype- Returns:
- List with objects of type Dimension, in canonical order.
-
getDimension
public Dimension getDimension(int i)
get the ith dimension- Specified by:
getDimensionin interfaceGridDatatype- Parameters:
i- : which dimension- Returns:
- ith Dimension
-
getTimeDimension
public Dimension getTimeDimension()
get the time Dimension, if it exists- Specified by:
getTimeDimensionin interfaceGridDatatype- Returns:
- the time Dimension, or null
-
getZDimension
public Dimension getZDimension()
get the z Dimension, if it exists- Specified by:
getZDimensionin interfaceGridDatatype- Returns:
- the z Dimension, or null
-
getYDimension
public Dimension getYDimension()
get the y Dimension, if it exists- Specified by:
getYDimensionin interfaceGridDatatype- Returns:
- the y Dimension, or null
-
getXDimension
public Dimension getXDimension()
get the x Dimension, if it exists- Specified by:
getXDimensionin interfaceGridDatatype- Returns:
- the x Dimension, or null
-
getEnsembleDimension
public Dimension getEnsembleDimension()
get the ensemble Dimension, if it exists- Specified by:
getEnsembleDimensionin interfaceGridDatatype- Returns:
- the ensemble Dimension, or null
-
getRunTimeDimension
public Dimension getRunTimeDimension()
get the run time Dimension, if it exists- Specified by:
getRunTimeDimensionin 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:
getTimeDimensionIndexin 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:
getZDimensionIndexin 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:
getYDimensionIndexin 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:
getXDimensionIndexin 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:
getEnsembleDimensionIndexin 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:
getRunTimeDimensionIndexin 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:
findAttributeIgnoreCasein 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:
findAttValueIgnoreCasein 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:
getRankin interfaceGridDatatype- Returns:
- the rank
-
getShape
public int[] getShape()
get the shape- Specified by:
getShapein interfaceGridDatatype- Returns:
- the shape (canonical ordering)
-
getDataType
public DataType getDataType()
get the data type- Specified by:
getDataTypein interfaceGridDatatype- Returns:
- the data type
-
attributes
public AttributeContainer attributes()
-
getAttributes
@Deprecated public List<Attribute> getAttributes()
Deprecated.use attributes()Description copied from interface:GridDatatypeGet a List of Attribute specific to the Grid- Specified by:
getAttributesin interfaceGridDatatype- Returns:
- a List of Attribute
-
getVariable
public VariableDS getVariable()
Description copied from interface:GridDatatypeGet the underlying Variable, if it exists.- Specified by:
getVariablein interfaceGridDatatype- Returns:
- the underlying Variable, if it exists, else null
-
getFullName
public String getFullName()
Description copied from interface:GridDatatypeGet the full, unescaped name of the Grid- Specified by:
getFullNamein interfaceGridDatatype- Returns:
- the full, unescaped name of the Grid
-
getName
public String getName()
Description copied from interface:NamedObjectGet the object's name- Specified by:
getNamein interfaceGridDatatype- Specified by:
getNamein interfaceNamedObject- Returns:
- object's name
-
getShortName
public String getShortName()
Description copied from interface:GridDatatypeGet the short name of the Grid- Specified by:
getShortNamein interfaceGridDatatype- Returns:
- the short name of the Grid
-
getCoordinateSystem
public GridCoordSystem getCoordinateSystem()
get the GridCoordSys for this GeoGrid.- Specified by:
getCoordinateSystemin 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:
getProjectionin 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:
getDescriptionin interfaceGridDatatype- Specified by:
getDescriptionin interfaceNamedObject- Returns:
- object's description
-
getValue
public Object getValue()
- Specified by:
getValuein interfaceNamedObject
-
getUnitsString
public String getUnitsString()
get the unit as a string- Specified by:
getUnitsStringin 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:
hasMissingDatain 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:
isMissingDatain interfaceGridDatatype- Parameters:
val- test this value- Returns:
- true if val is missing data
-
hasMissing
public boolean hasMissing()
Description copied from interface:IsMissingEvaluatortrue if there may be missing data- Specified by:
hasMissingin interfaceIsMissingEvaluator- Returns:
- true if there may be missing data
-
isMissing
public boolean isMissing(double val)
Description copied from interface:IsMissingEvaluatorif val is a missing data value- Specified by:
isMissingin 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:
setMissingToNaNin 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:
getMinMaxSkipMissingDatain 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:
readVolumeDatain 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:
readDataSlicein 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:
readDataSlicein 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:
readSubsetin interfaceGridDatatype- Throws:
InvalidRangeExceptionIOException
-
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:GridDatatypeCreate a new GeoGrid that is a logical subset of this GeoGrid. For backwards compatibility for grids with no runtime or ensemble dimensions.- Specified by:
makeSubsetin 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:GridDatatypeCreate a new GeoGrid that is a logical subset of this GeoGrid.- Specified by:
makeSubsetin 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:
getInfoin interfaceGridDatatype- Returns:
- human readable information about this Grid.
-
compareTo
public int compareTo(GridDatatype g)
- Specified by:
compareToin interfaceComparable<GridDatatype>
-
-