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 intfindTimeIndexFromDate(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.ProjectionRectgetBoundingBox()Get the x,y bounding box in projection coordinates.CalendarDateRangegetCalendarDateRange()List<CalendarDate>getCalendarDates()DateRangegetDateRange()Deprecated.use getCalendarDateRangeCoordinateAxis1DgetEnsembleAxis()get the Ensemble axis, else nullStringgetHorizStaggerType()LatLonPointgetLatLon(double xcoord, double ycoord)LatLonPointgetLatLon(int xindex, int yindex)Get the Lat/Lon coordinates of the midpoint of a grid cell, using the x,y indicesLatLonRectgetLatLonBoundingBox()Get horizontal bounding box in lat, lon coordinates.List<Range>getLatLonBoundingBox(LatLonRect rect)Deprecated.use getRangesFromLatLonRect.static LatLonRectgetLatLonBoundingBox(Projection proj, double startx, double starty, double endx, double endy)Deprecated.use Projection.projToLatlonBBintgetLevelIndex(String name)Get the index corresponding to the level name.StringgetLevelName(int index)Get the String name for the ith level(z) coordinate.List<NamedObject>getLevels()Deprecated.will move in ver 6ProjectionImplgetProjection()get the projectionList<Range>getRangesFromLatLonRect(LatLonRect rect)Get Index Ranges for the given lat, lon bounding box.CoordinateAxis1DTimegetRunTimeAxis()get the RunTime axis, else nullCoordinateAxisgetTimeAxis()get the Time axisCoordinateAxis1DTimegetTimeAxis1D()get the Time axis, if its 1-dimensionalCoordinateAxis1DTimegetTimeAxisForRun(int run_index)Deprecated.doesnt work correctly for intervalsDate[]getTimeDates()Deprecated.use getCalendarDatesintgetTimeIndex(String name)Deprecated.StringgetTimeName(int index)Deprecated.List<NamedObject>getTimes()Deprecated.will move in ver 6CoordinateAxis1DgetVerticalAxis()get the Vertical axis (either Geoz, Height, or Pressure)VerticalCTgetVerticalCT()Get the Coordinate Transform description.VerticalTransformgetVerticalTransform()Get the vertical transform function, or null if noneCoordinateAxisgetXHorizAxis()get the X Horizontal axis (either GeoX or Lon)CoordinateAxisgetYHorizAxis()get the Y Horizontal axis (either GeoY or Lat)booleanhasTimeAxis()True if there is a Time Axis.booleanhasTimeAxis1D()True if there is a Time Axis and it is 1D.booleanisGlobalLon()Is this a global coverage over longitude ?static booleanisGridCoordSys(Formatter sbuff, CoordinateSystem cs, VariableEnhanced ve)Determine if this CoordinateSystem can be made into a GridCoordSys.booleanisLatLon()is this a Lat/Lon coordinate system?booleanisRegularSpatial()true if x and y axes are CoordinateAxis1D and are regularbooleanisZPositive()true if increasing z coordinate values means "up" in altitudestatic GridCoordSysmakeGridCoordSys(Formatter sbuff, CoordinateSystem cs, VariableEnhanced v)Determine if the CoordinateSystem cs can be made into a GridCoordSys for the Variable v.voidsetHorizStaggerType(String horizStaggerType)voidsetProjectionBoundingBox()Use the bounding box to set the defaule map are of the projection.voidshow(Formatter f, boolean showCoords)StringtoString()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:
getVerticalTransformin interfaceGridCoordSystem- Returns:
- the vertical transform function, or null if none
-
getVerticalCT
public VerticalCT getVerticalCT()
Get the Coordinate Transform description.- Specified by:
getVerticalCTin interfaceGridCoordSystem- Returns:
- Coordinate Transform description, or null if none
-
getXHorizAxis
public CoordinateAxis getXHorizAxis()
get the X Horizontal axis (either GeoX or Lon)- Specified by:
getXHorizAxisin interfaceGridCoordSystem- Returns:
- X CoordinateAxis, may not be null.
-
getYHorizAxis
public CoordinateAxis getYHorizAxis()
get the Y Horizontal axis (either GeoY or Lat)- Specified by:
getYHorizAxisin interfaceGridCoordSystem- Returns:
- Y CoordinateAxis, may not be null.
-
getVerticalAxis
public CoordinateAxis1D getVerticalAxis()
get the Vertical axis (either Geoz, Height, or Pressure)- Specified by:
getVerticalAxisin interfaceGridCoordSystem- Returns:
- Y CoordinateAxis, may be null.
-
getTimeAxis
public CoordinateAxis getTimeAxis()
get the Time axis- Specified by:
getTimeAxisin interfaceGridCoordSystem- Returns:
- the time coordinate axis, may be null.
-
getTimeAxis1D
public CoordinateAxis1DTime getTimeAxis1D()
get the Time axis, if its 1-dimensional- Specified by:
getTimeAxis1Din interfaceGridCoordSystem- Returns:
- the time coordinate axis, may be null.
-
getRunTimeAxis
public CoordinateAxis1DTime getRunTimeAxis()
get the RunTime axis, else null- Specified by:
getRunTimeAxisin interfaceGridCoordSystem- Returns:
- RunTime CoordinateAxis, may be null.
-
getEnsembleAxis
public CoordinateAxis1D getEnsembleAxis()
get the Ensemble axis, else null- Specified by:
getEnsembleAxisin interfaceGridCoordSystem- Overrides:
getEnsembleAxisin classCoordinateSystem- Returns:
- axis of type AxisType.Ensemble, or null if none
-
getProjection
public ProjectionImpl getProjection()
get the projection- Specified by:
getProjectionin interfaceGridCoordSystem- Overrides:
getProjectionin classCoordinateSystem- Returns:
- ProjectionImpl or null if none. TODO return Projection in ver6
-
setProjectionBoundingBox
public void setProjectionBoundingBox()
Description copied from interface:GridCoordSystemUse the bounding box to set the defaule map are of the projection. This can be expensive if its a 2D coordinate system.- Specified by:
setProjectionBoundingBoxin interfaceGridCoordSystem
-
isLatLon
public boolean isLatLon()
is this a Lat/Lon coordinate system?- Specified by:
isLatLonin interfaceGridCoordSystem- Overrides:
isLatLonin classCoordinateSystem- Returns:
- true if it has Lat and Lon CoordinateAxis
-
isGlobalLon
public boolean isGlobalLon()
Is this a global coverage over longitude ?- Specified by:
isGlobalLonin interfaceGridCoordSystem- Returns:
- true if isLatLon and longitude wraps
-
isZPositive
public boolean isZPositive()
true if increasing z coordinate values means "up" in altitude- Specified by:
isZPositivein 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:
isRegularSpatialin interfaceGridCoordSystem- Returns:
- true if both X and Y axes are 1 dimensional and are regularly spaced.
-
getHorizStaggerType
public String getHorizStaggerType()
- Specified by:
getHorizStaggerTypein 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:
findXYindexFromCoordin 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:
findXYindexFromCoordBoundedin 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:
findXYindexFromLatLonin 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:
findXYindexFromLatLonBoundedin 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:
hasTimeAxisin interfaceGridCoordSystem- Overrides:
hasTimeAxisin classCoordinateSystem- Returns:
- true if has Time axis
-
hasTimeAxis1D
public boolean hasTimeAxis1D()
True if there is a Time Axis and it is 1D.- Specified by:
hasTimeAxis1Din 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:GridCoordSystemThis 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:
getTimeAxisForRunin 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:
getBoundingBoxin 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:
getLatLonin 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:
getLatLonBoundingBoxin 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:
getRangesFromLatLonRectin 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:
toStringin classCoordinateSystem
-
show
public void show(Formatter f, boolean showCoords)
- Specified by:
showin interfaceGridCoordSystem
-
getCalendarDates
public List<CalendarDate> getCalendarDates()
- Specified by:
getCalendarDatesin interfaceGridCoordSystem
-
getCalendarDateRange
public CalendarDateRange getCalendarDateRange()
- Specified by:
getCalendarDateRangein 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:
getDateRangein 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
-
-