/** * 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 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; }
/** * Add a variable with DataType = String to the file. Must be in define mode. * The variable will be stored in the file as a CHAR variable. * A new dimension with name "varName_strlen" is automatically added, with length max_strlen. * * @param varName name of Variable, must be unique within the file. * @param dims list of Dimensions for the variable, must already have been added. Use a list of length 0 * for a scalar variable. Do not include the string length dimension. * @param max_strlen maximum string length. * @return the Variable that has been added */ public Variable addStringVariable(String varName, List<Dimension> dims, int max_strlen) { if (!defineMode) throw new UnsupportedOperationException("not in define mode"); if (!N3iosp.isValidNetcdfObjectName(varName)) throw new IllegalArgumentException("illegal netCDF-3 variable name: "+varName); Variable v = new Variable(this, rootGroup, null, varName); v.setDataType(DataType.CHAR); Dimension d = addDimension(varName + "_strlen", max_strlen); ArrayList<Dimension> sdims = new ArrayList<Dimension>(dims); sdims.add(d); v.setDimensions(sdims); super.addVariable(null, 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; }
/** * 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); }
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 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); }
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); }
void addVariable(NetcdfFile nc, ArrayList dims, DoradePARM dparm) { Variable v = new Variable(nc, null, null, dparm.getName() ); v.setDataType( DataType.FLOAT ); v.setDimensions(dims); ncfile.addVariable(null, v); v.addAttribute( new Attribute(CDM.LONG_NAME, dparm.getDescription())); v.addAttribute( new Attribute(CDM.UNITS, dparm.getUnits())); String coordinates = "elevation azimuth distance_1 " + "latitudes_1 longitudes_1 altitudes_1"; v.addAttribute( new Attribute(_Coordinate.Axes, coordinates)); /* v.addAttribute( new Attribute(CDM.MISSING_VALUE, new Float(dparm.getBadDataFlag()))); v.addAttribute( new Attribute("_FillValue", new Float(dparm.getBadDataFlag()))); v.addAttribute( new Attribute("scale_factor", dparm.getUnits())); v.addAttribute( new Attribute("polarization", dparm.getUnits())); v.addAttribute( new Attribute("Frequencies_GHz", dparm.getUnits())); v.addAttribute( new Attribute("InterPulsePeriods_secs", dparm.getUnits())); v.addAttribute( new Attribute("ThresholdValue", new Float(dparm.getThresholdValue()))); v.addAttribute( new Attribute("ThresholdParamName", dparm.getthresholdParamName())); v.addAttribute( new Attribute("usedPRTs", new Integer(dparm.getusedPRTs()))); v.addAttribute( new Attribute("usedFrequencies", new Integer(dparm.getusedFrequencies()))); */ }
void addVariable(NetcdfFile nc, ArrayList dims, DoradePARM dparm) { Variable v = new Variable(nc, null, null, dparm.getName() ); v.setDataType( DataType.FLOAT ); v.setDimensions(dims); ncfile.addVariable(null, v); v.addAttribute( new Attribute(CDM.LONG_NAME, dparm.getDescription())); v.addAttribute( new Attribute(CDM.UNITS, dparm.getUnits())); String coordinates = "elevation azimuth distance_1 " + "latitudes_1 longitudes_1 altitudes_1"; v.addAttribute( new Attribute(_Coordinate.Axes, coordinates)); /* v.addAttribute( new Attribute(CDM.MISSING_VALUE, new Float(dparm.getBadDataFlag()))); v.addAttribute( new Attribute("_FillValue", new Float(dparm.getBadDataFlag()))); v.addAttribute( new Attribute("scale_factor", dparm.getUnits())); v.addAttribute( new Attribute("polarization", dparm.getUnits())); v.addAttribute( new Attribute("Frequencies_GHz", dparm.getUnits())); v.addAttribute( new Attribute("InterPulsePeriods_secs", dparm.getUnits())); v.addAttribute( new Attribute("ThresholdValue", new Float(dparm.getThresholdValue()))); v.addAttribute( new Attribute("ThresholdParamName", dparm.getthresholdParamName())); v.addAttribute( new Attribute("usedPRTs", new Integer(dparm.getusedPRTs()))); v.addAttribute( new Attribute("usedFrequencies", new Integer(dparm.getusedFrequencies()))); */ }
/** * 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); }