@Override public Variable addVariable(Group g, Variable v) { if (!(v instanceof VariableDS) && !(v instanceof StructureDS)) throw new IllegalArgumentException("NetcdfDataset variables must be VariableEnhanced objects"); return super.addVariable(g, v); }
@Override public Variable addVariable(Group g, Variable v) { if (!(v instanceof VariableDS) && !(v instanceof StructureDS)) throw new IllegalArgumentException("NetcdfDataset variables must be VariableEnhanced objects"); return super.addVariable(g, v); }
@Override public Variable addVariable(Group g, Variable v) { if (!(v instanceof VariableDS) && !(v instanceof StructureDS)) throw new IllegalArgumentException("NetcdfDataset variables must be VariableEnhanced objects"); return super.addVariable(g, v); }
private void addGlobalAttributes(TagVGroup group) throws IOException { // look for attributes for (int i = 0; i < group.nelems; i++) { Tag tag = tagMap.get(tagid(group.elem_ref[i], group.elem_tag[i])); if (tag == null) throw new IllegalStateException(); if (tag.code == 1962) { TagVH vh = (TagVH) tag; if (vh.className.startsWith("Att")) { String lowername = vh.name.toLowerCase(); if ((vh.nfields == 1) && (H4type.setDataType(vh.fld_type[0], null) == DataType.CHAR) && ((vh.fld_isize[0] > 4000) || lowername.startsWith("archivemetadata") || lowername.startsWith("coremetadata") || lowername.startsWith("productmetadata") || lowername.startsWith("structmetadata"))) { ncfile.addVariable(null, makeVariable(vh)); // // large EOS metadata - make into variable in root group } else { Attribute att = makeAttribute(vh); if (null != att) ncfile.addAttribute(null, att); // make into attribute in root group } } } } group.used = true; }
private void addGlobalAttributes(TagVGroup group) throws IOException { // look for attributes for (int i = 0; i < group.nelems; i++) { Tag tag = tagMap.get(tagid(group.elem_ref[i], group.elem_tag[i])); if (tag == null) throw new IllegalStateException(); if (tag.code == 1962) { TagVH vh = (TagVH) tag; if (vh.className.startsWith("Att")) { String lowername = vh.name.toLowerCase(); if ((vh.nfields == 1) && (H4type.setDataType(vh.fld_type[0], null) == DataType.CHAR) && ((vh.fld_isize[0] > 4000) || lowername.startsWith("archivemetadata") || lowername.startsWith("coremetadata") || lowername.startsWith("productmetadata") || lowername.startsWith("structmetadata"))) { ncfile.addVariable(null, makeVariable(vh)); // // large EOS metadata - make into variable in root group } else { Attribute att = makeAttribute(vh); if (null != att) ncfile.addAttribute(null, att); // make into attribute in root group } } } } group.used = true; }
private void addGlobalAttributes(TagVGroup group) throws IOException { // look for attributes for (int i = 0; i < group.nelems; i++) { Tag tag = tagMap.get(tagid(group.elem_ref[i], group.elem_tag[i])); if (tag == null) throw new IllegalStateException(); if (tag.code == 1962) { TagVH vh = (TagVH) tag; if (vh.className.startsWith("Att")) { String lowername = vh.name.toLowerCase(); if ((vh.nfields == 1) && (H4type.setDataType(vh.fld_type[0], null) == DataType.CHAR) && ((vh.fld_isize[0] > 4000) || lowername.startsWith("archivemetadata") || lowername.startsWith("coremetadata") || lowername.startsWith("productmetadata") || lowername.startsWith("structmetadata"))) { ncfile.addVariable(null, makeVariable(vh)); // // large EOS metadata - make into variable in root group } else { Attribute att = makeAttribute(vh); if (null != att) ncfile.addAttribute(null, att); // make into attribute in root group } } } } group.used = true; }
public void open(RandomAccessFile raf, NetcdfFile ncfile, CancelTask cancelTask) throws IOException { this.raf = raf; this.ncfile = ncfile; init(); ncfile.addAttribute(null, new Attribute(CDM.HISTORY, "Direct read of NMC ON29 by CDM")); ncfile.addAttribute(null, new Attribute(CDM.CONVENTIONS, "Unidata")); ncfile.addAttribute(null, new Attribute(CF.FEATURE_TYPE, CF.FeatureType.timeSeriesProfile.toString())); try { ncfile.addDimension(null, new Dimension("station", stations.size())); Structure station = makeStationStructure(); ncfile.addVariable(null, station); ncfile.addDimension(null, new Dimension("report", reports.size())); Structure reportIndexVar = makeReportIndexStructure(); ncfile.addVariable(null, reportIndexVar); Structure reportVar = makeReportStructure(); ncfile.addVariable(null, reportVar); } catch (InvalidRangeException e) { log.error("open ON29 File", e); throw new IllegalStateException(e.getMessage()); } }
public void open(RandomAccessFile raf, NetcdfFile ncfile, CancelTask cancelTask) throws IOException { this.raf = raf; this.ncfile = ncfile; init(); ncfile.addAttribute(null, new Attribute(CDM.HISTORY, "Direct read of NMC ON29 by CDM")); ncfile.addAttribute(null, new Attribute(CDM.CONVENTIONS, "Unidata")); ncfile.addAttribute(null, new Attribute(CF.FEATURE_TYPE, CF.FeatureType.timeSeriesProfile.toString())); try { ncfile.addDimension(null, new Dimension("station", stations.size())); Structure station = makeStationStructure(); ncfile.addVariable(null, station); ncfile.addDimension(null, new Dimension("report", reports.size())); Structure reportIndexVar = makeReportIndexStructure(); ncfile.addVariable(null, reportIndexVar); Structure reportVar = makeReportStructure(); ncfile.addVariable(null, reportVar); } catch (InvalidRangeException e) { log.error("open ON29 File", e); throw new IllegalStateException(e.getMessage()); } }
public void open(RandomAccessFile raf, NetcdfFile ncfile, CancelTask cancelTask) throws IOException { super.open(raf, ncfile, cancelTask); init(); ncfile.addAttribute(null, new Attribute(CDM.HISTORY, "Direct read of NMC ON29 by CDM")); ncfile.addAttribute(null, new Attribute(CDM.CONVENTIONS, "Unidata")); ncfile.addAttribute(null, new Attribute(CF.FEATURE_TYPE, CF.FeatureType.timeSeriesProfile.toString())); try { ncfile.addDimension(null, new Dimension("station", stations.size())); Structure station = makeStationStructure(); ncfile.addVariable(null, station); ncfile.addDimension(null, new Dimension("report", reports.size())); Structure reportIndexVar = makeReportIndexStructure(); ncfile.addVariable(null, reportIndexVar); Structure reportVar = makeReportStructure(); ncfile.addVariable(null, reportVar); } catch (InvalidRangeException e) { log.error("open ON29 File", e); throw new IllegalStateException(e.getMessage()); } }
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 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); }
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)); }
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); }
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 void makeTimeCoordinate1D(NetcdfFile ncfile, Group g, CoordinateTime coordTime) { //}, CoordinateRuntime runtime) { int ntimes = coordTime.getSize(); String tcName = coordTime.getName(); String dims = coordTime.getName(); ncfile.addDimension(g, new Dimension(tcName, ntimes)); Variable v = ncfile.addVariable(g, new Variable(ncfile, g, null, tcName, DataType.DOUBLE, dims)); String units = coordTime.getTimeUdUnit(); v.addAttribute(new Attribute(CDM.UNITS, units)); v.addAttribute(new Attribute(CF.STANDARD_NAME, CF.TIME)); v.addAttribute(new Attribute(CDM.LONG_NAME, Grib.GRIB_VALID_TIME)); v.addAttribute(new Attribute(CF.CALENDAR, Calendar.proleptic_gregorian.toString())); double[] data = new double[ntimes]; int count = 0; // coordinate values for (int val : coordTime.getOffsetSorted()) data[count++] = val; v.setCachedData(Array.factory(DataType.DOUBLE, new int[]{ntimes}, data)); makeTimeAuxReference(ncfile, g, tcName, units, coordTime); }