/** * Flatten the Structures into a 1D array of Structures of length getTotalNumberOfStructures(). * @return Array of Structures */ public ArrayStructure flatten() { ArrayStructureW aw = new ArrayStructureW( getStructureMembers(), new int[] {total}); for (int i=0; i<total; i++) { StructureData sdata = new StructureDataA( this, i); aw.setStructureData(sdata, i); } return aw; }
/** * Flatten the Structures into a 1D array of Structures of length getTotalNumberOfStructures(). * @return Array of Structures */ public ArrayStructure flatten() { ArrayStructureW aw = new ArrayStructureW( getStructureMembers(), new int[] {total}); for (int i=0; i<total; i++) { StructureData sdata = new StructureDataA( this, i); aw.setStructureData(sdata, i); } return aw; }
/** * Flatten the Structures into a 1D array of Structures of length getTotalNumberOfStructures(). * @return Array of Structures */ public ArrayStructure flatten() { ArrayStructureW aw = new ArrayStructureW( getStructureMembers(), new int[] {total}); for (int i=0; i<total; i++) { StructureData sdata = new StructureDataA( this, i); aw.setStructureData(sdata, i); } return aw; }
public void writeRecord(String stnName, double timeCoordValue, CalendarDate obsDate, StructureData sdata) throws IOException { trackBB(null, obsDate); Integer parentIndex = stationMap.get(stnName); if (parentIndex == null) throw new RuntimeException("Cant find station " + stnName); // needs to be wrapped as an ArrayStructure, even though we are only writing one at a time. ArrayStructureW sArray = new ArrayStructureW(sdata.getStructureMembers(), new int[]{1}); sArray.setStructureData(sdata, 0); timeArray.set(0, timeCoordValue); parentArray.set(0, parentIndex); // write the recno record origin[0] = recno; try { writer.write(record, origin, sArray); writer.write(time, origin, timeArray); writer.write(stationIndex, origin, parentArray); } catch (InvalidRangeException e) { e.printStackTrace(); throw new IllegalStateException(e); } recno++; }
public void writeRecord(String stnName, Date obsDate, StructureData sdata) throws IOException { StationTracker tracker = stationMap.get(stnName); // needs to be wrapped as an ArrayStructure, even though we are only writing one at a time. ArrayStructureW sArray = new ArrayStructureW(sdata.getStructureMembers(), new int[]{1}); sArray.setStructureData(sdata, 0); // date is handled specially if ((minDate == null) || minDate.after(obsDate)) minDate = obsDate; if ((maxDate == null) || maxDate.before(obsDate)) maxDate = obsDate; timeArray.set(0, dateFormatter.toDateTimeStringISO(obsDate)); prevArray.set(0, tracker.lastChild); parentArray.set(0, tracker.parent_index); tracker.link.add(recno); tracker.lastChild = recno; tracker.numChildren++; // write the recno record origin[0] = recno; originTime[0] = recno; try { ncfile.write("record", origin, sArray); ncfile.writeStringData(timeName, originTime, timeArray); ncfile.write(prevChildName, originTime, prevArray); ncfile.write(parentName, originTime, parentArray); } catch (InvalidRangeException e) { e.printStackTrace(); throw new IllegalStateException(e); } recno++; }
public void writeRecord(String stnName, Date obsDate, StructureData sdata) throws IOException { StationTracker tracker = stationMap.get(stnName); // needs to be wrapped as an ArrayStructure, even though we are only writing one at a time. ArrayStructureW sArray = new ArrayStructureW(sdata.getStructureMembers(), new int[]{1}); sArray.setStructureData(sdata, 0); // date is handled specially if ((minDate == null) || minDate.after(obsDate)) minDate = obsDate; if ((maxDate == null) || maxDate.before(obsDate)) maxDate = obsDate; timeArray.set(0, dateFormatter.toDateTimeStringISO(obsDate)); prevArray.set(0, tracker.lastChild); parentArray.set(0, tracker.parent_index); tracker.link.add(recno); tracker.lastChild = recno; tracker.numChildren++; // write the recno record origin[0] = recno; originTime[0] = recno; try { ncfile.write("record", origin, sArray); ncfile.writeStringData(timeName, originTime, timeArray); ncfile.write(prevChildName, originTime, prevArray); ncfile.write(parentName, originTime, parentArray); } catch (InvalidRangeException e) { e.printStackTrace(); throw new IllegalStateException(e); } recno++; }
public void writeRecord(String stnName, Date obsDate, StructureData sdata) throws IOException { StationTracker tracker = stationMap.get(stnName); // needs to be wrapped as an ArrayStructure, even though we are only writing one at a time. ArrayStructureW sArray = new ArrayStructureW(sdata.getStructureMembers(), new int[]{1}); sArray.setStructureData(sdata, 0); // date is handled specially if ((minDate == null) || minDate.after(obsDate)) minDate = obsDate; if ((maxDate == null) || maxDate.before(obsDate)) maxDate = obsDate; timeArray.set(0, dateFormatter.toDateTimeStringISO(obsDate)); prevArray.set(0, tracker.lastChild); parentArray.set(0, tracker.parent_index); tracker.link.add(recno); tracker.lastChild = recno; tracker.numChildren++; // write the recno record origin[0] = recno; originTime[0] = recno; try { ncfile.write("record", origin, sArray); ncfile.writeStringData(timeName, originTime, timeArray); ncfile.write(prevChildName, originTime, prevArray); ncfile.write(parentName, originTime, parentArray); } catch (InvalidRangeException e) { e.printStackTrace(); throw new IllegalStateException(e); } recno++; }
sArray.setStructureData(sdata, 0);
sdata.setMemberData((StructureMembers.Member) memberIter.next(), sArray); asw.setStructureData(sdata, ii); ii++;
protected int writeStructureData(int recno, Structure s, StructureData sdata, Map<String, Variable> varMap) throws IOException { // write the recno record int[] origin = new int[1]; origin[0] = recno; try { if (isExtendedModel) { if (s.isUnlimited()) return writer.appendStructureData(s, sdata); // can write it all at once along unlimited dimension else { ArrayStructureW as = new ArrayStructureW(sdata.getStructureMembers(), new int[] {1}); as.setStructureData(sdata, 0); writer.write(s, origin, as); // can write it all at once along regular dimension return recno + 1; } } else { writeStructureDataClassic(varMap, origin, sdata); } } catch (InvalidRangeException e) { e.printStackTrace(); throw new IllegalStateException(e); } return recno+1; }
protected int writeStructureData(int recno, Structure s, StructureData sdata, Map<String, Variable> varMap) throws IOException { // write the recno record int[] origin = new int[1]; origin[0] = recno; try { if (isExtendedModel) { if (s.isUnlimited()) return writer.appendStructureData(s, sdata); // can write it all at once along unlimited dimension else { ArrayStructureW as = new ArrayStructureW(sdata.getStructureMembers(), new int[] {1}); as.setStructureData(sdata, 0); writer.write(s, origin, as); // can write it all at once along regular dimension return recno + 1; } } else { writeStructureDataClassic(varMap, origin, sdata); } } catch (InvalidRangeException e) { e.printStackTrace(); throw new IllegalStateException(e); } return recno+1; }
sdata.setMemberData((StructureMembers.Member) memberIter.next(), sArray); asw.setStructureData(sdata, ii); ii++;
@Override public Array sectionNoReduce(List<Range> ranges) throws InvalidRangeException { Section viewSection = new Section(ranges); ArrayStructureW result = new ArrayStructureW(this.members, viewSection.getShape()); int count = 0; Section.Iterator iter = viewSection.getIterator(getShape()); while (iter.hasNext()) { int recno = iter.next(null); StructureData sd = getStructureData(recno); result.setStructureData(sd, count++); } return result; }
@Override public Array sectionNoReduce(List<Range> ranges) throws InvalidRangeException { Section viewSection = new Section(ranges); ArrayStructureW result = new ArrayStructureW(this.members, viewSection.getShape()); int count = 0; Section.Iterator iter = viewSection.getIterator(getShape()); while (iter.hasNext()) { int recno = iter.next(null); StructureData sd = getStructureData(recno); result.setStructureData(sd, count++); } return result; }
static private ArrayStructure sectionArrayStructure(ParsedSectionSpec child, ArrayStructure innerData, StructureMembers.Member m) throws IOException, InvalidRangeException { StructureMembers membersw = new StructureMembers(m.getStructureMembers()); // no data arrays get propagated ArrayStructureW result = new ArrayStructureW(membersw, child.section.getShape()); int count = 0; Section.Iterator iter = child.section.getIterator(child.v.getShape()); while (iter.hasNext()) { int recno = iter.next(null); StructureData sd = innerData.getStructureData(recno); result.setStructureData(sd, count++); } return result; }
static private ArrayStructure sectionArrayStructure(ParsedSectionSpec child, ArrayStructure innerData, StructureMembers.Member m) throws IOException, InvalidRangeException { StructureMembers membersw = new StructureMembers(m.getStructureMembers()); // no data arrays get propagated ArrayStructureW result = new ArrayStructureW(membersw, child.section.getShape()); int count = 0; Section.Iterator iter = child.section.getIterator(child.v.getShape()); while (iter.hasNext()) { int recno = iter.next(null); StructureData sd = innerData.getStructureData(recno); result.setStructureData(sd, count++); } return result; }
static private ArrayStructure sectionArrayStructure(ParsedSectionSpec child, ArrayStructure innerData, StructureMembers.Member m) throws IOException, InvalidRangeException { StructureMembers membersw = new StructureMembers(m.getStructureMembers()); // no data arrays get propagated ArrayStructureW result = new ArrayStructureW(membersw, child.section.getShape()); int count = 0; Section.Iterator iter = child.section.getIterator(child.v.getShape()); while (iter.hasNext()) { int recno = iter.next(); StructureData sd = innerData.getStructureData(recno); result.setStructureData(sd, count++); } return result; }
public void writeRecord(double timeCoordValue, CalendarDate obsDate, EarthLocation loc, StructureData sdata) throws IOException { trackBB(loc, obsDate); // needs to be wrapped as an ArrayStructure, even though we are only writing one at a time. ArrayStructureW sArray = new ArrayStructureW(sdata.getStructureMembers(), new int[]{1}); sArray.setStructureData(sdata, 0); timeArray.set(0, timeCoordValue); latArray.set(0, loc.getLatitude()); lonArray.set(0, loc.getLongitude()); if (altUnits != null) altArray.set(0, loc.getAltitude()); // write the recno record origin[0] = recno; try { writer.write(record, origin, sArray); writer.write(time, origin, timeArray); writer.write(lat, origin, latArray); writer.write(lon, origin, lonArray); if (altUnits != null) writer.write(alt, origin, altArray); } catch (InvalidRangeException e) { e.printStackTrace(); throw new IllegalStateException(e); } recno++; }
sArray.setStructureData(recordData, 0);
sArray.setStructureData(recordData, 0);