public int getRank() { return variableDS.getRank() - ignoredDimensions.size(); }
public int getRank() { return variableDS.getRank() - ignoredDimensions.size(); }
/** * Create a coordinate axis from an existing Variable. * * @param ncd the containing dataset * @param vds an existing Variable in dataset. * @return CoordinateAxis or one of its subclasses (CoordinateAxis1D, CoordinateAxis2D, or CoordinateAxis1DTime). */ static public CoordinateAxis factory(NetcdfDataset ncd, VariableDS vds) { if ((vds.getRank() == 0) || (vds.getRank() == 1) || (vds.getRank() == 2 && vds.getDataType() == DataType.CHAR)) { return new CoordinateAxis1D(ncd, vds); } else if (vds.getRank() == 2) return new CoordinateAxis2D(ncd, vds); else return new CoordinateAxis(ncd, vds); }
/** * Create a coordinate axis from an existing Variable. * * @param ncd the containing dataset * @param vds an existing Variable in dataset. * @return CoordinateAxis or one of its subclasses (CoordinateAxis1D, CoordinateAxis2D, or CoordinateAxis1DTime). */ static public CoordinateAxis factory(NetcdfDataset ncd, VariableDS vds) { if ((vds.getRank() == 1) || (vds.getRank() == 2 && vds.getDataType() == DataType.CHAR)) { return new CoordinateAxis1D(ncd, vds); } else if (vds.getRank() == 2) return new CoordinateAxis2D(ncd, vds); else return new CoordinateAxis(ncd, vds); }
/** * Create a coordinate axis from an existing Variable. * * @param ncd the containing dataset * @param vds an existing Variable in dataset. * @return CoordinateAxis or one of its subclasses (CoordinateAxis1D, CoordinateAxis2D, or CoordinateAxis1DTime). */ static public CoordinateAxis factory(NetcdfDataset ncd, VariableDS vds) { if ((vds.getRank() == 1) || (vds.getRank() == 2 && vds.getDataType() == DataType.CHAR)) return new CoordinateAxis1D(ncd, vds); else if (vds.getRank() == 2) return new CoordinateAxis2D(ncd, vds); else return new CoordinateAxis(ncd, vds); }
private TableConfig getPointConfig(NetcdfDataset ds, EncodingInfo info, Formatter errlog) throws IOException { if (info.time.getRank() != 1) { errlog.format("CFpointObs type=point: coord time must have rank 1, coord var= %s %n", info.time.getNameAndDimensions()); return null; } Dimension obsDim = info.time.getDimension(0); TableConfig obsTable = makeSingle(ds, obsDim, errlog); obsTable.featureType = FeatureType.POINT; return obsTable; }
protected TableConfig getPointConfig(NetcdfDataset ds, EncodingInfo info, Formatter errlog) throws IOException { if (info.time.getRank() != 1) { errlog.format("CFpointObs type=point: coord time must have rank 1, coord var= %s %n", info.time.getNameAndDimensions()); return null; } Dimension obsDim = info.time.getDimension(0); TableConfig obsTable = makeSingle(ds, obsDim, errlog); obsTable.featureType = FeatureType.POINT; return obsTable; }
protected TableConfig getPointConfig(NetcdfDataset ds, EncodingInfo info, Formatter errlog) throws IOException { if (info.time.getRank() != 1) { errlog.format("CFpointObs type=point: coord time must have rank 1, coord var= %s %n", info.time.getNameAndDimensions()); return null; } Dimension obsDim = info.time.getDimension(0); TableConfig obsTable = makeSingle(ds, obsDim, errlog); obsTable.featureType = FeatureType.POINT; return obsTable; }
public void check(Formatter f) { for (Variable v : getVariables()) { VariableDS vds = (VariableDS) v; if (vds.getOriginalDataType() != vds.getDataType()) { f.format("Variable %s has type %s, org = %s%n", vds.getFullName(), vds.getOriginalDataType(), vds.getDataType()); } if (vds.getOriginalVariable() != null) { Variable orgVar = vds.getOriginalVariable(); if (orgVar.getRank() != vds.getRank()) f.format("Variable %s has rank %d, org = %d%n", vds.getFullName(), vds.getRank(), orgVar.getRank()); } } }
public void check(Formatter f) { for (Variable v : getVariables()) { VariableDS vds = (VariableDS) v; if (vds.getOriginalDataType() != vds.getDataType()) { f.format("Variable %s has type %s, org = %s%n", vds.getFullName(), vds.getOriginalDataType(), vds.getDataType()); } if (vds.getOriginalVariable() != null) { Variable orgVar = vds.getOriginalVariable(); if (orgVar.getRank() != vds.getRank()) f.format("Variable %s has rank %d, org = %d%n", vds.getFullName(), vds.getRank(), orgVar.getRank()); } } }
public void check(Formatter f) { for (Variable v : getVariables()) { VariableDS vds = (VariableDS) v; if (vds.getOriginalDataType() != vds.getDataType()) { f.format("Variable %s has type %s, org = %s%n", vds.getFullName(), vds.getOriginalDataType(), vds.getDataType()); } if (vds.getOriginalVariable() != null) { Variable orgVar = vds.getOriginalVariable(); if (orgVar.getRank() != vds.getRank()) f.format("Variable %s has rank %d, org = %d%n", vds.getFullName(), vds.getRank(), orgVar.getRank()); } } }
private List<CalendarDate> makeTimesFromChar(VariableDS org, Formatter errMessages) throws IOException { int ncoords = (int) org.getSize(); int rank = org.getRank(); int strlen = org.getShape(rank - 1); ncoords /= strlen; List<CalendarDate> result = new ArrayList<CalendarDate>(ncoords); ArrayChar data = (ArrayChar) org.read(); ArrayChar.StringIterator ii = data.getStringIterator(); ArrayObject.D1 sdata = new ArrayObject.D1(String.class, ncoords); for (int i = 0; i < ncoords; i++) { String coordValue = ii.next(); CalendarDate cd = makeCalendarDateFromStringCoord(coordValue, org, errMessages); sdata.set(i, coordValue); result.add( cd); } setCachedData(sdata, true); return result; }
private List<CalendarDate> makeTimesFromChar(VariableDS org, Formatter errMessages) throws IOException { int ncoords = (int) org.getSize(); int rank = org.getRank(); int strlen = org.getShape(rank - 1); ncoords /= strlen; List<CalendarDate> result = new ArrayList<>(ncoords); ArrayChar data = (ArrayChar) org.read(); ArrayChar.StringIterator ii = data.getStringIterator(); ArrayObject.D1 sdata = new ArrayObject.D1(String.class, ncoords); for (int i = 0; i < ncoords; i++) { String coordValue = ii.next(); CalendarDate cd = makeCalendarDateFromStringCoord(coordValue, org, errMessages); sdata.set(i, coordValue); result.add( cd); } setCachedData(sdata, true); return result; }
private List<CalendarDate> makeTimesFromChar(VariableDS org, Formatter errMessages) throws IOException { int ncoords = (int) org.getSize(); int rank = org.getRank(); int strlen = org.getShape(rank - 1); ncoords /= strlen; List<CalendarDate> result = new ArrayList<>(ncoords); ArrayChar data = (ArrayChar) org.read(); ArrayChar.StringIterator ii = data.getStringIterator(); ArrayObject.D1 sdata = (ArrayObject.D1) Array.factory(DataType.STRING, new int[] {ncoords}); for (int i = 0; i < ncoords; i++) { String coordValue = ii.next(); CalendarDate cd = makeCalendarDateFromStringCoord(coordValue, org, errMessages); sdata.set(i, coordValue); result.add( cd); } setCachedData(sdata, true); return result; }
/** * */ private void initRange() { // set the rank rank = variableDS.getRank(); width = variableDS.getDimension(rank - UnidataUtilities.X_DIMENSION).getLength(); height = variableDS.getDimension(rank - UnidataUtilities.Y_DIMENSION).getLength(); numBands = rank > 2 ? variableDS.getDimension(2).getLength() : 1; final int bufferType = UnidataUtilities.getRawDataType(variableDS); sampleModel = new BandedSampleModel(bufferType, width, height, 1); // range type String description = variableDS.getDescription(); final StringBuilder sb = new StringBuilder(); final Set<SampleDimension> sampleDims = new HashSet<SampleDimension>(); sampleDims.add(new GridSampleDimension(description + ":sd", (Category[]) null, null)); InternationalString desc = null; if (description != null && !description.isEmpty()) { desc = new SimpleInternationalString(description); } final FieldType fieldType = new DefaultFieldType(new NameImpl(getName()), desc, sampleDims); sb.append(description != null ? description.toString() + "," : ""); final RangeType range = new DefaultRangeType(getName(), description, fieldType); this.setRangeType(range); }
private boolean computeIsInterval() { intervalWasComputed = true; Attribute boundsAtt = findAttributeIgnoreCase(CF.BOUNDS); if ((null == boundsAtt) || !boundsAtt.isString()) return false; String boundsVarName = boundsAtt.getStringValue(); VariableDS boundsVar = (VariableDS) ncd.findVariable(getParentGroup(), boundsVarName); if (null == boundsVar) return false; if (3 != boundsVar.getRank()) return false; if (getDimension(0) != boundsVar.getDimension(0)) return false; return 2 == boundsVar.getDimension(2).getLength(); }
private boolean computeIsInterval() { intervalWasComputed = true; Attribute boundsAtt = findAttributeIgnoreCase(CF.BOUNDS); if ((null == boundsAtt) || !boundsAtt.isString()) return false; String boundsVarName = boundsAtt.getStringValue(); VariableDS boundsVar = (VariableDS) ncd.findVariable(getParentGroup(), boundsVarName); if (null == boundsVar) return false; if (3 != boundsVar.getRank()) return false; if (getDimension(0) != boundsVar.getDimension(0)) return false; if (getDimension(1) != boundsVar.getDimension(1)) return false; return 2 == boundsVar.getDimension(2).getLength(); }
@Test public void testExplicitFillValue() throws Exception { String filename = TestDir.cdmLocalTestDataDir +"standardVar.nc"; try (NetcdfDataset ncfile = NetcdfDataset.openDataset(filename)) { VariableDS v = (VariableDS) ncfile.findVariable("t3"); Assert.assertNotNull("t3", v); Assert.assertTrue(v.hasFillValue()); Assert.assertNotNull(v.findAttribute("_FillValue")); int rank = v.getRank(); List<Range> ranges = new ArrayList<>(); ranges.add(null); for (int i = 1; i < rank; i++) { ranges.add(new Range(0, 1)); } VariableDS v_section = (VariableDS) v.section(ranges); Assert.assertNotNull (v_section.findAttribute("_FillValue")); System.out.println(v_section.findAttribute("_FillValue")); Assert.assertTrue(v_section.hasFillValue()); } }
private void checkMissingValues(VariableDS elev, VariableDS azi, VariableDS time, VariableDS q) throws IOException, InvalidRangeException { Array elevData = elev.read(); IndexIterator elevII = elevData.getIndexIterator(); Array aziData = azi.read(); IndexIterator aziII = aziData.getIndexIterator(); Array timeData = time.read(); IndexIterator timeII = timeData.getIndexIterator(); while (elevII.hasNext()) { float elevValue = elevII.getFloatNext(); float aziValue = aziII.getFloatNext(); assert azi.isMissing(aziValue) == elev.isMissing(elevValue); // LOOK missing data broken for non-float coordinate axes //int timeValue = timeII.getIntNext(); //assert azi.isMissing(aziValue) == time.isMissing(timeValue) : " azi= "+aziValue +" time= "+timeValue; } int[] shape = q.getShape(); int rank = q.getRank(); int[] origin = new int[rank]; shape[rank-1] = 1; Array qData = q.read(origin, shape); assert qData.getSize() == aziData.getSize(); IndexIterator qII = qData.getIndexIterator(); aziII = aziData.getIndexIterator(); while (qII.hasNext()) { float qValue = qII.getFloatNext(); float aziValue = aziII.getFloatNext(); if (azi.isMissing(aziValue)) assert q.isMissing(qValue); } }