/** * For rank 1 array of Structures, read count Structures and return the data as an ArrayStructure. * Use only when this is a one dimensional array of Structures. * @param start start at this index * @param count return this many StructureData * @return the StructureData recordsfrom start to start+count-1 * @throws java.io.IOException on read error * @throws ucar.ma2.InvalidRangeException if start, count out of range */ public ArrayStructure readStructure(int start, int count) throws IOException, ucar.ma2.InvalidRangeException { if (getRank() != 1) throw new java.lang.UnsupportedOperationException("not a vector structure"); int[] origin = new int[] {start}; int[] shape = new int[] {count}; if (NetcdfFile.debugStructureIterator) System.out.println("readStructure "+start+" "+count); return (ArrayStructure) read(origin, shape); }
/** * For rank 1 array of Structures, read count Structures and return the data as an ArrayStructure. * Use only when this is a one dimensional array of Structures. * @param start start at this index * @param count return this many StructureData * @return the StructureData recordsfrom start to start+count-1 * @throws java.io.IOException on read error * @throws ucar.ma2.InvalidRangeException if start, count out of range */ public ArrayStructure readStructure(int start, int count) throws IOException, ucar.ma2.InvalidRangeException { if (getRank() != 1) throw new java.lang.UnsupportedOperationException("not a vector structure"); int[] origin = new int[] {start}; int[] shape = new int[] {count}; if (NetcdfFile.debugStructureIterator) System.out.println("readStructure "+start+" "+count); return (ArrayStructure) read(origin, shape); }
/** * For rank 1 array of Structures, read count Structures and return the data as an ArrayStructure. * Use only when this is a one dimensional array of Structures. * @param start start at this index * @param count return this many StructureData * @return the StructureData recordsfrom start to start+count-1 * @throws java.io.IOException on read error * @throws ucar.ma2.InvalidRangeException if start, count out of range */ public ArrayStructure readStructure(int start, int count) throws IOException, ucar.ma2.InvalidRangeException { if (getRank() != 1) throw new java.lang.UnsupportedOperationException("not a vector structure"); int[] origin = new int[] {start}; int[] shape = new int[] {count}; if (NetcdfFile.debugStructureIterator) System.out.println("readStructure "+start+" "+count); return (ArrayStructure) read(origin, shape); }
/** * Use this when this is a scalar Structure. Its the same as read(), but it extracts the single * StructureData out of the Array. * @return StructureData for a scalar * @throws java.io.IOException on read error */ public StructureData readStructure() throws IOException { if (getRank() != 0) throw new java.lang.UnsupportedOperationException("not a scalar structure"); Array dataArray = read(); ArrayStructure data = (ArrayStructure) dataArray; return data.getStructureData(0); }
/** * Use this when this is a scalar Structure. Its the same as read(), but it extracts the single * StructureData out of the Array. * @return StructureData for a scalar * @throws java.io.IOException on read error */ public StructureData readStructure() throws IOException { if (getRank() != 0) throw new java.lang.UnsupportedOperationException("not a scalar structure"); Array dataArray = read(); ArrayStructure data = (ArrayStructure) dataArray; return data.getStructureData(0); }
/** * Use this when this is a scalar Structure. Its the same as read(), but it extracts the single * StructureData out of the Array. * @return StructureData for a scalar * @throws java.io.IOException on read error */ public StructureData readStructure() throws IOException { if (getRank() != 0) throw new java.lang.UnsupportedOperationException("not a scalar structure"); Array dataArray = read(); ArrayStructure data = (ArrayStructure) dataArray; return data.getStructureData(0); }
/** * Get an efficient iterator over all the data in the Structure. * * This is the efficient way to get all the data, it can be much faster than reading one record at a time, * and is optimized for large datasets. * This is accomplished by buffering bufferSize amount of data at once. * * <pre>Example: * * StructureDataIterator ii = structVariable.getStructureIterator(100 * 1000); * while (ii.hasNext()) { * StructureData sdata = ii.next(); * } * </pre> * @param bufferSize size in bytes to buffer, set < 0 to use default size * @return StructureDataIterator over type StructureData * @throws java.io.IOException on read error */ public StructureDataIterator getStructureIterator(int bufferSize) throws java.io.IOException { return (getRank() < 2) ? new Structure.IteratorRank1(bufferSize) : new Structure.Iterator(bufferSize); }
/** * Get an efficient iterator over all the data in the Structure. * * This is the efficient way to get all the data, it can be much faster than reading one record at a time, * and is optimized for large datasets. * This is accomplished by buffering bufferSize amount of data at once. * * <pre>Example: * * StructureDataIterator ii = structVariable.getStructureIterator(100 * 1000); * while (ii.hasNext()) { * StructureData sdata = ii.next(); * } * </pre> * @param bufferSize size in bytes to buffer, set < 0 to use default size * @return StructureDataIterator over type StructureData * @throws java.io.IOException on read error */ public StructureDataIterator getStructureIterator(int bufferSize) throws java.io.IOException { return (getRank() < 2) ? new Structure.IteratorRank1(bufferSize) : new Structure.Iterator(bufferSize); }
/** * Get an efficient iterator over all the data in the Structure. * * This is the efficient way to get all the data, it can be much faster than reading one record at a time, * and is optimized for large datasets. * This is accomplished by buffering bufferSize amount of data at once. * * <pre>Example: * * StructureDataIterator ii = structVariable.getStructureIterator(100 * 1000); * while (ii.hasNext()) { * StructureData sdata = ii.next(); * } * </pre> * @param bufferSize size in bytes to buffer, set < 0 to use default size * @return StructureDataIterator over type StructureData * @throws java.io.IOException on read error */ public StructureDataIterator getStructureIterator(int bufferSize) throws java.io.IOException { return (getRank() < 2) ? new Structure.IteratorRank1(bufferSize) : new Structure.Iterator(bufferSize); }
@Override protected boolean identifyEncodingStation(NetcdfDataset ds, EncodingInfo info, CF.FeatureType ftype, Formatter errlog) { Structure obs = info.time.getParentStructure(); if (obs.getRank() == 0) { errlog.format("CFpointObs: must have a non-scalar Time coordinate%n"); return false; } Dimension obsDim = obs.getDimension(0); Structure station = info.lat.getParentStructure(); if (station.getRank() == 0) { // could be scalar info.set(Encoding.single, null, obsDim); } Dimension stnDim = station.getDimension(0); // the raggeds if (identifyRaggeds(ds, info, stnDim, obsDim, errlog)) return true; errlog.format("CFpointObsExt: %s Must have Lat/Lon coordinates of rank 0 or 1%n", ftype); return false; }
@Override protected boolean identifyEncodingStation(NetcdfDataset ds, EncodingInfo info, CF.FeatureType ftype, Formatter errlog) { Structure obs = info.time.getParentStructure(); if (obs.getRank() == 0) { errlog.format("CFpointObs: must have a non-scalar Time coordinate%n"); return false; } Dimension obsDim = obs.getDimension(0); Structure station = info.lat.getParentStructure(); if (station.getRank() == 0) { // could be scalar info.set(Encoding.single, null, obsDim); } Dimension stnDim = station.getDimension(0); // the raggeds if (identifyRaggeds(ds, info, stnDim, obsDim, errlog)) return true; errlog.format("CFpointObsExt: %s Must have Lat/Lon coordinates of rank 0 or 1%n", ftype); return false; }
static private void writeNcMLStructure( Structure s, PrintStream out, Indent indent) throws IOException { out.print(indent); out.print("<structure name='"+ StringUtil2.quoteXmlAttribute(s.getShortName())); // any dimensions? if (s.getRank() > 0) { writeNcMLDimension( s, out); } out.print(">\n"); indent.incr(); List<Attribute> attList = s.getAttributes(); for (Attribute att : attList) { writeNcMLAtt(att, out, indent); } if (attList.size() > 0) out.print("\n"); List<Variable> varList = s.getVariables(); for (Variable v : varList) { writeNcMLVariable(v, out, indent, false); } indent.decr(); out.print(indent); out.print("</structure>\n"); }
static private void writeNcMLStructure(Structure s, Formatter out, Indent indent, WantValues showValues) throws IOException { out.format("%s<structure name='%s", indent, StringUtil2.quoteXmlAttribute(s.getShortName())); // any dimensions? if (s.getRank() > 0) { writeNcMLDimension(s, out); } out.format(">%n"); indent.incr(); List<Attribute> attList = s.getAttributes(); for (Attribute att : attList) { writeNcMLAtt(att, out, indent); } if (attList.size() > 0) out.format("%n"); List<Variable> varList = s.getVariables(); for (Variable v : varList) { writeNcMLVariable(v, out, indent, showValues); } indent.decr(); out.format("%s</structure>%n", indent); }
@Override protected boolean identifyEncodingTraj(NetcdfDataset ds, EncodingInfo info, Formatter errlog) { // find the obs structure info.childStruct = info.lat.getParentStructure(); Dimension obsDim = info.childStruct.getDimension(0); // find the traj structure Variable varatt = Evaluator.findVariableWithAttributeValue(ds, CF.CF_ROLE, CF.TRAJECTORY_ID); Structure traj = varatt.getParentStructure(); if (traj.getRank() == 0) { // could be scalar info.set(Encoding.single, null, obsDim); } Dimension trajDim = traj.getDimension(0); if (identifyRaggeds(ds, info, trajDim, obsDim, errlog)) return true; errlog.format("CFpointObsExt: %s only supports ragged array representation%n", CF.FeatureType.trajectory); return false; }
@Override protected boolean identifyEncodingTraj(NetcdfDataset ds, EncodingInfo info, Formatter errlog) { // find the obs structure info.childStruct = info.lat.getParentStructure(); Dimension obsDim = info.childStruct.getDimension(0); // find the traj structure Variable varatt = Evaluator.findVariableWithAttributeValue(ds, CF.CF_ROLE, CF.TRAJECTORY_ID); Structure traj = varatt.getParentStructure(); if (traj.getRank() == 0) { // could be scalar info.set(Encoding.single, null, obsDim); } Dimension trajDim = traj.getDimension(0); if (identifyRaggeds(ds, info, trajDim, obsDim, errlog)) return true; errlog.format("CFpointObsExt: %s only supports ragged array representation%n", CF.FeatureType.trajectory); return false; }
@Override protected boolean identifyEncodingProfile(NetcdfDataset ds, EncodingInfo info, Formatter errlog) { Evaluator.VarAtt varatt = Evaluator.findVariableWithAttribute(ds, CF.SAMPLE_DIMENSION); if (varatt == null) return false; String dimName = varatt.att.getStringValue(); Dimension obsDim = ds.findDimension(dimName); Structure profile = info.lat.getParentStructure(); if (profile.getRank() == 0) { // could be scalar info.set(Encoding.single, null, obsDim); } Dimension profileDim = profile.getDimension(0); // now find the child structure info.childStruct = Evaluator.findStructureWithDimensions(ds, obsDim, null); // the raggeds if (identifyRaggeds(ds, info, profileDim, obsDim, errlog)) return true; errlog.format("CFpointObsExt: %s only supports ragged array representation%n", CF.FeatureType.profile); return false; }
@Override protected boolean identifyEncodingProfile(NetcdfDataset ds, EncodingInfo info, Formatter errlog) { Evaluator.VarAtt varatt = Evaluator.findVariableWithAttribute(ds, CF.SAMPLE_DIMENSION); if (varatt == null) return false; String dimName = varatt.att.getStringValue(); Dimension obsDim = ds.findDimension(dimName); Structure profile = info.lat.getParentStructure(); if (profile.getRank() == 0) { // could be scalar info.set(Encoding.single, null, obsDim); } Dimension profileDim = profile.getDimension(0); // now find the child structure info.childStruct = Evaluator.findStructureWithDimensions(ds, obsDim, null); // the raggeds if (identifyRaggeds(ds, info, profileDim, obsDim, errlog)) return true; errlog.format("CFpointObsExt: %s only supports ragged array representation%n", CF.FeatureType.profile); return false; }
public boolean match(CoordinateAxis axis) { if ((outer == null) && (axis.getRank() == 0)) return true; if ((outer != null) && (axis.getRank() == 1) && (outer.equals(axis.getDimension(0)))) return true; // if axis is structure member, try pulling dimension out of parent structure if (axis.getParentStructure() != null) { Structure parent = axis.getParentStructure(); if ((outer != null) && (parent.getRank() == 1) && (outer.equals(parent.getDimension(0)))) return true; } return false; } });
public boolean match(CoordinateAxis axis) { if ((outer == null) && (axis.getRank() == 0)) return true; if ((outer != null) && (axis.getRank() == 1) && (outer.equals(axis.getDimension(0)))) return true; // if axis is structure member, try pulling dimension out of parent structure if (axis.getParentStructure() != null) { Structure parent = axis.getParentStructure(); if ((outer != null) && (parent.getRank() == 1) && (outer.equals(parent.getDimension(0)))) return true; } return false; } });
public boolean match(CoordinateAxis axis) { if ((outer == null) && (axis.getRank() == 0)) return true; if ((outer != null) && (axis.getRank() == 1) && (outer.equals(axis.getDimension(0)))) return true; // if axis is structure member, try pulling dimension out of parent structure if (axis.getParentStructure() != null) { Structure parent = axis.getParentStructure(); if ((outer != null) && (parent.getRank() == 1) && (outer.equals(parent.getDimension(0)))) return true; } return false; } });