本文整理汇总了Java中ucar.nc2.dt.grid.GridCoordSys类的典型用法代码示例。如果您正苦于以下问题:Java GridCoordSys类的具体用法?Java GridCoordSys怎么用?Java GridCoordSys使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GridCoordSys类属于ucar.nc2.dt.grid包,在下文中一共展示了GridCoordSys类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getRangeValues
import ucar.nc2.dt.grid.GridCoordSys; //导入依赖的package包/类
/**
* Gets range values corresponding to range index.
*
* @param gcs grid coordinate system from which range is computed
* @param rangeLat latitude range
* @param rangeLon longitude range
* @param rangeValueLat latitude values corresponding to the range
* @param rangeValueLon longitude values corresponding to the range
*/
private void getRangeValues(GridCoordSys gcs, Range rangeLat, Range rangeLon, double[] rangeValueLat, double[] rangeValueLon)
throws MotuNotImplementedException {
// this is the case where no point are included
boolean hasLatRange = ExtractCriteriaLatLon.hasRange(rangeLat);
boolean hasLonRange = ExtractCriteriaLatLon.hasRange(rangeLon);
CoordinateAxis xaxis = gcs.getXHorizAxis();
CoordinateAxis yaxis = gcs.getYHorizAxis();
if ((xaxis instanceof CoordinateAxis1D) && (yaxis instanceof CoordinateAxis1D)) {
CoordinateAxis1D xaxis1 = (CoordinateAxis1D) xaxis;
CoordinateAxis1D yaxis1 = (CoordinateAxis1D) yaxis;
if ((rangeValueLat != null) && hasLatRange) {
rangeValueLat[0] = yaxis1.getCoordValue(rangeLat.first());
rangeValueLat[1] = yaxis1.getCoordValue(rangeLat.last());
}
if ((rangeValueLon != null) && hasLonRange) {
rangeValueLon[0] = xaxis1.getCoordValue(rangeLon.first());
rangeValueLon[1] = xaxis1.getCoordValue(rangeLon.last());
}
} else if ((xaxis instanceof CoordinateAxis2D) && (yaxis instanceof CoordinateAxis2D) && gcs.isLatLon()) {
CoordinateAxis2D lonAxis = (CoordinateAxis2D) xaxis;
CoordinateAxis2D latAxis = (CoordinateAxis2D) yaxis;
if ((rangeValueLat != null) && hasLatRange) {
rangeValueLat[0] = latAxis.getCoordValue(rangeLat.first(), rangeLon.first());
rangeValueLat[1] = latAxis.getCoordValue(rangeLat.last(), rangeLon.last());
}
if ((rangeValueLon != null) && hasLonRange) {
rangeValueLon[0] = lonAxis.getCoordValue(rangeLat.first(), rangeLon.first());
rangeValueLon[1] = lonAxis.getCoordValue(rangeLat.last(), rangeLon.last());
}
} else {
throw new MotuNotImplementedException(
"Coordinate axes that are not 1D or 2D/LatLon are not implemented in ExtractCriteriaLatLon.toRange");
}
}
示例2: getGridFromCoords
import ucar.nc2.dt.grid.GridCoordSys; //导入依赖的package包/类
private HorizontalGrid getGridFromCoords(String coord1, String coord2,
Map<String, CoordinateAxis> horizontalCoordinateAxes, NetcdfDataset nc) {
Collection<CoordinateAxis> axes = new ArrayList<>();
axes.add(horizontalCoordinateAxes.get(coord1.trim()));
axes.add(horizontalCoordinateAxes.get(coord2.trim()));
CoordinateSystem coordSys = new CoordinateSystem(nc, axes, null);
GridCoordSys gridCoordSys = new GridCoordSys(coordSys, null);
return CdmUtils.createHorizontalGrid(gridCoordSys);
}
示例3: toListRanges
import ucar.nc2.dt.grid.GridCoordSys; //导入依赖的package包/类
/**
* Gets a list of Index Ranges for the given lat, lon bounding box. For projection, only an approximation
* based on lat/lon corners. Must have 2D/LatLon for x and y axis.
*
* @param cs coordinate system from which range is computed (must have Lat/Lon axes)
* @param listRangeValueLat latitude values (min/max) corresponding to the each range. Can be null.
* @param listRangeValueLon longitude values (min/max) corresponding to the each range. Can be null.
* @return a list of list of 2 Range objects, first y (lat) then x (lon). Can be empty if rect is out of
* range.
* @throws MotuNotImplementedException
* @throws MotuException
*/
public List<List<Range>> toListRanges(CoordinateSystem cs, List<double[]> listRangeValueLat, List<double[]> listRangeValueLon)
throws MotuException, MotuInvalidLatLonRangeException, MotuNotImplementedException {
// NetCDF 2.2.16
// GridCoordSys gcs = new GridCoordSys(cs);
// NetCDF 2.2.18
Formatter errMessages = new Formatter();
GridCoordSys gcs = new GridCoordSys(cs, errMessages);
// NetCDF 2.2.16
// List<Range> listRange = (List<Range>) gcs.getLatLonBoundingBox(latLonRect);
// NetCDF 2.2.18
List<List<Range>> listRanges = getListRangesFromLatLonRect(gcs, latLonRect);
// List<Range> listRange = getRangesFromLatLonRect(gcs, latLonRect);
if (ExtractCriteriaLatLon.hasEmptyYXRanges(listRanges)) {
// return listRanges;
throw new MotuInvalidLatLonRangeException(latLonRect, gcs.getLatLonBoundingBox());
}
removeEmptyYXRanges(listRanges);
if ((listRangeValueLat == null) && (listRangeValueLon == null)) {
return listRanges;
}
for (List<Range> ranges : listRanges) {
Range rangeLat = ranges.get(0);
Range rangeLon = ranges.get(1);
if (!(ExtractCriteriaLatLon.hasRange(ranges))) {
continue;
}
double[] rangeValueLat = new double[2];
rangeValueLat[0] = Double.MAX_VALUE;
rangeValueLat[1] = Double.MAX_VALUE;
double[] rangeValueLon = new double[2];
rangeValueLon[0] = Double.MAX_VALUE;
rangeValueLon[1] = Double.MAX_VALUE;
getRangeValues(gcs, rangeLat, rangeLon, rangeValueLat, rangeValueLon);
listRangeValueLat.add(rangeValueLat);
listRangeValueLon.add(rangeValueLon);
}
return listRanges;
}