Package ucar.nc2.dataset
Class CoordinateSystem
- java.lang.Object
-
- ucar.nc2.dataset.CoordinateSystem
-
- Direct Known Subclasses:
GridCoordSys
public class CoordinateSystem extends Object
A CoordinateSystem specifies the coordinates of a Variable's values. Mathematically it is a vector function F from index space to Sn:F(i,j,k,...) -> (S1, S2, ...Sn) where i,j,k are integers, and S is the set of reals (R) or Strings.
The components of F are just its coordinate axes:F = (A1, A2, ...An) A1(i,j,k,...) -> S1 A2(i,j,k,...) -> S2 An(i,j,k,...) -> Sn
Concretely, a CoordinateSystem is a set of coordinate axes, and an optional set of coordinate transforms. The domain rank of F is the number of dimensions it is a function of. The range rank is the number of coordinate axes.An important class of CoordinateSystems are georeferencing Coordinate Systems, that locate a Variable's values in space and time. A CoordinateSystem that has a Lat and Lon axis, or a GeoX and GeoY axis and a Projection CoordinateTransform will have isGeoReferencing() true. A CoordinateSystem that has a Height, Pressure, or GeoZ axis will have hasVerticalAxis() true.
Further CoordinateSystems specialization is done by "data type specific" classes such as ucar.nc2.ft2.coverage.grid.GridCoordSys.
- See Also:
- Coordinate System Object Model
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
CoordinateSystem.Builder<T extends CoordinateSystem.Builder<T>>
-
Field Summary
Fields Modifier and Type Field Description protected CoordinateAxis
aziAxis
protected List<CoordinateAxis>
coordAxes
protected List<CoordinateTransform>
coordTrans
protected String
dataType
protected Set<Dimension>
domain
protected NetcdfDataset
ds
protected CoordinateAxis
elevAxis
protected CoordinateAxis
ensAxis
protected CoordinateAxis
hAxis
protected boolean
isImplicit
protected CoordinateAxis
latAxis
protected CoordinateAxis
lonAxis
protected String
name
protected CoordinateAxis
pAxis
protected CoordinateAxis
radialAxis
protected CoordinateAxis
tAxis
protected CoordinateAxis
xAxis
protected CoordinateAxis
yAxis
protected CoordinateAxis
zAxis
-
Constructor Summary
Constructors Modifier Constructor Description protected
CoordinateSystem()
Deprecated.Use CoordinateSystem.builder()protected
CoordinateSystem(CoordinateSystem.Builder<?> builder, NetcdfDataset ncd, List<CoordinateAxis> axes, List<CoordinateTransform> allTransforms)
CoordinateSystem(NetcdfDataset ds, Collection<CoordinateAxis> axes, Collection<CoordinateTransform> coordTrans)
Deprecated.Use CoordinateSystem.builder()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addCoordinateTransform(CoordinateTransform ct)
Deprecated.Use CoordinateSystem.builder()void
addCoordinateTransforms(Collection<CoordinateTransform> ct)
Deprecated.Use CoordinateSystem.builder()protected CoordinateSystem.Builder<?>
addLocalFieldsToBuilder(CoordinateSystem.Builder<? extends CoordinateSystem.Builder<?>> b)
static CoordinateSystem.Builder<?>
builder()
Get Builder for this class that allows subclassing.boolean
containsAxes(List<CoordinateAxis> wantAxes)
Do we have all the axes in the list?boolean
containsAxis(String axisName)
Do we have the named axis?boolean
containsAxisType(AxisType wantAxisType)
Do we have an axes of the given type?boolean
containsAxisTypes(List<AxisType> wantAxes)
Do we have all the axes types in the list?boolean
containsDomain(List<Dimension> wantDimensions)
Do we have all the dimensions in the list?static int
countDomain(Variable[] axes)
boolean
equals(Object oo)
Instances which have same name, axes and transforms are equal.CoordinateAxis
findAxis(AxisType type)
Find the CoordinateAxis that has the given AxisType.CoordinateAxis
getAzimuthAxis()
get the CoordinateAxis with AxisType.RadialAzimuth, or null if none.com.google.common.collect.ImmutableList<CoordinateAxis>
getCoordinateAxes()
Get the List of CoordinateAxis objectscom.google.common.collect.ImmutableList<CoordinateTransform>
getCoordinateTransforms()
Get the List of CoordinateTransform objectscom.google.common.collect.ImmutableCollection<Dimension>
getDomain()
get the Collection of Dimensions that constitute the domain.CoordinateAxis
getElevationAxis()
get the CoordinateAxis with AxisType.RadialElevation, or null if none.CoordinateAxis
getEnsembleAxis()
get the CoordinateAxis with AxisType.Ensemble, or null if none.CoordinateAxis
getHeightAxis()
get the CoordinateAxis with AxisType.Height, or null if none.CoordinateAxis
getLatAxis()
get the CoordinateAxis with AxisType.Lat, or null if none.CoordinateAxis
getLonAxis()
get the CoordinateAxis with AxisType.Lon, or null if none.String
getName()
get the name of the Coordinate SystemNetcdfDataset
getNetcdfDataset()
Get the underlying NetcdfDatasetCoordinateAxis
getPressureAxis()
get the CoordinateAxis with AxisType.Pressure, or null if none.ProjectionImpl
getProjection()
Get the Projection for this coordinate system.ProjectionCT
getProjectionCT()
Find the first ProjectionCT from the list of CoordinateTransforms.CoordinateAxis
getRadialAxis()
get the CoordinateAxis with AxisType.RadialDistance, or null if none.int
getRankDomain()
Get the domain rank of the coordinate system = number of dimensions it is a function of.int
getRankRange()
Get the range rank of the coordinate system = number of coordinate axes.CoordinateAxis
getTaxis()
get the CoordinateAxis with AxisType.Time, or null if none.CoordinateAxis
getXaxis()
get the CoordinateAxis with AxisType.GeoX, or null if none.CoordinateAxis
getYaxis()
get the CoordinateAxis with AxisType.GeoY, or null if none.CoordinateAxis
getZaxis()
get the CoordinateAxis with AxisType.GeoZ, or null if none.int
hashCode()
Override Object.hashCode() to implement equals.boolean
hasTimeAxis()
true if has Time axisboolean
hasVerticalAxis()
true if has Height, Pressure, or GeoZ axisboolean
isComplete(Variable v)
Check if this Coordinate System is complete for v, ie if all its dimensions are also used by v.boolean
isCoordinateSystemFor(Variable v)
Check if this Coordinate System can be used for the given variable.boolean
isGeoReferencing()
true if isGeoXY or isLatLonboolean
isGeoXY()
true if it has X and Y CoordinateAxis, and a CoordTransform Projectionboolean
isImplicit()
Implicit Coordinate System are constructed based on which Coordinate Variables exist for the Dimensions of the Variable.boolean
isLatLon()
true if it has Lat and Lon CoordinateAxisboolean
isProductSet()
true if all axes are CoordinateAxis1Dboolean
isRadial()
true if it has radial distance and azimuth CoordinateAxisboolean
isRegular()
true if all axes are CoordinateAxis1D and are regularstatic boolean
isSubset(Collection<Dimension> subset, Collection<Dimension> set)
Test if all the Dimensions in subset are in setstatic boolean
isSubset(Set<String> subset, Set<String> set)
static Set<Dimension>
makeDomain(Iterable<? extends Variable> axes)
static String
makeName(List<CoordinateAxis> axes)
Create standard name from list of axes.protected void
setImplicit(boolean isImplicit)
Deprecated.Use CoordinateSystem.builder()CoordinateSystem.Builder<?>
toBuilder()
String
toString()
-
-
-
Field Detail
-
ds
protected NetcdfDataset ds
-
coordAxes
protected List<CoordinateAxis> coordAxes
-
coordTrans
protected List<CoordinateTransform> coordTrans
-
name
protected String name
-
xAxis
protected CoordinateAxis xAxis
-
yAxis
protected CoordinateAxis yAxis
-
zAxis
protected CoordinateAxis zAxis
-
tAxis
protected CoordinateAxis tAxis
-
latAxis
protected CoordinateAxis latAxis
-
lonAxis
protected CoordinateAxis lonAxis
-
hAxis
protected CoordinateAxis hAxis
-
pAxis
protected CoordinateAxis pAxis
-
ensAxis
protected CoordinateAxis ensAxis
-
aziAxis
protected CoordinateAxis aziAxis
-
elevAxis
protected CoordinateAxis elevAxis
-
radialAxis
protected CoordinateAxis radialAxis
-
isImplicit
protected boolean isImplicit
-
dataType
protected String dataType
-
-
Constructor Detail
-
CoordinateSystem
@Deprecated protected CoordinateSystem()
Deprecated.Use CoordinateSystem.builder()
-
CoordinateSystem
@Deprecated public CoordinateSystem(NetcdfDataset ds, Collection<CoordinateAxis> axes, Collection<CoordinateTransform> coordTrans)
Deprecated.Use CoordinateSystem.builder()Constructor.- Parameters:
ds
- the containing datasetaxes
- Collection of type CoordinateAxis, must be at least one.coordTrans
- Collection of type CoordinateTransform, may be empty or null.
-
CoordinateSystem
protected CoordinateSystem(CoordinateSystem.Builder<?> builder, NetcdfDataset ncd, List<CoordinateAxis> axes, List<CoordinateTransform> allTransforms)
-
-
Method Detail
-
makeName
public static String makeName(List<CoordinateAxis> axes)
Create standard name from list of axes. Sort the axes first- Parameters:
axes
- list of CoordinateAxis- Returns:
- CoordinateSystem name, created from axes names
-
addCoordinateTransform
@Deprecated public void addCoordinateTransform(CoordinateTransform ct)
Deprecated.Use CoordinateSystem.builder()add a CoordinateTransform- Parameters:
ct
- add this CoordinateTransform
-
addCoordinateTransforms
@Deprecated public void addCoordinateTransforms(Collection<CoordinateTransform> ct)
Deprecated.Use CoordinateSystem.builder()add a Collection of CoordinateTransform- Parameters:
ct
- add all CoordinateTransform in this collection
-
getCoordinateAxes
public com.google.common.collect.ImmutableList<CoordinateAxis> getCoordinateAxes()
Get the List of CoordinateAxis objects
-
getCoordinateTransforms
public com.google.common.collect.ImmutableList<CoordinateTransform> getCoordinateTransforms()
Get the List of CoordinateTransform objects
-
getName
public String getName()
get the name of the Coordinate System- Returns:
- the name of the Coordinate System
-
getNetcdfDataset
public NetcdfDataset getNetcdfDataset()
Get the underlying NetcdfDataset- Returns:
- the underlying NetcdfDataset.
-
getDomain
public com.google.common.collect.ImmutableCollection<Dimension> getDomain()
get the Collection of Dimensions that constitute the domain.
-
getRankDomain
public int getRankDomain()
Get the domain rank of the coordinate system = number of dimensions it is a function of.- Returns:
- domain.size()
-
getRankRange
public int getRankRange()
Get the range rank of the coordinate system = number of coordinate axes.- Returns:
- coordAxes.size()
-
findAxis
public CoordinateAxis findAxis(AxisType type)
Find the CoordinateAxis that has the given AxisType. If more than one, return the one with lesser rank.- Parameters:
type
- look for this axisType- Returns:
- CoordinateAxis of the given AxisType, else null.
-
getXaxis
public CoordinateAxis getXaxis()
get the CoordinateAxis with AxisType.GeoX, or null if none. if more than one, choose one with smallest rank- Returns:
- axis of type AxisType.GeoX, or null if none
-
getYaxis
public CoordinateAxis getYaxis()
get the CoordinateAxis with AxisType.GeoY, or null if none. if more than one, choose one with smallest rank- Returns:
- axis of type AxisType.GeoY, or null if none
-
getZaxis
public CoordinateAxis getZaxis()
get the CoordinateAxis with AxisType.GeoZ, or null if none. if more than one, choose one with smallest rank- Returns:
- axis of type AxisType.GeoZ, or null if none
-
getTaxis
public CoordinateAxis getTaxis()
get the CoordinateAxis with AxisType.Time, or null if none. if more than one, choose one with smallest rank- Returns:
- axis of type AxisType.Time, or null if none
-
getLatAxis
public CoordinateAxis getLatAxis()
get the CoordinateAxis with AxisType.Lat, or null if none. if more than one, choose one with smallest rank- Returns:
- axis of type AxisType.Lat, or null if none
-
getLonAxis
public CoordinateAxis getLonAxis()
get the CoordinateAxis with AxisType.Lon, or null if none. if more than one, choose one with smallest rank *- Returns:
- axis of type AxisType.Lon, or null if none
-
getHeightAxis
public CoordinateAxis getHeightAxis()
get the CoordinateAxis with AxisType.Height, or null if none. if more than one, choose one with smallest rank- Returns:
- axis of type AxisType.Height, or null if none
-
getPressureAxis
public CoordinateAxis getPressureAxis()
get the CoordinateAxis with AxisType.Pressure, or null if none. if more than one, choose one with smallest rank.- Returns:
- axis of type AxisType.Pressure, or null if none
-
getEnsembleAxis
public CoordinateAxis getEnsembleAxis()
get the CoordinateAxis with AxisType.Ensemble, or null if none. if more than one, choose one with smallest rank.- Returns:
- axis of type AxisType.Ensemble, or null if none
-
getAzimuthAxis
public CoordinateAxis getAzimuthAxis()
get the CoordinateAxis with AxisType.RadialAzimuth, or null if none. if more than one, choose one with smallest rank- Returns:
- axis of type AxisType.RadialAzimuth, or null if none
-
getRadialAxis
public CoordinateAxis getRadialAxis()
get the CoordinateAxis with AxisType.RadialDistance, or null if none. if more than one, choose one with smallest rank- Returns:
- axis of type AxisType.RadialDistance, or null if none
-
getElevationAxis
public CoordinateAxis getElevationAxis()
get the CoordinateAxis with AxisType.RadialElevation, or null if none. if more than one, choose one with smallest rank- Returns:
- axis of type AxisType.RadialElevation, or null if none
-
getProjectionCT
public ProjectionCT getProjectionCT()
Find the first ProjectionCT from the list of CoordinateTransforms.- Returns:
- ProjectionCT or null if none.
-
getProjection
public ProjectionImpl getProjection()
Get the Projection for this coordinate system. If isLatLon(), then returns a LatLonProjection. Otherwise, extracts the projection from any ProjectionCT CoordinateTransform.- Returns:
- ProjectionImpl or null if none. TODO return Projection in ver6
-
isGeoXY
public boolean isGeoXY()
true if it has X and Y CoordinateAxis, and a CoordTransform Projection- Returns:
- true if it has X and Y CoordinateAxis, and a CoordTransform Projection
-
isLatLon
public boolean isLatLon()
true if it has Lat and Lon CoordinateAxis- Returns:
- true if it has Lat and Lon CoordinateAxis
-
isRadial
public boolean isRadial()
true if it has radial distance and azimuth CoordinateAxis- Returns:
- true if it has radial distance and azimuth CoordinateAxis
-
isGeoReferencing
public boolean isGeoReferencing()
true if isGeoXY or isLatLon- Returns:
- true if isGeoXY or isLatLon
-
isProductSet
public boolean isProductSet()
true if all axes are CoordinateAxis1D- Returns:
- true if all axes are CoordinateAxis1D
-
isRegular
public boolean isRegular()
true if all axes are CoordinateAxis1D and are regular- Returns:
- true if all axes are CoordinateAxis1D and are regular
-
isComplete
public boolean isComplete(Variable v)
Check if this Coordinate System is complete for v, ie if all its dimensions are also used by v.- Parameters:
v
- check for this variable- Returns:
- true if all dimensions in V (including parents) are in the domain of this coordinate system.
-
isCoordinateSystemFor
public boolean isCoordinateSystemFor(Variable v)
Check if this Coordinate System can be used for the given variable. A CoordinateAxis can only be part of a Variable's CoordinateSystem if the CoordinateAxis' set of Dimensions is a subset of the Variable's set of Dimensions. So, a CoordinateSystem' set of Dimensions must be a subset of the Variable's set of Dimensions.- Parameters:
v
- check for this variable- Returns:
- true if all dimensions in the domain of this coordinate system are in V (including parents).
-
isSubset
public static boolean isSubset(Collection<Dimension> subset, Collection<Dimension> set)
Test if all the Dimensions in subset are in set- Parameters:
subset
- is this a subsetset
- of this?- Returns:
- true if all the Dimensions in subset are in set
-
countDomain
public static int countDomain(Variable[] axes)
-
isImplicit
public boolean isImplicit()
Implicit Coordinate System are constructed based on which Coordinate Variables exist for the Dimensions of the Variable. This is in contrast to a Coordinate System that is explicitly specified in the file.- Returns:
- true if this coordinate system was constructed implicitly.
-
setImplicit
@Deprecated protected void setImplicit(boolean isImplicit)
Deprecated.Use CoordinateSystem.builder()Set whether this Coordinate System is implicit- Parameters:
isImplicit
- true if constructed implicitly.
-
hasVerticalAxis
public boolean hasVerticalAxis()
true if has Height, Pressure, or GeoZ axis- Returns:
- true if has a vertical axis
-
hasTimeAxis
public boolean hasTimeAxis()
true if has Time axis- Returns:
- true if has Time axis
-
containsAxes
public boolean containsAxes(List<CoordinateAxis> wantAxes)
Do we have all the axes in the list?- Parameters:
wantAxes
- List of CoordinateAxis- Returns:
- true if all in our list.
-
containsAxis
public boolean containsAxis(String axisName)
Do we have the named axis?- Parameters:
axisName
- (full unescaped) name of axis- Returns:
- true if we have an axis of that name
-
containsDomain
public boolean containsDomain(List<Dimension> wantDimensions)
Do we have all the dimensions in the list?- Parameters:
wantDimensions
- List of Dimensions- Returns:
- true if all in our list.
-
containsAxisTypes
public boolean containsAxisTypes(List<AxisType> wantAxes)
Do we have all the axes types in the list?- Parameters:
wantAxes
- List of AxisType- Returns:
- true if all in our list.
-
containsAxisType
public boolean containsAxisType(AxisType wantAxisType)
Do we have an axes of the given type?- Parameters:
wantAxisType
- want this AxisType- Returns:
- true if we have at least one axis of that type.
-
equals
public boolean equals(Object oo)
Instances which have same name, axes and transforms are equal.
-
hashCode
public int hashCode()
Override Object.hashCode() to implement equals.
-
toBuilder
public CoordinateSystem.Builder<?> toBuilder()
-
addLocalFieldsToBuilder
protected CoordinateSystem.Builder<?> addLocalFieldsToBuilder(CoordinateSystem.Builder<? extends CoordinateSystem.Builder<?>> b)
-
builder
public static CoordinateSystem.Builder<?> builder()
Get Builder for this class that allows subclassing.- See Also:
- "https://community.oracle.com/blogs/emcmanus/2010/10/24/using-builder-pattern-subclasses"
-
-