public CoverageCoordAxis getZAxis() { for (String axisName : getAxisNames()) { CoverageCoordAxis axis = dataset.findCoordAxis(axisName); if (axis == null) throw new IllegalStateException("Cant find axis with name "+axisName); if (axis.getAxisType() == AxisType.GeoZ || axis.getAxisType() == AxisType.Height || axis.getAxisType() == AxisType.Pressure) return axis; } return null; }
public boolean isTime2D( CoverageCoordAxis axis) { if (time2DCoordSys == null) return false; if (axis instanceof TimeOffsetAxis) return true; if (axis instanceof TimeAxis2DFmrc) return true; return (axis.getAxisType() == AxisType.RunTime) && (axis.getDependenceType() != CoverageCoordAxis.DependenceType.dependent); }
@Override protected void setDataset(CoordSysContainer dataset) { if (shape != null) throw new RuntimeException("Cant change axis once set"); shape = new int[2]; String runtimeName = dependsOn.get(0); CoverageCoordAxis runtime = dataset.findCoordAxis(runtimeName); if (runtime == null) throw new IllegalStateException("FmrcTimeAxis2D cant find runtime axis with name "+runtimeName); assert runtime instanceof CoverageCoordAxis1D; assert runtime.getAxisType() == AxisType.RunTime; runCoord = (CoverageCoordAxis1D) runtime; shape[0] = runtime.getNcoords(); shape[1] = ncoords / shape[0]; }
private CoverageCoordAxis1D findDependent( CoverageCoordAxis independentAxis, AxisType axisType) { for (CoverageCoordAxis axis : axes) { if (axis.getDependenceType() == CoverageCoordAxis.DependenceType.dependent) { for (String axisName : axis.dependsOn) { if (axisName.equalsIgnoreCase(independentAxis.getName()) && axis.getAxisType() == axisType) return (CoverageCoordAxis1D) axis; } } } return null; } }
public CoverageCoordAxis getAxis(AxisType type) { for (String axisName : getAxisNames()) { CoverageCoordAxis axis = dataset.findCoordAxis(axisName); if (axis == null) throw new IllegalStateException("Cant find axis with name "+axisName); else if (axis.getAxisType() == type) { return axis; } } return null; }
public List<RangeIterator> getRanges() { List<RangeIterator> result = new ArrayList<>(); for (CoverageCoordAxis axis : getAxes()) { if (axis.getAxisType().isHoriz()) continue; if (axis.getDependenceType() == CoverageCoordAxis.DependenceType.independent) result.add(axis.getRangeIterator()); } result.addAll(horizCoordSys.getRanges()); // may be 2D return result; }
if (axis.getAxisType() == AxisType.TimeOffset) { if (timeOffsetAxis != null) throw new RuntimeException("Cant have multiple TimeOffset Axes in a CoverageCoordSys"); timeOffsetAxis = (TimeOffsetAxis) axis; if (axis.getAxisType() == AxisType.RunTime) { if (runtimeAxis != null) throw new RuntimeException("Cant have multiple RunTime axes in a CoverageCoordSys");
List<CoverageCoordAxis> coordList = coord2axisMap.get(axis); if (coordList != null) { for (CoverageCoordAxis coord : coordList) names.add(new NameAndType(coord.getName(), coord.getAxisType()));
if (axis.getAxisType() == AxisType.RunTime) { runtime = (CalendarDate) coord; result.setRunTime(runtime); } else if (axis.getAxisType() == AxisType.Time) { CoverageCoordAxis1D runtimeForBest = findDependent(axis, AxisType.RunTime); if (runtimeForBest != null) { else if (axis.getAxisType().isVert()) { if (coord instanceof Double) result.setVertCoord( (Double) coord); else if (axis.getAxisType() == AxisType.Ensemble) result.setEnsCoord((Double) coord); else if (!constantForecast && axis.getAxisType() == AxisType.TimeOffset) { if (coord instanceof Double) result.setTimeOffset( (Double) coord);
if (axis.getAxisType().isHoriz()) continue; if (isTime2D(axis)) continue; if (axis.getDependenceType() == CoverageCoordAxis.DependenceType.independent) rank++; if (axis.getAxisType().isHoriz()) continue; if (isTime2D(axis)) continue; if (axis.getDependenceType() == CoverageCoordAxis.DependenceType.independent)
if (axis.getAxisType() == AxisType.Lat) { newV.addAttribute(new Attribute(CDM.UNITS, CDM.LAT_UNITS)); newV.addAttribute(new Attribute(CF.STANDARD_NAME, CF.LATITUDE)); if (axis.getAxisType() == AxisType.Lon) { newV.addAttribute(new Attribute(CDM.UNITS, CDM.LON_UNITS)); newV.addAttribute(new Attribute(CF.STANDARD_NAME, CF.LONGITUDE)); if (axis.getAxisType() == AxisType.GeoX) { newV.addAttribute(new Attribute(CF.STANDARD_NAME, CF.PROJECTION_X_COORDINATE)); if (axis.getAxisType() == AxisType.GeoY) { newV.addAttribute(new Attribute(CF.STANDARD_NAME, CF.PROJECTION_Y_COORDINATE)); if (axis.getAxisType() == AxisType.Ensemble) { newV.addAttribute(new Attribute(CF.STANDARD_NAME, CF.ENSEMBLE));
for (CoverageCoordAxis axis : getAxes()) { if (axis.getDependenceType() == CoverageCoordAxis.DependenceType.dependent) continue; if (axis.getAxisType().isHoriz()) continue; if (isTime2D(axis)) continue;
switch (axis.getAxisType()) { // LOOK what about 2D ?? case RunTime: case Time:
@Test public void testGridCoverageDatasetRdavm() throws IOException, InvalidRangeException { if (showDetails) System.out.printf("%s%n", filename); try (FeatureDatasetCoverage fdc = CoverageDatasetFactory.open(filename)) { Assert.assertNotNull(filename, fdc); for (CoverageCollection cc : fdc.getCoverageCollections()) { System.out.printf(" %s type=%s%n", cc.getName(), cc.getCoverageType()); //for (CoverageCoordSys coordSys : cc.getCoordSys()) { //Assert.assertTrue( coordSys.isTime2D(coordSys.getAxis(AxisType.RunTime))); //Assert.assertTrue( coordSys.isTime2D(coordSys.getTimeAxis())); //} if (showDetails) for (CoverageCoordAxis axis : cc.getCoordAxes()) { if (axis.getAxisType().isTime()) System.out.printf(" %12s %10s %5d %10s %s%n", axis.getName(), axis.getAxisType(), axis.getNcoords(), axis.getDependenceType(), axis.getSpacing()); } } } }
varElem.setAttribute("type", dt.toString()); AxisType axisType = axis.getAxisType(); if (null != axisType) varElem.setAttribute("axisType", axisType.toString());
@Ignore("files not present") @Test public void testGridCoverageDatasetFmrc() throws IOException, InvalidRangeException { System.out.printf("%s%n", filename); try (FeatureDatasetCoverage fdc = CoverageDatasetFactory.open(filename)) { Assert.assertNotNull(filename, fdc); CoverageCollection cc = fdc.findCoverageDataset(FeatureType.GRID); Assert.assertNotNull(FeatureType.GRID.toString(), cc); System.out.printf(" %s type=%s%n", cc.getName(), cc.getCoverageType()); for (CoverageCoordSys coordSys : cc.getCoordSys()) { Assert.assertTrue( coordSys.isTime2D(coordSys.getAxis(AxisType.RunTime))); Assert.assertTrue( coordSys.isTime2D(coordSys.getTimeAxis())); } for (CoverageCoordAxis axis : cc.getCoordAxes()) { if (axis.getAxisType().isTime()) System.out.printf(" %12s %10s %5d %10s %s%n", axis.getName(), axis.getAxisType(), axis.getNcoords(), axis.getDependenceType(), axis.getSpacing()); } } } }
builder.setName(axis.getName()); builder.setDataType(NcStream.convertDataType(axis.getDataType())); builder.setAxisType(convertAxisType(axis.getAxisType())); builder.setNvalues(axis.getNcoords()); if (axis.getUnits() != null) builder.setUnits(axis.getUnits());
private void addCoordinateAxes(CoverageCollection subsetDataset, NetcdfFileWriter writer) { for (CoverageCoordAxis axis : subsetDataset.getCoordAxes()) { String dims; if (axis.getDependenceType() == CoverageCoordAxis.DependenceType.independent) { dims = axis.getName(); } else if (axis.getDependenceType() == CoverageCoordAxis.DependenceType.scalar) { dims = ""; } else { dims = axis.getDependsOn(); } boolean hasBounds = false; if (axis.isInterval()) { Variable vb = writer.addVariable(null, axis.getName()+BOUNDS, axis.getDataType(), dims+" "+BOUNDS_DIM); vb.addAttribute(new Attribute(CDM.UNITS, axis.getUnits())); hasBounds = true; } Variable v = writer.addVariable(null, axis.getName(), axis.getDataType(), dims); addVariableAttributes(v, axis.getAttributes()); v.addAttribute(new Attribute(CDM.UNITS, axis.getUnits())); // override what was in att list if (hasBounds) v.addAttribute(new Attribute(CF.BOUNDS, axis.getName()+BOUNDS)); if (axis.getAxisType() == AxisType.TimeOffset) v.addAttribute(new Attribute(CF.STANDARD_NAME, CF.TIME_OFFSET)); } }