Variable makeMemberVariable(Group g, Structure parent) throws IOException { Variable v = makeVariable(g, parent, name, fldtypeid, ""); if (ctype.isVen) { v.setDimensions("*"); } else { try { v.setDimensionsAnonymous(dims); // LOOK no shared dimensions ? } catch (InvalidRangeException e) { e.printStackTrace(); } } return v; }
/** * Create a Variable. Also must call setDataType() and setDimensions() * * @param ncfile the containing NetcdfFile. * @param group the containing group; if null, use rootGroup * @param parent parent Structure, may be null * @param shortName variable shortName, must be unique within the Group * @param dtype the Variable's DataType * @param dims space delimited list of dimension names. may be null or "" for scalars. */ public Variable(NetcdfFile ncfile, Group group, Structure parent, String shortName, DataType dtype, String dims) { this(ncfile,group,parent,shortName); setDataType( dtype); setDimensions( dims); }
/** * Create a Variable. Also must call setDataType() and setDimensions() * * @param ncfile the containing NetcdfFile. * @param group the containing group; if null, use rootGroup * @param parent parent Structure, may be null * @param shortName variable shortName, must be unique within the Group * @param dtype the Variable's DataType * @param dims space delimited list of dimension names. may be null or "" for scalars. */ public Variable(NetcdfFile ncfile, Group group, Structure parent, String shortName, DataType dtype, String dims) { this(ncfile, group, parent, shortName); setDataType(dtype); setDimensions(dims); }
/** * Create a Variable. Also must call setDataType() and setDimensions() * * @param ncfile the containing NetcdfFile. * @param group the containing group; if null, use rootGroup * @param parent parent Structure, may be null * @param shortName variable shortName, must be unique within the Group * @param dtype the Variable's DataType * @param dims dimension names. */ public Variable(NetcdfFile ncfile, Group group, Structure parent, String shortName, DataType dtype, List<Dimension> dims) { this(ncfile, group, parent, shortName); setDataType(dtype); setDimensions(dims); }
/** * Create a Variable. Also must call setDataType() and setDimensions() * * @param ncfile the containing NetcdfFile. * @param group the containing group; if null, use rootGroup * @param parent parent Structure, may be null * @param shortName variable shortName, must be unique within the Group * @param dtype the Variable's DataType * @param dims space delimited list of dimension names. may be null or "" for scalars. */ public Variable(NetcdfFile ncfile, Group group, Structure parent, String shortName, DataType dtype, String dims) { this(ncfile, group, parent, shortName, dtype, (List<Dimension>)null); if(group == null) group = ncfile.getRootGroup(); setDimensions(Dimension.makeDimensionsList(group, dims)); }
/** * 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; }
/** * 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; }
/** * Set the dimensions using the dimensions names. The dimension is searched for recursively in the parent groups. * * @param dimString : whitespace separated list of dimension names, or '*' for Dimension.UNKNOWN, or number for anon dimension. null or empty String is a scalar. */ public void setDimensions(String dimString) { if (immutable) throw new IllegalStateException("Cant modify"); try { setDimensions(Dimension.makeDimensionsList(getParentGroup(), dimString)); //this.dimensions = Dimension.makeDimensionsList(getParentGroup(), dimString); resetShape(); } catch (IllegalStateException e) { throw new IllegalArgumentException("Variable " + getFullName() + " setDimensions = '" + dimString + "' FAILED: " + e.getMessage() + " file = " + getDatasetLocation()); } }
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); }
/** * Create a new Variable of type Datatype.CHAR, 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 dims list of dimension names * @param strlen dimension length of the inner (fastest changing) dimension * @return the new Variable */ public Variable addStringVariable(Group g, String shortName, String dims, int strlen) { if (immutable) throw new IllegalStateException("Cant modify"); if (g == null) g = rootGroup; String dimName = shortName + "_strlen"; addDimension(g, new Dimension(dimName, strlen)); Variable v = new Variable(this, g, null, shortName); v.setDataType(DataType.CHAR); v.setDimensions(dims + " " + dimName); g.addVariable(v); return v; }
/** * Create a new Variable of type Datatype.CHAR, 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 dims list of dimension names * @param strlen dimension length of the inner (fastest changing) dimension * @return the new Variable */ public Variable addStringVariable(Group g, String shortName, String dims, int strlen) { if (immutable) throw new IllegalStateException("Cant modify"); if (g == null) g = rootGroup; String dimName = shortName + "_strlen"; addDimension(g, new Dimension(dimName, strlen)); Variable v = new Variable(this, g, null, shortName); v.setDataType(DataType.CHAR); v.setDimensions(dims + " " + dimName); g.addVariable(v); return v; }
/** * Create a new Variable of type Datatype.CHAR, 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 dims list of dimension names * @param strlen dimension length of the inner (fastest changing) dimension * @return the new Variable */ public Variable addStringVariable(Group g, String shortName, String dims, int strlen) { if (immutable) throw new IllegalStateException("Cant modify"); if (g == null) g = rootGroup; String dimName = shortName + "_strlen"; addDimension(g, new Dimension(dimName, strlen)); Variable v = new Variable(this, g, null, shortName); v.setDataType(DataType.CHAR); v.setDimensions(dims + " " + dimName); g.addVariable(v); return v; }
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 makeVariableNoCoords(NetcdfFile ncfile, int datatype, String shortName, String longName, Variable from) { Variable v = new Variable(ncfile, null, null, shortName); v.setDataType(DataType.BYTE); v.setDimensions( from.getDimensions()); ncfile.addVariable(null, v); v.addAttribute( new Attribute(CDM.UNITS, Cinrad2Record.getDatatypeUnits(datatype))); v.addAttribute( new Attribute(CDM.LONG_NAME, longName)); byte[] b = new byte[2]; b[0] = Cinrad2Record.MISSING_DATA; b[1] = Cinrad2Record.BELOW_THRESHOLD; Array missingArray = Array.factory(DataType.BYTE.getPrimitiveClassType(), new int[] {2}, b); v.addAttribute( new Attribute(CDM.MISSING_VALUE, missingArray)); v.addAttribute( new Attribute("signal_below_threshold", new Byte( Cinrad2Record.BELOW_THRESHOLD))); v.addAttribute( new Attribute(CDM.SCALE_FACTOR, new Float( Cinrad2Record.getDatatypeScaleFactor(datatype)))); v.addAttribute( new Attribute(CDM.ADD_OFFSET, new Float( Cinrad2Record.getDatatypeAddOffset(datatype)))); v.addAttribute( new Attribute(CDM.UNSIGNED, "true")); Attribute fromAtt = from.findAttribute(_Coordinate.Axes); v.addAttribute( new Attribute(_Coordinate.Axes, fromAtt)); Vgroup vgFrom = (Vgroup) from.getSPobject(); Vgroup vg = new Vgroup(datatype, vgFrom.map); v.setSPobject( vg); }
public boolean syncExtend() throws IOException { //unlocked = false; if (agg != null) return agg.syncExtend(); // synch orgFile if it has an unlimited dimension if (orgFile != null) { boolean wasExtended = orgFile.syncExtend(); // propagate changes. LOOK rather ad-hoc if (wasExtended) { Dimension ndim = orgFile.getUnlimitedDimension(); int newLength = ndim.getLength(); Dimension udim = getUnlimitedDimension(); udim.setLength(newLength); for (Variable v : getVariables()) { if (v.isUnlimited()) // set it in all of the record variables v.setDimensions(v.getDimensions()); } return true; } } return false; }
/** * Add coordinate system variable * * @param ncfile netCDF file * @param name name of the variable * @param dims dimensions */ private void addCoordSystemVariable(NetcdfFile ncfile, String name, String dims) { Variable v = new Variable(ncfile, g, null, name); v.setDataType(DataType.CHAR); v.setDimensions(""); // scalar Array dataArray = Array.factory(DataType.CHAR, new int[0], new char[]{'0'}); v.setCachedData(dataArray, false); v.addAttribute(new Attribute(_Coordinate.Axes, dims)); if (isLatLon()) v.addAttribute(new Attribute(_Coordinate.Transforms, "")); // to make sure its identified as a Coordinate System Variable else v.addAttribute(new Attribute(_Coordinate.Transforms, getGridName())); addGDSparams(v); ncfile.addVariable(g, v); }