protected Variable copy() { return new Variable(this); }
protected Variable copy() { return new Variable(this); }
protected Variable copy() { return new Variable(this); }
public Variable addStructureMember(Structure s, String shortName, DataType dtype, String dims) { if (!defineMode) throw new UnsupportedOperationException("not in define mode"); shortName = makeValidObjectName(shortName); if (!version.isExtendedModel()) throw new IllegalArgumentException("Structure type only supported in extended model, version="+version); Variable m = new Variable(ncfile, null, s, shortName, dtype, dims); return s.addMemberVariable(m); }
/** * Create a new Variable, and add to the given group. * * @param g add to this group. If group is null, use root group * @param shortName short name of the Variable * @param dtype data type of the Variable * @param dims list of dimension names * @return the new Variable */ public Variable addVariable(Group g, String shortName, DataType dtype, String dims) { if (immutable) throw new IllegalStateException("Cant modify"); if (g == null) g = rootGroup; Variable v = new Variable(this, g, null, shortName); v.setDataType(dtype); v.setDimensions(dims); g.addVariable(v); return v; }
/** * Create a new Variable, and add to the given group. * * @param g add to this group. If group is null, use root group * @param shortName short name of the Variable * @param dtype data type of the Variable * @param dims list of dimension names * @return the new Variable */ public Variable addVariable(Group g, String shortName, DataType dtype, String dims) { if (immutable) throw new IllegalStateException("Cant modify"); if (g == null) g = rootGroup; Variable v = new Variable(this, g, null, shortName); v.setDataType(dtype); v.setDimensions(dims); g.addVariable(v); return v; }
public Variable addStructureMember(Structure s, String shortName, DataType dtype, String dims) { if (!defineMode) throw new UnsupportedOperationException("not in define mode"); shortName = makeValidObjectName(shortName); if (!version.isExtendedModel()) throw new IllegalArgumentException("Structure type only supported in extended model, version="+version); Variable m = new Variable(ncfile, null, s, shortName, dtype, dims); // LOOK: What if dtype == STRUCTURE? s.addMemberVariable(m); // We've added a member to s. Recalculate its size and all ancestor structure sizes. for (Structure struct = s; struct != null; struct = struct.getParentStructure()) { struct.calcElementSize(); } return m; }
private void addDpiSequence(Structure parent, BufrConfig.FieldConverter fld) { Structure struct = new Structure(ncfile, null, parent, "statistics"); try { struct.setDimensionsAnonymous(new int[]{fld.dds.replication}); // scalar } catch (InvalidRangeException e) { e.printStackTrace(); } Variable v = new Variable(ncfile, null, struct, "name"); v.setDataType(DataType.STRING); // scalar v.setDimensions(""); // scalar struct.addMemberVariable(v); v = new Variable(ncfile, null, struct, "data"); v.setDataType(DataType.FLOAT); // scalar v.setDimensions(""); // scalar struct.addMemberVariable(v); parent.addMemberVariable(struct); }
private void addDpiSequence(Structure parent, DataDescriptor dataDesc) { Structure struct = new Structure(ncfile, null, parent, "statistics"); try { struct.setDimensionsAnonymous(new int[] {dataDesc.replication}); // scalar } catch (InvalidRangeException e) { e.printStackTrace(); } Variable v = new Variable(ncfile, null, struct, "name"); v.setDataType(DataType.STRING); // scalar v.setDimensions(""); // scalar struct.addMemberVariable(v); v = new Variable(ncfile, null, struct, "data"); v.setDataType(DataType.FLOAT); // scalar v.setDimensions(""); // scalar struct.addMemberVariable(v); parent.addMemberVariable(struct); }
private void makeEnsembleCoordinate(NetcdfFile ncfile, Group g, CoordinateEns ec) { int n = ec.getSize(); String ecName = ec.getName().toLowerCase(); ncfile.addDimension(g, new Dimension(ecName, n)); Variable v = new Variable(ncfile, g, null, ecName, DataType.INT, ecName); ncfile.addVariable(g, v); v.addAttribute(new Attribute(_Coordinate.AxisType, AxisType.Ensemble.toString())); int[] data = new int[n]; int count = 0; for (EnsCoord.Coord ecc : ec.getEnsSorted()) data[count++] = ecc.getEnsMember(); v.setCachedData(Array.factory(DataType.INT, new int[]{n}, data)); }
void addParameter(String pName, String longName, NetcdfFile nc, ArrayList dims, Attribute att, DataType dtype, String ut) { String vName = pName; Variable vVar = new Variable(nc, null, null, vName); vVar.setDataType(dtype); if( dims != null ) vVar.setDimensions(dims); else vVar.setDimensions(""); if(att != null ) vVar.addAttribute(att); vVar.addAttribute( new Attribute(CDM.UNITS, ut)); vVar.addAttribute( new Attribute(CDM.LONG_NAME, longName)); nc.addVariable(null, vVar); }
void addParameter(String pName, String longName, NetcdfFile nc, ArrayList dims, Attribute att, DataType dtype, String ut) { String vName = pName; Variable vVar = new Variable(nc, null, null, vName); vVar.setDataType(dtype); if( dims != null ) vVar.setDimensions(dims); else vVar.setDimensions(""); if(att != null ) vVar.addAttribute(att); vVar.addAttribute( new Attribute(CDM.UNITS, ut)); vVar.addAttribute( new Attribute(CDM.LONG_NAME, longName)); nc.addVariable(null, vVar); }
void addParameter(String pName, String longName, NetcdfFile nc, ArrayList dims, Attribute att, DataType dtype, String ut) { Variable vVar = new Variable(nc, null, null, pName); vVar.setDataType(dtype); if (dims != null) vVar.setDimensions(dims); else vVar.setDimensions(""); if (att != null) vVar.addAttribute(att); vVar.addAttribute(new Attribute(CDM.UNITS, ut)); vVar.addAttribute(new Attribute(CDM.LONG_NAME, longName)); nc.addVariable(null, vVar); }
private Structure makeReportIndexStructure() throws IOException { Structure reportIndex = new Structure(ncfile, null, null, BufrIosp.obsIndex); ncfile.addVariable(null, reportIndex); reportIndex.setDimensions("record"); reportIndex.addAttribute(new Attribute("long_name", "index on report")); Variable v = reportIndex.addMemberVariable(new Variable(ncfile, null, reportIndex, "name", DataType.STRING, "")); v.addAttribute(new Attribute("long_name", "name of station")); v.addAttribute(new Attribute("standard_name", "station_name")); v = reportIndex.addMemberVariable(new Variable(ncfile, null, reportIndex, "time", DataType.LONG, "")); v.addAttribute(new Attribute("units", "msecs since 1970-01-01 00:00")); v.addAttribute(new Attribute("long_name", "observation time")); v.addAttribute(new Attribute(_Coordinate.AxisType, "Time")); return reportIndex; }
private Variable makeMember(Structure s, String shortName, DataType dataType, String dims, String longName, String units, String cfName, AxisType atype) { Variable v = new Variable(ncfile, null, s, shortName, dataType, dims); v.addAttribute(new Attribute(CDM.LONG_NAME, longName)); if (cfName != null) v.addAttribute(new Attribute(CF.STANDARD_NAME, cfName)); if (units != null) v.addAttribute(new Attribute(CDM.UNITS, units)); if (atype != null) v.addAttribute(new Attribute(_Coordinate.AxisType, atype.toString())); s.addMemberVariable(v); return v; }
private Variable makeMember(Structure s, String shortName, DataType dataType, String dims, String longName, String units, String cfName, AxisType atype) { Variable v = new Variable(ncfile, null, s, shortName, dataType, dims); v.addAttribute(new Attribute(CDM.LONG_NAME, longName)); if (cfName != null) v.addAttribute(new Attribute(CF.STANDARD_NAME, cfName)); if (units != null) v.addAttribute(new Attribute(CDM.UNITS, units)); if (atype != null) v.addAttribute(new Attribute(_Coordinate.AxisType, atype.toString())); s.addMemberVariable(v); return v; }
private Variable makeMember(Structure s, String shortName, DataType dataType, String dims, String longName, String units, String cfName, AxisType atype) { Variable v = new Variable(ncfile, null, s, shortName, dataType, dims); v.addAttribute(new Attribute(CDM.LONG_NAME, longName)); if (cfName != null) v.addAttribute(new Attribute(CF.STANDARD_NAME, cfName)); if (units != null) v.addAttribute(new Attribute(CDM.UNITS, units)); if (atype != null) v.addAttribute(new Attribute(_Coordinate.AxisType, atype.toString())); s.addMemberVariable(v); return v; }
private Structure makeReportIndexStructure() throws InvalidRangeException, IOException { Structure reportIndex = new Structure(ncfile, null, null, "reportIndex"); reportIndex.setDimensions("report"); reportIndex.addAttribute(new Attribute(CDM.LONG_NAME, "index on report - in memory")); int pos = 0; Variable v = reportIndex.addMemberVariable(new Variable(ncfile, null, reportIndex, "stationName", DataType.CHAR, "")); v.setDimensionsAnonymous(new int[]{6}); v.addAttribute(new Attribute(CDM.LONG_NAME, "name of station")); v.addAttribute(new Attribute("standard_name", "station_name")); v.setSPobject(new Vinfo(pos)); pos += 6; v = reportIndex.addMemberVariable(new Variable(ncfile, null, reportIndex, "time", DataType.INT, "")); v.addAttribute(new Attribute(CDM.UNITS, "secs since 1970-01-01 00:00")); v.addAttribute(new Attribute(CDM.LONG_NAME, "observation time")); v.setSPobject(new Vinfo(pos)); return reportIndex; }
private Structure makeReportIndexStructure() throws InvalidRangeException, IOException { Structure reportIndex = new Structure(ncfile, null, null, "reportIndex"); reportIndex.setDimensions("report"); reportIndex.addAttribute(new Attribute(CDM.LONG_NAME, "index on report - in memory")); int pos = 0; Variable v = reportIndex.addMemberVariable(new Variable(ncfile, null, reportIndex, "stationName", DataType.CHAR, "")); v.setDimensionsAnonymous(new int[]{6}); v.addAttribute(new Attribute(CDM.LONG_NAME, "name of station")); v.addAttribute(new Attribute("standard_name", "station_name")); v.setSPobject(new Vinfo(pos)); pos += 6; v = reportIndex.addMemberVariable(new Variable(ncfile, null, reportIndex, "time", DataType.INT, "")); v.addAttribute(new Attribute(CDM.UNITS, "secs since 1970-01-01 00:00")); v.addAttribute(new Attribute(CDM.LONG_NAME, "observation time")); v.setSPobject(new Vinfo(pos)); return reportIndex; }
private void makeTimeAuxReference(NetcdfFile ncfile, Group g, String timeName, String units, CoordinateTimeAbstract time) { if (time.getTime2runtime() == null) return; String tcName = "ref"+timeName; Variable v = ncfile.addVariable(g, new Variable(ncfile, g, null, tcName, DataType.DOUBLE, timeName)); v.addAttribute(new Attribute(CF.STANDARD_NAME, CF.TIME_REFERENCE)); v.addAttribute(new Attribute(CDM.LONG_NAME, Grib.GRIB_RUNTIME)); v.addAttribute(new Attribute(CF.CALENDAR, Calendar.proleptic_gregorian.toString())); v.addAttribute(new Attribute(CDM.UNITS, units)); // lazy evaluation v.setSPobject(new Time2Dinfo(Time2DinfoType.timeAuxRef, null, time)); }