void setVariable(Variable v) { this.v = v; v.setSPobject(this); }
void setVariable(Variable v) { this.v = v; v.setSPobject(this); }
void setVariable(Variable v) { this.v = v; v.setSPobject(this); }
private void addMember(Structure parent, BufrConfig.FieldConverter fld) { DataDescriptor dkey = fld.dds; if (dkey.replication == 0) addSequence(parent, fld); else if (dkey.replication > 1) { List<DataDescriptor> subKeys = dkey.subKeys; if (subKeys.size() == 1) { BufrConfig.FieldConverter subFld = fld.flds.get(0); Variable v = addVariable(parent, subFld, dkey.replication); v.setSPobject(fld); // set the replicating field as SPI object } else { addStructure(parent, fld, dkey.replication); } } else { addVariable(parent, fld, dkey.replication); } }
private void addMember(Structure parent, DataDescriptor dkey) { if (dkey.replication == 0) addSequence(parent, dkey); else if (dkey.replication > 1) { List<DataDescriptor> subKeys = dkey.subKeys; if (subKeys.size() == 1) { DataDescriptor sub = dkey.subKeys.get(0); Variable v = addVariable(parent, sub, dkey.replication); v.setSPobject(dkey); // set the replicating dkey as SPI object } else { addStructure(parent, dkey, dkey.replication); } } else { addVariable(parent, dkey, dkey.replication); } }
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 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); }
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; }
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; }
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 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 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)); pos += 4; return reportIndex; }
Structure makeStructure(Structure parent) throws InvalidRangeException { Sequence seq = new Sequence(ncfile, null, parent, "clouds"); seq.addAttribute(new Attribute(CDM.LONG_NAME, catNames[7])); int pos = 0; Variable v = seq.addMemberVariable(new Variable(ncfile, null, parent, "pressure", DataType.FLOAT, "")); v.addAttribute(new Attribute(CDM.UNITS, "mbars")); v.addAttribute(new Attribute(CDM.LONG_NAME, "pressure level")); v.addAttribute(new Attribute(_Coordinate.AxisType, AxisType.Pressure.toString())); v.setSPobject(new Vinfo(pos)); pos += 4; v = seq.addMemberVariable(new Variable(ncfile, null, parent, "percentClouds", DataType.SHORT, "")); v.addAttribute(new Attribute(CDM.UNITS, "")); v.addAttribute(new Attribute(CDM.LONG_NAME, "amount of cloudiness (%)")); v.addAttribute(new Attribute(CDM.MISSING_VALUE, (short) 999)); v.setSPobject(new Vinfo(pos)); pos += 2; v = seq.addMemberVariable(new Variable(ncfile, null, parent, "qualityFlags", DataType.CHAR, "")); v.setDimensionsAnonymous(new int[]{2}); v.addAttribute(new Attribute(CDM.LONG_NAME, "quality marks: 0=pressure, 1=percentClouds")); v.setSPobject(new Vinfo(pos)); return seq; }
Structure makeStructure(Structure parent) throws InvalidRangeException { Sequence seq = new Sequence(ncfile, null, parent, "clouds"); seq.addAttribute(new Attribute(CDM.LONG_NAME, catNames[7])); int pos = 0; Variable v = seq.addMemberVariable(new Variable(ncfile, null, parent, "pressure", DataType.FLOAT, "")); v.addAttribute(new Attribute(CDM.UNITS, "mbars")); v.addAttribute(new Attribute(CDM.LONG_NAME, "pressure level")); v.addAttribute(new Attribute(_Coordinate.AxisType, AxisType.Pressure.toString())); v.setSPobject(new Vinfo(pos)); pos += 4; v = seq.addMemberVariable(new Variable(ncfile, null, parent, "percentClouds", DataType.SHORT, "")); v.addAttribute(new Attribute(CDM.UNITS, "")); v.addAttribute(new Attribute(CDM.LONG_NAME, "amount of cloudiness (%)")); v.addAttribute(new Attribute(CDM.MISSING_VALUE, (short) 999)); v.setSPobject(new Vinfo(pos)); pos += 2; v = seq.addMemberVariable(new Variable(ncfile, null, parent, "qualityFlags", DataType.CHAR, "")); v.setDimensionsAnonymous(new int[]{2}); v.addAttribute(new Attribute(CDM.LONG_NAME, "quality marks: 0=pressure, 1=percentClouds")); v.setSPobject(new Vinfo(pos)); return seq; }
private Variable makeVariableMember(Group g, Structure s, String name, long dataPos, MessageDatatype mdt) throws IOException { Variable v; Vinfo vinfo = new Vinfo(mdt, null, dataPos); // LOOK need mds if (vinfo.getNCDataType() == null) { debugOut.println("SKIPPING DataType= " + vinfo.typeInfo.hdfType + " for variable " + name); return null; } if (mdt.type == 6) { v = new Structure(ncfile, g, s, name); makeVariableShapeAndType(v, mdt, null, vinfo, null); addMembersToStructure(g, (Structure) v, vinfo, mdt); v.setElementSize(mdt.byteSize); } else { v = new Variable(ncfile, g, s, name); makeVariableShapeAndType(v, mdt, null, vinfo, null); } // special case of variable length strings if (v.getDataType() == DataType.STRING) v.setElementSize(16); // because the array has elements that are HeapIdentifier v.setSPobject(vinfo); vinfo.setOwner(v); if (vinfo.typeInfo.unsigned) v.addAttribute(new Attribute(CDM.UNSIGNED, "true")); return v; }
Structure makeStructure(Structure parent) throws InvalidRangeException { Sequence seq = new Sequence(ncfile, null, parent, "clouds"); seq.addAttribute(new Attribute(CDM.LONG_NAME, catNames[7])); int pos = 0; Variable v = seq.addMemberVariable(new Variable(ncfile, null, parent, "pressure", DataType.FLOAT, "")); v.addAttribute(new Attribute(CDM.UNITS, "mbars")); v.addAttribute(new Attribute(CDM.LONG_NAME, "pressure level")); v.addAttribute(new Attribute(_Coordinate.AxisType, AxisType.Pressure.toString())); v.setSPobject(new Vinfo(pos)); pos += 4; v = seq.addMemberVariable(new Variable(ncfile, null, parent, "percentClouds", DataType.SHORT, "")); v.addAttribute(new Attribute(CDM.UNITS, "")); v.addAttribute(new Attribute(CDM.LONG_NAME, "amount of cloudiness (%)")); v.addAttribute(new Attribute(CDM.MISSING_VALUE, (short) 999)); v.setSPobject(new Vinfo(pos)); pos += 2; v = seq.addMemberVariable(new Variable(ncfile, null, parent, "qualityFlags", DataType.CHAR, "")); v.setDimensionsAnonymous(new int[]{2}); v.addAttribute(new Attribute(CDM.LONG_NAME, "quality marks: 0=pressure, 1=percentClouds")); v.setSPobject(new Vinfo(pos)); pos += 2; return seq; }
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)); }
/** * adding new variable to the netcdf file * @param pName variable name * @param longName variable long name * @param nc netcdf file * @param dims variable dimensions * @param coordinates variable coordinate * @param dtype variable type * @param ut unit string * @param hoff header offset * @param hedsiz header size * @param isZ is compressed file * @param nlevel calibrated level number * @param levels calibrate levels * @param iscale is scale variable */ void addVariable(String pName, String longName, NetcdfFile nc, ArrayList dims, String coordinates, DataType dtype, String ut, long hoff, long hedsiz, boolean isZ, int nlevel, int[] levels, int iscale) { Variable v = new Variable(nc, null, null, pName); v.setDataType(dtype); v.setDimensions(dims); ncfile.addVariable(null, v); v.addAttribute( new Attribute(CDM.LONG_NAME, longName)); v.addAttribute( new Attribute(CDM.UNITS, ut)); v.addAttribute( new Attribute(_Coordinate.Axes, coordinates)); v.setSPobject( new Vinfo (numX, numX0, numY, numY0, hoff, hedsiz, isR, isZ, null, levels, iscale, nlevel)); }
private void makeRuntimeCoordinate(NetcdfFile ncfile, Group g, CoordinateRuntime rtc) { int n = rtc.getSize(); boolean isScalar = (n == 1); // this is the case of runtime[1] String tcName = rtc.getName(); String dims = isScalar ? null : rtc.getName(); // null means scalar if (!isScalar) ncfile.addDimension(g, new Dimension(tcName, n)); Variable v = ncfile.addVariable(g, new Variable(ncfile, g, null, tcName, DataType.DOUBLE, dims)); v.addAttribute(new Attribute(CDM.UNITS, rtc.getUnit())); 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())); /* String vsName = tcName + "_ISO"; Variable vs = ncfile.addVariable(g, new Variable(ncfile, g, null, vsName, DataType.STRING, dims)); vs.addAttribute(new Attribute(CDM.UNITS, "ISO8601")); v.addAttribute(new Attribute(CDM.LONG_NAME, "GRIB reference time")); v.addAttribute(new Attribute(CF.CALENDAR, Calendar.proleptic_gregorian.toString())); // coordinate values String[] dataS = new String[n]; int count = 0; for (CalendarDate val : rtc.getRuntimesSorted()) { dataS[count++] = val.toString(); } vs.setCachedData(Array.factory(DataType.STRING, isScalar ? new int[0] : new int[]{n}, dataS)); */ // lazy eval v.setSPobject(new Time2Dinfo(Time2DinfoType.reftime, null, rtc)); }