public StructureDataIterator getStructureIterator(int bufferSize) throws java.io.IOException { return new StructureDataConverter(this, orgSeq.getStructureIterator(bufferSize)); }
private void addSequence(Structure parent, DataDescriptor dataDesc) { //String seqName = ftype == (FeatureType.STATION_PROFILE) ? "profile" : "seq"; String seqName = "seq" + seqNum; seqNum++; Sequence seq = new Sequence(ncfile, null, parent, seqName); seq.setDimensions(""); // scalar for (DataDescriptor dkey : dataDesc.getSubKeys()) addMember(seq, dkey); parent.addMemberVariable(seq); seq.setSPobject(dataDesc); dataDesc.name = seqName; dataDesc.refersTo = seq; }
private StructureDataRegexp.Vinfo setVinfo(RandomAccessFile raff, NetcdfFile ncfile, Pattern p, String seqName) { Sequence seq = (Sequence) ncfile.findVariable(seqName); StructureMembers sm = seq.makeStructureMembers(); StructureDataRegexp.Vinfo result = new StructureDataRegexp.Vinfo(raff, sm, p); seq.setSPobject(result); int fldno = 1; for (StructureMembers.Member m : sm.getMembers()) { StructureDataRegexp.VinfoField vf = new StructureDataRegexp.VinfoField(fldno++); Variable v = seq.findVariable(m.getName()); Attribute att = v.findAttribute("iosp_scale"); if (att != null) { vf.hasScale = true; vf.scale = att.getNumericValue().floatValue(); //v.remove(att); } m.setDataObject(vf); } return result; }
public Sequence(NetcdfFile ncfile, Group group, Structure parent, String shortName) { super(ncfile, group, parent, shortName); List<Dimension> dims = new ArrayList<>(); dims.add(Dimension.VLEN); setDimensions(dims); setDataType(DataType.SEQUENCE); }
protected Sequence makeSequence(NetcdfFile ncfile) { Sequence seq = new Sequence(ncfile, null, null, RECORD); "time of stroke", null, secondsSince1970, AxisType.Time); seq.addMemberVariable(v); seq.addMemberVariable(v); seq.addMemberVariable(v); seq.addMemberVariable(v); "error ellipse semi-major axis", null, "km", null); seq.addMemberVariable(v); "error ellipse minor axis ", null, "km", null); seq.addMemberVariable(v); "error ellipse axis angle of orientation ", null, "degrees", null); seq.addMemberVariable(v); "multiplicity [#strokes per flash]", null, "", null); seq.addMemberVariable(v);
Structure makeStructure(Structure parent) throws InvalidRangeException { Sequence seq = new Sequence(ncfile, null, parent, "otherData"); seq.addAttribute(new Attribute(CDM.LONG_NAME, catNames[8])); int pos = 0; Variable v = seq.addMemberVariable(new Variable(ncfile, null, parent, "data", DataType.INT, "")); v.addAttribute(new Attribute(CDM.LONG_NAME, "additional data specified in table 101.1")); v.addAttribute(new Attribute(_Coordinate.AxisType, AxisType.Pressure.toString())); v.setSPobject(new Vinfo(pos)); pos += 4; v = seq.addMemberVariable(new Variable(ncfile, null, parent, "table101code", DataType.SHORT, "")); v.addAttribute(new Attribute(CDM.LONG_NAME, "code figure from table 101")); v.addAttribute(new Attribute(CDM.MISSING_VALUE, (short) 999)); v.setSPobject(new Vinfo(pos)); pos += 2; v = seq.addMemberVariable(new Variable(ncfile, null, parent, "indicatorFlags", DataType.CHAR, "")); v.setDimensionsAnonymous(new int[]{2}); v.addAttribute(new Attribute(CDM.LONG_NAME, "quality marks: 0=data, 1=form")); v.setSPobject(new Vinfo(pos)); pos += 2; return seq; }
private void makeObsRecord(BufrConfig bufrConfig) throws IOException { recordStructure = new Sequence(ncfile, null, null, BufrIosp2.obsRecord); ncfile.addVariable(null, recordStructure);
members = seq.makeStructureMembers(); for (StructureMembers.Member m : members.getMembers()) { m.setDataParam(offset); Variable mv = seq.findVariable(m.getName()); DataDescriptor dk = (DataDescriptor) mv.getSPobject(); if (dk.replication == 0)
@Test @Category(NeedsCdmUnitTest.class) public void testRead() throws IOException { try (NetcdfFile ncfile = NetcdfFile.open(TestDir.cdmUnitTestDir + "ft/point/200929100.ingest")) { Sequence record = (Sequence) ncfile.findVariable("record"); List<String> expectedMemberNames = Arrays.asList("tsec", "nsec", "lat", "lon", "sgnl", "mult", "fill", "majorAxis", "eccent", "ellipseAngle", "chisqr"); Assert.assertEquals(Sets.newHashSet(expectedMemberNames), Sets.newHashSet(record.getVariableNames())); try (StructureDataIterator iter = record.getStructureIterator()) { int recordCount = 0; while (iter.hasNext()) { StructureData data = iter.next(); // Assert that a single value from the first record equals an expected value. // Kinda lazy, but checking all values would be impractical. if (recordCount++ == 0) { Assert.assertEquals(-700, data.getScalarShort("sgnl")); } } Assert.assertEquals(1165, recordCount); } } }
/** * UnsupportedOperation * * @throws UnsupportedOperationException */ @Override public Array read(ucar.ma2.Section section) throws java.io.IOException, ucar.ma2.InvalidRangeException { return read(); }
/** * Open existing file, and populate ncfile with it. This method is only * called by the NetcdfFile constructor on itself. The provided NetcdfFile * object will be empty except for the location String and the * IOServiceProvider associated with this NetcdfFile object. * * @param raf the file to work on, it has already passed the * isValidFile() test. * @param ncfile add objects to this empty NetcdfFile * @param cancelTask used to monitor user cancellation; may be null. * @throws IOException if read error */ public void open(RandomAccessFile raf, NetcdfFile ncfile, CancelTask cancelTask) throws IOException { super.open(raf, ncfile, cancelTask); isExtended = checkFormat(); isoDateFormat = new SimpleDateFormat(); isoDateFormat.setTimeZone(java.util.TimeZone.getTimeZone("GMT")); isoDateFormat.applyPattern(isExtended ? TIME_FORMAT_EX : TIME_FORMAT); Sequence seq = makeSequence(ncfile); ncfile.addVariable(null, seq); addLightningGlobalAttributes(ncfile); ncfile.finish(); sm = seq.makeStructureMembers(); ArrayStructureBB.setOffsets(sm); }
SeqIter() { addTime = (construct.recordStructure.findVariable(ConstructNC.TIME_NAME) != null); reset(); }
"Height_of_station", "Short_station_or_site_name", "Type_of_measuring_equipment_used", "Time_significance", "Time_period_or_displacement", "seq1"); Assert.assertEquals(Sets.newHashSet(expectedMemberNames), Sets.newHashSet(obs.getVariableNames())); ArraySequence obsArray = (ArraySequence) obs.read(); int obsCount = 0;
private void annotateObs(Sequence recordStructure) { StandardFields.StandardFieldsFromStructure extract = new StandardFields.StandardFieldsFromStructure(centerId, recordStructure); Formatter f = new Formatter(); String name = extract.getFieldName(BufrCdmIndexProto.FldType.lat); if (name != null) f.format("%s ", name); name = extract.getFieldName(BufrCdmIndexProto.FldType.lon); if (name != null) f.format("%s ", name); name = extract.getFieldName(BufrCdmIndexProto.FldType.height); if (name != null) f.format("%s ", name); name = extract.getFieldName(BufrCdmIndexProto.FldType.heightAboveStation); if (name != null) f.format("%s ", name); recordStructure.addAttribute(new Attribute("coordinates", f.toString())); }
private void makeIndex(File indexFile) throws IOException { Vinfo stnInfo = (Vinfo) stnSeq.getSPobject(); StructureMembers.Member m = stnInfo.sm.findMember(STNID); TableParser.Field f = (TableParser.Field) m.getDataObject(); Vinfo dataInfo = (Vinfo) dataSeq.getSPobject(); m = dataInfo.sm.findMember(STNID); f = (TableParser.Field) m.getDataObject();
Structure makeStructure(Structure parent) throws InvalidRangeException { Sequence seq = new Sequence(ncfile, null, parent, "otherData"); seq.addAttribute(new Attribute(CDM.LONG_NAME, catNames[8])); int pos = 0; Variable v = seq.addMemberVariable(new Variable(ncfile, null, parent, "data", DataType.INT, "")); v.addAttribute(new Attribute(CDM.LONG_NAME, "additional data specified in table 101.1")); v.addAttribute(new Attribute(_Coordinate.AxisType, AxisType.Pressure.toString())); v.setSPobject(new Vinfo(pos)); pos += 4; v = seq.addMemberVariable(new Variable(ncfile, null, parent, "table101code", DataType.SHORT, "")); v.addAttribute(new Attribute(CDM.LONG_NAME, "code figure from table 101")); v.addAttribute(new Attribute(CDM.MISSING_VALUE, (short) 999)); v.setSPobject(new Vinfo(pos)); pos += 2; v = seq.addMemberVariable(new Variable(ncfile, null, parent, "indicatorFlags", DataType.CHAR, "")); v.setDimensionsAnonymous(new int[]{2}); v.addAttribute(new Attribute(CDM.LONG_NAME, "quality marks: 0=data, 1=form")); v.setSPobject(new Vinfo(pos)); return seq; }
static Structure decodeStructure(NetcdfFile ncfile, Group g, Structure parent, NcStreamProto.Structure s) { Structure ncvar = (s.getDataType() == ucar.nc2.stream.NcStreamProto.DataType.SEQUENCE) ? new Sequence(ncfile, g, parent, s.getName()) : new Structure(ncfile, g, parent, s.getName()); ncvar.setDataType(decodeDataType(s.getDataType())); List<Dimension> dims = new ArrayList<Dimension>(6); for (ucar.nc2.stream.NcStreamProto.Dimension dim : s.getShapeList()) { Dimension ncdim = decodeDim(dim); if (!ncdim.isShared()) dims.add(ncdim); else { Dimension d = g.findDimension(ncdim.getShortName()); if (d == null) throw new IllegalStateException("Can find shared dimension " + dim.getName()); dims.add(d); } } ncvar.setDimensions(dims); for (ucar.nc2.stream.NcStreamProto.Attribute att : s.getAttsList()) ncvar.addAttribute(decodeAtt(att)); for (ucar.nc2.stream.NcStreamProto.Variable vp : s.getVarsList()) ncvar.addMemberVariable(decodeVar(ncfile, g, ncvar, vp)); for (NcStreamProto.Structure sp : s.getStructsList()) ncvar.addMemberVariable(decodeStructure(ncfile, g, ncvar, sp)); return ncvar; }
protected Sequence makeSequence(NetcdfFile ncfile) { Sequence seq = new Sequence(ncfile, null, null, RECORD); "time of stroke", null, secondsSince1970, AxisType.Time); seq.addMemberVariable(v); seq.addMemberVariable(v); seq.addMemberVariable(v); seq.addMemberVariable(v); "error ellipse semi-major axis", null, "km", null); seq.addMemberVariable(v); "error ellipse minor axis ", null, "km", null); seq.addMemberVariable(v); "error ellipse axis angle of orientation ", null, "degrees", null); seq.addMemberVariable(v); "multiplicity [#strokes per flash]", null, "", null); seq.addMemberVariable(v);
members = seq.makeStructureMembers(); for (StructureMembers.Member m : members.getMembers()) { m.setDataParam(offset); Variable mv = seq.findVariable(m.getName()); BufrConfig.FieldConverter fld = (BufrConfig.FieldConverter) mv.getSPobject(); DataDescriptor dk = fld.dds;
public Sequence(NetcdfFile ncfile, Group group, Structure parent, String shortName) { super(ncfile, group, parent, shortName); List<Dimension> dims = new ArrayList<Dimension>(); dims.add(Dimension.VLEN); setDimensions(dims); setDataType(DataType.SEQUENCE); }