本文整理匯總了Java中ucar.nc2.dataset.CoordinateAxis2D類的典型用法代碼示例。如果您正苦於以下問題:Java CoordinateAxis2D類的具體用法?Java CoordinateAxis2D怎麽用?Java CoordinateAxis2D使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
CoordinateAxis2D類屬於ucar.nc2.dataset包,在下文中一共展示了CoordinateAxis2D類的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: makeGeoAxisFrom2D
import ucar.nc2.dataset.CoordinateAxis2D; //導入依賴的package包/類
static private AxisBean makeGeoAxisFrom2D(CoordinateAxis2D axis, String type, String id) {
NumberFormat nf = NumberFormat.getNumberInstance(Locale.US);
DecimalFormat fmt = (DecimalFormat) nf;
fmt.applyPattern("####.####");
AxisBean axisbean = new AxisBean();
axisbean.setElement(axis.getShortName() + "-" + type + "-" + id);
axisbean.setType(type);
// Since the axis is curvi, represent it as a 1-degree arange.
double min = axis.getMinValue();
double max = axis.getMaxValue();
double diff = Math.abs(max - min);
// divide the range into 50 equal increments...
ArangeBean arange = new ArangeBean();
axisbean.setUnits(axis.getUnitsString());
arange.setSize("50");
arange.setStep(String.valueOf(diff/50.));
arange.setStart(fmt.format(min));
axisbean.setArange(arange);
return axisbean;
}
示例2: getRangeValues
import ucar.nc2.dataset.CoordinateAxis2D; //導入依賴的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");
}
}
示例3: computeLatLonMinMax
import ucar.nc2.dataset.CoordinateAxis2D; //導入依賴的package包/類
/**
* Compute lat lon min max.
*
* @param latAxis the lat axis
* @param lonAxis the lon axis
* @param minj the minj
* @param mini the mini
* @param maxj the maxj
* @param maxi the maxi
* @param minx the minx
* @throws MotuException the motu exception
*/
public void computeLatLonMinMax(CoordinateAxis2D latAxis,
CoordinateAxis2D lonAxis,
int minj,
int mini,
int maxj,
int maxi,
double minx,
double maxx)
throws MotuException {
computeLonMinMax(lonAxis, minj, mini, maxj, maxi, minx, maxx);
computeLatMinMax(latAxis, minj, mini, maxj, maxi);
}
示例4: computeLatMinMax
import ucar.nc2.dataset.CoordinateAxis2D; //導入依賴的package包/類
/**
* Compute lat min max.
*
* @param latAxis the lat axis
* @param minj the minj
* @param mini the mini
* @param maxj the maxj
* @param maxi the maxi
* @throws MotuException the motu exception
*/
public void computeLatMinMax(CoordinateAxis2D latAxis, int minj, int mini, int maxj, int maxi) throws MotuException {
if (latAxis == null) {
throw new MotuException(ErrorType.INVALID_LATITUDE, "ERROR in ExtractCriteriaLatLon#computeLatMinMax for CoordinateAxis2D: axis is null");
}
if (latAxis.getAxisType() != AxisType.Lat) {
String msg = String.format(
"ERROR in ExtractCriteriaLatLon#computeLatMinMax for CoordinateAxis2D: axis name '%s' - type is '%s' and expected type is '%s'",
latAxis.getName(),
latAxis.getAxisType().name(),
AxisType.Lat.name());
throw new MotuException(ErrorType.INVALID_LATITUDE, msg);
}
double latMin = Double.MAX_VALUE;
double latMax = -(Double.MAX_VALUE);
for (int j = minj; j <= maxj; j++) {
for (int i = mini; i <= maxi; i++) {
double value = latAxis.getCoordValue(j, i);
if (latMin > value) {
latMin = value;
}
if (latMax < value) {
latMax = value;
}
}
}
minMaxYValue2D = computeMinMax(minMaxYValue2D, new MinMax(latMin, latMax));
}
示例5: hasLatLonAxis2D
import ucar.nc2.dataset.CoordinateAxis2D; //導入依賴的package包/類
/**
* Checks for lat lon axis2 d.
*
* @return true, if successful
*/
public boolean hasLatLonAxis2D() {
if (!hasLatLonAxis()) {
return false;
}
return (getLatAxis() instanceof CoordinateAxis2D) && (getLonAxis() instanceof CoordinateAxis2D);
}
示例6: computeLonMinMax
import ucar.nc2.dataset.CoordinateAxis2D; //導入依賴的package包/類
/**
* Compute lon min max.
*
* @param lonAxis the lon axis
* @param minj the minj
* @param mini the mini
* @param maxj the maxj
* @param maxi the maxi
* @param minx the minx
* @throws MotuException the motu exception
*/
public void computeLonMinMax(CoordinateAxis2D lonAxis, int minj, int mini, int maxj, int maxi, double minx, double maxx) throws MotuException {
if (lonAxis == null) {
throw new MotuException(
ErrorType.INVALID_LONGITUDE,
"ERROR in ExtractCriteriaLatLon#computeLonMinMax for CoordinateAxis2D: axis is null");
}
if (lonAxis.getAxisType() != AxisType.Lon) {
String msg = String.format(
"ERROR in ExtractCriteriaLatLon#computeLonMinMax for CoordinateAxis2D: axis name '%s' - type is '%s' and expected type is '%s'",
lonAxis.getName(),
lonAxis.getAxisType().name(),
AxisType.Lon.name());
throw new MotuException(ErrorType.INVALID_LONGITUDE, msg);
}
double longitudeCenter = (minx + maxx) / 2;
double lonMin = Double.MAX_VALUE;
double lonMax = -(Double.MAX_VALUE);
for (int j = minj; j <= maxj; j++) {
for (int i = mini; i <= maxi; i++) {
double value = lonAxis.getCoordValue(j, i);
if (lonMin > value) {
lonMin = value;
}
if (lonMax < value) {
lonMax = value;
}
if (lonMin < minx) {
lonMin = LatLonPointImpl.lonNormal(lonMin, longitudeCenter);
}
if (lonMax < minx) {
lonMax = LatLonPointImpl.lonNormal(lonMax, longitudeCenter);
}
if (lonMin > lonMax) {
double temp = lonMin;
lonMin = lonMax;
lonMax = temp;
}
}
}
minMaxXValue2D = computeMinMax(minMaxXValue2D, new MinMax(lonMin, lonMax));
}
示例7: createHorizontalGrid
import ucar.nc2.dataset.CoordinateAxis2D; //導入依賴的package包/類
/**
*
* @param coordSys
* The {@link GridCoordSystem} to create a {@link HorizontalGrid}
* from
* @return two-dimensional referenceable grid from the given grid coordinate
* system. Will return more specific subclasses (
* {@link RectilinearGrid} or {@link RegularGrid}) if appropriate
* for the passed-in coordinate system. The grid's coordinate system
* will be a WGS84 longitude-latitude system.
*
* TODO May want to be careful about datum shifts - model data is
* often in spherical coordinates, not strict WGS84
*/
public static HorizontalGrid createHorizontalGrid(GridCoordSystem coordSys) {
CoordinateAxis xAxis = coordSys.getXHorizAxis();
CoordinateAxis yAxis = coordSys.getYHorizAxis();
boolean isLatLon = xAxis.getAxisType() == AxisType.Lon
&& yAxis.getAxisType() == AxisType.Lat;
if (xAxis instanceof CoordinateAxis1D && yAxis instanceof CoordinateAxis1D) {
ReferenceableAxis<Double> xRefAxis = createReferenceableAxis((CoordinateAxis1D) xAxis);
ReferenceableAxis<Double> yRefAxis = createReferenceableAxis((CoordinateAxis1D) yAxis);
if (isLatLon) {
/* We can create a RectilinearGrid in lat-lon space */
if (xRefAxis instanceof RegularAxis && yRefAxis instanceof RegularAxis) {
/* We can create a regular grid */
return new RegularGridImpl((RegularAxis) xRefAxis, (RegularAxis) yRefAxis,
GISUtils.defaultGeographicCRS());
} else {
/* Axes are not both regular */
return new RectilinearGridImpl(xRefAxis, yRefAxis,
GISUtils.defaultGeographicCRS());
}
} else {
/*
* Axes are not latitude and longitude so we need to create a
* ReferenceableGrid that uses the coordinate system's
* Projection object to convert from x and y to lat and lon
*/
return new CdmTransformedGrid(coordSys);
}
} else if (xAxis instanceof CoordinateAxis2D && yAxis instanceof CoordinateAxis2D) {
/* The axis must be 2D so we have to create look-up tables */
if (!isLatLon) {
throw new UnsupportedOperationException("Can't create a HorizontalGrid"
+ " from 2D coordinate axes that are not longitude and latitude.");
}
final CoordinateAxis2D lonAxis = (CoordinateAxis2D) xAxis;
final CoordinateAxis2D latAxis = (CoordinateAxis2D) yAxis;
Array2D<Number> lonVals = get2DCoordinateValues(lonAxis);
Array2D<Number> latVals = get2DCoordinateValues(latAxis);
return LookUpTableGrid.generate(lonVals, latVals);
} else {
/* Shouldn't get here */
throw new IllegalStateException("Inconsistent axis types");
}
}