Package ucar.nc2.dt.grid
Class GridCoordSys
- java.lang.Object
-
- ucar.nc2.dataset.CoordinateSystem
-
- ucar.nc2.dt.grid.GridCoordSys
-
- All Implemented Interfaces:
GridCoordSystem
public class GridCoordSys extends CoordinateSystem implements GridCoordSystem
A georeferencing "gridded" CoordinateSystem. This describes a "grid" of coordinates, which implies a connected topology such that values next to each other in index space are next to each other in coordinate space. This currently assumes that the CoordinateSystem- is georeferencing (has Lat, Lon or GeoX, GeoY axes)
- x, y are 1 or 2-dimensional axes.
- rt, z, e are 1-dimensional axes.
- t is 1 or 2 dimensional. if 2d, then rt exists
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class ucar.nc2.dataset.CoordinateSystem
CoordinateSystem.Builder<T extends CoordinateSystem.Builder<T>>
-
-
Field Summary
-
Fields inherited from class ucar.nc2.dataset.CoordinateSystem
aziAxis, coordAxes, coordTrans, dataType, domain, ds, elevAxis, ensAxis, hAxis, isImplicit, latAxis, lonAxis, name, pAxis, radialAxis, tAxis, xAxis, yAxis, zAxis
-
-
Constructor Summary
Constructors Constructor Description GridCoordSys(CoordinateSystem cs, Formatter sbuff)
Create a GridCoordSys from an existing Coordinate System.GridCoordSys(GridCoordSys from, Range t_range, Range z_range, Range y_range, Range x_range)
Create a GridCoordSys as a section of an existing GridCoordSys.GridCoordSys(GridCoordSys from, Range rt_range, Range e_range, Range t_range, Range z_range, Range y_range, Range x_range)
Create a GridCoordSys as a section of an existing GridCoordSys.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description int
findTimeIndexFromDate(Date d)
Deprecated.use CoordinateAxis1DTime.findTimeIndexFromDateint[]
findXYCoordElement(double x_coord, double y_coord, int[] result)
Deprecated.use findXYindexFromCoordint[]
findXYindexFromCoord(double x_coord, double y_coord, int[] result)
Given a point in x,y coordinate space, find the x,y index in the coordinate system.int[]
findXYindexFromCoordBounded(double x_coord, double y_coord, int[] result)
Given a point in x,y coordinate space, find the x,y index in the coordinate system.int[]
findXYindexFromLatLon(double lat, double lon, int[] result)
Given a lat,lon point, find the x,y index in the coordinate system.int[]
findXYindexFromLatLonBounded(double lat, double lon, int[] result)
Given a lat,lon point, find the x,y index in the coordinate system.ProjectionRect
getBoundingBox()
Get the x,y bounding box in projection coordinates.CalendarDateRange
getCalendarDateRange()
List<CalendarDate>
getCalendarDates()
DateRange
getDateRange()
Deprecated.use getCalendarDateRangeCoordinateAxis1D
getEnsembleAxis()
get the Ensemble axis, else nullString
getHorizStaggerType()
LatLonPoint
getLatLon(double xcoord, double ycoord)
LatLonPoint
getLatLon(int xindex, int yindex)
Get the Lat/Lon coordinates of the midpoint of a grid cell, using the x,y indicesLatLonRect
getLatLonBoundingBox()
Get horizontal bounding box in lat, lon coordinates.List<Range>
getLatLonBoundingBox(LatLonRect rect)
Deprecated.use getRangesFromLatLonRect.static LatLonRect
getLatLonBoundingBox(Projection proj, double startx, double starty, double endx, double endy)
Deprecated.use Projection.projToLatlonBBint
getLevelIndex(String name)
Get the index corresponding to the level name.String
getLevelName(int index)
Get the String name for the ith level(z) coordinate.List<NamedObject>
getLevels()
Deprecated.will move in ver 6ProjectionImpl
getProjection()
get the projectionList<Range>
getRangesFromLatLonRect(LatLonRect rect)
Get Index Ranges for the given lat, lon bounding box.CoordinateAxis1DTime
getRunTimeAxis()
get the RunTime axis, else nullCoordinateAxis
getTimeAxis()
get the Time axisCoordinateAxis1DTime
getTimeAxis1D()
get the Time axis, if its 1-dimensionalCoordinateAxis1DTime
getTimeAxisForRun(int run_index)
Deprecated.doesnt work correctly for intervalsDate[]
getTimeDates()
Deprecated.use getCalendarDatesint
getTimeIndex(String name)
Deprecated.String
getTimeName(int index)
Deprecated.List<NamedObject>
getTimes()
Deprecated.will move in ver 6CoordinateAxis1D
getVerticalAxis()
get the Vertical axis (either Geoz, Height, or Pressure)VerticalCT
getVerticalCT()
Get the Coordinate Transform description.VerticalTransform
getVerticalTransform()
Get the vertical transform function, or null if noneCoordinateAxis
getXHorizAxis()
get the X Horizontal axis (either GeoX or Lon)CoordinateAxis
getYHorizAxis()
get the Y Horizontal axis (either GeoY or Lat)boolean
hasTimeAxis()
True if there is a Time Axis.boolean
hasTimeAxis1D()
True if there is a Time Axis and it is 1D.boolean
isGlobalLon()
Is this a global coverage over longitude ?static boolean
isGridCoordSys(Formatter sbuff, CoordinateSystem cs, VariableEnhanced ve)
Determine if this CoordinateSystem can be made into a GridCoordSys.boolean
isLatLon()
is this a Lat/Lon coordinate system?boolean
isRegularSpatial()
true if x and y axes are CoordinateAxis1D and are regularboolean
isZPositive()
true if increasing z coordinate values means "up" in altitudestatic GridCoordSys
makeGridCoordSys(Formatter sbuff, CoordinateSystem cs, VariableEnhanced v)
Determine if the CoordinateSystem cs can be made into a GridCoordSys for the Variable v.void
setHorizStaggerType(String horizStaggerType)
void
setProjectionBoundingBox()
Use the bounding box to set the defaule map are of the projection.void
show(Formatter f, boolean showCoords)
String
toString()
String representation.-
Methods inherited from class ucar.nc2.dataset.CoordinateSystem
addCoordinateTransform, addCoordinateTransforms, addLocalFieldsToBuilder, builder, containsAxes, containsAxis, containsAxisType, containsAxisTypes, containsDomain, countDomain, equals, findAxis, getAzimuthAxis, getCoordinateAxes, getCoordinateTransforms, getDomain, getElevationAxis, getHeightAxis, getLatAxis, getLonAxis, getName, getNetcdfDataset, getPressureAxis, getProjectionCT, getRadialAxis, getRankDomain, getRankRange, getTaxis, getXaxis, getYaxis, getZaxis, hashCode, hasVerticalAxis, isComplete, isCoordinateSystemFor, isGeoReferencing, isGeoXY, isImplicit, isProductSet, isRadial, isRegular, isSubset, isSubset, makeDomain, makeName, setImplicit, toBuilder
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface ucar.nc2.dt.GridCoordSystem
getCoordinateAxes, getCoordinateTransforms, getDomain, getName, getProjectionCT, isProductSet
-
-
-
-
Constructor Detail
-
GridCoordSys
public GridCoordSys(CoordinateSystem cs, Formatter sbuff)
Create a GridCoordSys from an existing Coordinate System. This will choose which axes are the XHoriz, YHoriz, Vertical, Time, RunTIme, Ensemble. If theres a Projection, it will set its map area- Parameters:
cs
- create from this Coordinate Systemsbuff
- place information messages here, may be null
-
GridCoordSys
public GridCoordSys(GridCoordSys from, Range t_range, Range z_range, Range y_range, Range x_range) throws InvalidRangeException
Create a GridCoordSys as a section of an existing GridCoordSys. This will create sections of the corresponding CoordinateAxes.- Parameters:
from
- copy this GridCoordSyst_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- Throws:
InvalidRangeException
- if any of the ranges are illegal
-
GridCoordSys
public GridCoordSys(GridCoordSys from, Range rt_range, Range e_range, Range t_range, Range z_range, Range y_range, Range x_range) throws InvalidRangeException
Create a GridCoordSys as a section of an existing GridCoordSys. This will create sections of the corresponding CoordinateAxes.- Parameters:
from
- copy this GridCoordSysrt_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- Throws:
InvalidRangeException
- if any of the ranges are illegal
-
-
Method Detail
-
isGridCoordSys
public static boolean isGridCoordSys(Formatter sbuff, CoordinateSystem cs, VariableEnhanced ve)
Determine if this CoordinateSystem can be made into a GridCoordSys. Optionally for a given variable. This currently assumes that the CoordinateSystem:- is georeferencing (cs.isGeoReferencing())
- x, y are 1 or 2-dimensional axes.
- z, t, if they exist, are 1-dimensional axes.
- domain rank > 1
- Parameters:
sbuff
- place information messages here, may be nullcs
- the CoordinateSystem to testve
- can it be used for this variable; v may be null- Returns:
- true if it can be made into a GridCoordSys.
- See Also:
CoordinateSystem.isGeoReferencing()
-
makeGridCoordSys
public static GridCoordSys makeGridCoordSys(Formatter sbuff, CoordinateSystem cs, VariableEnhanced v)
Determine if the CoordinateSystem cs can be made into a GridCoordSys for the Variable v.- Parameters:
sbuff
- put debug information into this StringBuffer; may be null.cs
- CoordinateSystem to check.v
- Variable to check.- Returns:
- the GridCoordSys made from cs, else null.
-
getVerticalTransform
public VerticalTransform getVerticalTransform()
Get the vertical transform function, or null if none- Specified by:
getVerticalTransform
in interfaceGridCoordSystem
- Returns:
- the vertical transform function, or null if none
-
getVerticalCT
public VerticalCT getVerticalCT()
Get the Coordinate Transform description.- Specified by:
getVerticalCT
in interfaceGridCoordSystem
- Returns:
- Coordinate Transform description, or null if none
-
getXHorizAxis
public CoordinateAxis getXHorizAxis()
get the X Horizontal axis (either GeoX or Lon)- Specified by:
getXHorizAxis
in interfaceGridCoordSystem
- Returns:
- X CoordinateAxis, may not be null.
-
getYHorizAxis
public CoordinateAxis getYHorizAxis()
get the Y Horizontal axis (either GeoY or Lat)- Specified by:
getYHorizAxis
in interfaceGridCoordSystem
- Returns:
- Y CoordinateAxis, may not be null.
-
getVerticalAxis
public CoordinateAxis1D getVerticalAxis()
get the Vertical axis (either Geoz, Height, or Pressure)- Specified by:
getVerticalAxis
in interfaceGridCoordSystem
- Returns:
- Y CoordinateAxis, may be null.
-
getTimeAxis
public CoordinateAxis getTimeAxis()
get the Time axis- Specified by:
getTimeAxis
in interfaceGridCoordSystem
- Returns:
- the time coordinate axis, may be null.
-
getTimeAxis1D
public CoordinateAxis1DTime getTimeAxis1D()
get the Time axis, if its 1-dimensional- Specified by:
getTimeAxis1D
in interfaceGridCoordSystem
- Returns:
- the time coordinate axis, may be null.
-
getRunTimeAxis
public CoordinateAxis1DTime getRunTimeAxis()
get the RunTime axis, else null- Specified by:
getRunTimeAxis
in interfaceGridCoordSystem
- Returns:
- RunTime CoordinateAxis, may be null.
-
getEnsembleAxis
public CoordinateAxis1D getEnsembleAxis()
get the Ensemble axis, else null- Specified by:
getEnsembleAxis
in interfaceGridCoordSystem
- Overrides:
getEnsembleAxis
in classCoordinateSystem
- Returns:
- axis of type AxisType.Ensemble, or null if none
-
getProjection
public ProjectionImpl getProjection()
get the projection- Specified by:
getProjection
in interfaceGridCoordSystem
- Overrides:
getProjection
in classCoordinateSystem
- Returns:
- ProjectionImpl or null if none. TODO return Projection in ver6
-
setProjectionBoundingBox
public void setProjectionBoundingBox()
Description copied from interface:GridCoordSystem
Use the bounding box to set the defaule map are of the projection. This can be expensive if its a 2D coordinate system.- Specified by:
setProjectionBoundingBox
in interfaceGridCoordSystem
-
isLatLon
public boolean isLatLon()
is this a Lat/Lon coordinate system?- Specified by:
isLatLon
in interfaceGridCoordSystem
- Overrides:
isLatLon
in classCoordinateSystem
- Returns:
- true if it has Lat and Lon CoordinateAxis
-
isGlobalLon
public boolean isGlobalLon()
Is this a global coverage over longitude ?- Specified by:
isGlobalLon
in interfaceGridCoordSystem
- Returns:
- true if isLatLon and longitude wraps
-
isZPositive
public boolean isZPositive()
true if increasing z coordinate values means "up" in altitude- Specified by:
isZPositive
in interfaceGridCoordSystem
- Returns:
- true if increasing z coordinate values means "up" in altitude
-
isRegularSpatial
public boolean isRegularSpatial()
true if x and y axes are CoordinateAxis1D and are regular- Specified by:
isRegularSpatial
in interfaceGridCoordSystem
- Returns:
- true if both X and Y axes are 1 dimensional and are regularly spaced.
-
getHorizStaggerType
public String getHorizStaggerType()
- Specified by:
getHorizStaggerType
in interfaceGridCoordSystem
-
setHorizStaggerType
public void setHorizStaggerType(String horizStaggerType)
-
findXYindexFromCoord
public int[] findXYindexFromCoord(double x_coord, double y_coord, int[] result)
Given a point in x,y coordinate space, find the x,y index in the coordinate system.- Specified by:
findXYindexFromCoord
in interfaceGridCoordSystem
- Parameters:
x_coord
- position in x coordinate space.y_coord
- position in y coordinate space.result
- put result (x,y) index in here, may be null- Returns:
- int[2], 0=x,1=y indices in the coordinate system of the point. These will be -1 if out of range.
-
findXYindexFromCoordBounded
public int[] findXYindexFromCoordBounded(double x_coord, double y_coord, int[] result)
Given a point in x,y coordinate space, find the x,y index in the coordinate system. If outside the range, the closest point is returned, eg, 0 or n-1 depending on if the coordinate is too small or too large.- Specified by:
findXYindexFromCoordBounded
in interfaceGridCoordSystem
- Parameters:
x_coord
- position in x coordinate space.y_coord
- position in y coordinate space.result
- put result in here, may be null- Returns:
- int[2], 0=x,1=y indices in the coordinate system of the point.
-
findXYindexFromLatLon
public int[] findXYindexFromLatLon(double lat, double lon, int[] result)
Given a lat,lon point, find the x,y index in the coordinate system.- Specified by:
findXYindexFromLatLon
in interfaceGridCoordSystem
- Parameters:
lat
- latitude position.lon
- longitude position.result
- put result in here, may be null- Returns:
- int[2], 0=x,1=y indices in the coordinate system of the point. These will be -1 if out of range.
-
findXYindexFromLatLonBounded
public int[] findXYindexFromLatLonBounded(double lat, double lon, int[] result)
Given a lat,lon point, find the x,y index in the coordinate system. If outside the range, the closest point is returned- Specified by:
findXYindexFromLatLonBounded
in interfaceGridCoordSystem
- Parameters:
lat
- latitude position.lon
- longitude position.result
- put result in here, may be null- Returns:
- int[2], 0=x,1=y indices in the coordinate system of the point.
-
hasTimeAxis
public boolean hasTimeAxis()
True if there is a Time Axis.- Specified by:
hasTimeAxis
in interfaceGridCoordSystem
- Overrides:
hasTimeAxis
in classCoordinateSystem
- Returns:
- true if has Time axis
-
hasTimeAxis1D
public boolean hasTimeAxis1D()
True if there is a Time Axis and it is 1D.- Specified by:
hasTimeAxis1D
in interfaceGridCoordSystem
- Returns:
- true if there is a Time Axis and it is 1D.
-
getTimeAxisForRun
public CoordinateAxis1DTime getTimeAxisForRun(int run_index)
Deprecated.doesnt work correctly for intervalsDescription copied from interface:GridCoordSystem
This is the case of a 2D time axis, which depends on the run index. A time coordinate must be a udunit date or ISO String, so it can always be converted to a Date.- Specified by:
getTimeAxisForRun
in interfaceGridCoordSystem
- Parameters:
run_index
- which run?- Returns:
- 1D time axis for that run. Null if not 2D time
-
getBoundingBox
public ProjectionRect getBoundingBox()
Get the x,y bounding box in projection coordinates.- Specified by:
getBoundingBox
in interfaceGridCoordSystem
- Returns:
- ProjectionRect bounding box.
-
getLatLon
public LatLonPoint getLatLon(int xindex, int yindex)
Get the Lat/Lon coordinates of the midpoint of a grid cell, using the x,y indices- Specified by:
getLatLon
in interfaceGridCoordSystem
- Parameters:
xindex
- x indexyindex
- y index- Returns:
- lat/lon coordinate of the midpoint of the cell
-
getLatLon
public LatLonPoint getLatLon(double xcoord, double ycoord)
-
getLatLonBoundingBox
public LatLonRect getLatLonBoundingBox()
Get horizontal bounding box in lat, lon coordinates. If projection coordinates are used, the lat/ lon box is calculated from the perimeter of the projection coordinates box- Specified by:
getLatLonBoundingBox
in interfaceGridCoordSystem
- Returns:
- lat, lon bounding box.
-
getLatLonBoundingBox
public List<Range> getLatLonBoundingBox(LatLonRect rect) throws InvalidRangeException
Deprecated.use getRangesFromLatLonRect.Get Index Ranges for the given lat, lon bounding box.- Throws:
InvalidRangeException
-
getRangesFromLatLonRect
public List<Range> getRangesFromLatLonRect(LatLonRect rect) throws InvalidRangeException
Get Index Ranges for the given lat, lon bounding box. For projection, only an approximation based on latlon corners. Must have CoordinateAxis1D or 2D for x and y axis.- Specified by:
getRangesFromLatLonRect
in interfaceGridCoordSystem
- Parameters:
rect
- the requested lat/lon bounding box- Returns:
- list of 2 Range objects, first y then x.
- Throws:
InvalidRangeException
- if llbb generates bad ranges
-
toString
public String toString()
String representation.- Overrides:
toString
in classCoordinateSystem
-
show
public void show(Formatter f, boolean showCoords)
- Specified by:
show
in interfaceGridCoordSystem
-
getCalendarDates
public List<CalendarDate> getCalendarDates()
- Specified by:
getCalendarDates
in interfaceGridCoordSystem
-
getCalendarDateRange
public CalendarDateRange getCalendarDateRange()
- Specified by:
getCalendarDateRange
in interfaceGridCoordSystem
-
getLevels
@Deprecated public List<NamedObject> getLevels()
Deprecated.will move in ver 6Get the list of level names, to be used for user selection. The ith one refers to the ith level coordinate.- Returns:
- List of ucar.nc2.util.NamedObject, or empty list.
-
getLevelName
public String getLevelName(int index)
Get the String name for the ith level(z) coordinate.- Parameters:
index
- which level coordinate- Returns:
- level name
-
getLevelIndex
public int getLevelIndex(String name)
Get the index corresponding to the level name.- Parameters:
name
- level name- Returns:
- level index, or -1 if not found
-
getTimes
@Deprecated public List<NamedObject> getTimes()
Deprecated.will move in ver 6Get the list of time names, to be used for user selection. The ith one refers to the ith time coordinate.- Returns:
- List of ucar.nc2.util.NamedObject, or empty list.
-
findXYCoordElement
public int[] findXYCoordElement(double x_coord, double y_coord, int[] result)
Deprecated.use findXYindexFromCoordGiven a point in x,y coordinate space, find the x,y index in the coordinate system.
-
getDateRange
public DateRange getDateRange()
Deprecated.use getCalendarDateRangeGet the date range- Specified by:
getDateRange
in interfaceGridCoordSystem
- Returns:
- date range
-
getTimeDates
public Date[] getTimeDates()
Deprecated.use getCalendarDatesGet the list of times as Dates. If 2D, return list of unique dates.- Returns:
- array of java.util.Date, or Date[0].
-
getTimeName
public String getTimeName(int index)
Deprecated.Get the string name for the ith time coordinate.- Parameters:
index
- which time coordinate- Returns:
- time name.
-
getTimeIndex
public int getTimeIndex(String name)
Deprecated.Get the index corresponding to the time name.- Parameters:
name
- time name- Returns:
- time index, or -1 if not found
-
findTimeIndexFromDate
public int findTimeIndexFromDate(Date d)
Deprecated.use CoordinateAxis1DTime.findTimeIndexFromDateOnly works if coordsys has 1d time axis
-
getLatLonBoundingBox
@Deprecated public static LatLonRect getLatLonBoundingBox(Projection proj, double startx, double starty, double endx, double endy)
Deprecated.use Projection.projToLatlonBB
-
-