public List<Dimension> getDimensions() { return v.getDimensions(); } public List<Attribute> getAttributes() { return v.getAttributes(); }
public List<Dimension> getDimensions() { return v.getDimensions(); } public List<Attribute> getAttributes() { return v.getAttributes(); }
public List<Dimension> getDimensions() { return v.getDimensions(); } public List<Attribute> getAttributes() { return v.getAttributes(); }
protected void addDimensionsClassic(List<? extends VariableSimpleIF> vars, Map<String, Dimension> dimMap) throws IOException { Set<Dimension> oldDims = new HashSet<>(20); // find all dimensions needed by these variables for (VariableSimpleIF var : vars) { List<Dimension> dims = var.getDimensions(); oldDims.addAll(dims); } // add them for (Dimension d : oldDims) { // The dimension we're creating below will be shared, so we need an appropriate name for it. String dimName = getSharedDimName(d); if (!writer.hasDimension(null, dimName)) { Dimension newDim = writer.addDimension(null, dimName, d.getLength(), false, d.isVariableLength()); dimMap.put(dimName, newDim); } } }
protected void addDimensionsClassic(List<? extends VariableSimpleIF> vars, Map<String, Dimension> dimMap) throws IOException { Set<Dimension> oldDims = new HashSet<>(20); // find all dimensions needed by these variables for (VariableSimpleIF var : vars) { List<Dimension> dims = var.getDimensions(); oldDims.addAll(dims); } // add them for (Dimension d : oldDims) { // The dimension we're creating below will be shared, so we need an appropriate name for it. String dimName = getSharedDimName(d); if (!writer.hasDimension(null, dimName)) { Dimension newDim = writer.addDimension(null, dimName, d.getLength(), true, false, d.isVariableLength()); dimMap.put(dimName, newDim); } } }
public void getDetailInfo( java.util.Formatter sf) { sf.format("FeatureDataset on location= %s%n", getLocation()); sf.format(" featureType= %s%n",getFeatureType()); sf.format(" title= %s%n",getTitle()); sf.format(" desc= %s%n",getDescription()); sf.format(" range= %s%n",getCalendarDateRange()); sf.format(" start= %s%n", getCalendarDateEnd()); sf.format(" end = %s%n",getCalendarDateEnd()); LatLonRect bb = getBoundingBox(); sf.format(" bb = %s%n", bb); if (bb != null) sf.format(" bb = %s%n",getBoundingBox().toString2()); sf.format(" has netcdf = %b%n", (getNetcdfFile() != null)); List<Attribute> ga = getGlobalAttributes(); if (ga.size() > 0) { sf.format(" Attributes%n"); for (Attribute a : ga) sf.format(" %s%n",a); } List<VariableSimpleIF> vars = getDataVariables(); sf.format("%n Data Variables (%d)%n",vars.size()); for (VariableSimpleIF v : vars) { sf.format(" name='%s' desc='%s' units=%s' type='%s' dims=(", v.getShortName(), v.getDescription(), v.getUnitsString(), v.getDataType()); for (Dimension d : v.getDimensions()) sf.format("%s ", d); sf.format(")%n"); } if (parseInfo.toString().length() > 0) sf.format("%nparseInfo=%n%s%n", parseInfo); }
public void getDetailInfo( java.util.Formatter sf) { sf.format("FeatureDataset on location= %s%n", getLocation()); sf.format(" featureType= %s%n",getFeatureType()); sf.format(" title= %s%n",getTitle()); sf.format(" desc= %s%n",getDescription()); sf.format(" range= %s%n",getCalendarDateRange()); sf.format(" start= %s%n", getCalendarDateEnd()); sf.format(" end = %s%n",getCalendarDateEnd()); LatLonRect bb = getBoundingBox(); sf.format(" bb = %s%n", bb); if (bb != null) sf.format(" bb = %s%n",getBoundingBox().toString2()); sf.format(" has netcdf = %b%n", (getNetcdfFile() != null)); List<Attribute> ga = getGlobalAttributes(); if (ga.size() > 0) { sf.format(" Attributes%n"); for (Attribute a : ga) sf.format(" %s%n",a); } List<VariableSimpleIF> vars = getDataVariables(); sf.format("%n Data Variables (%d)%n",vars.size()); for (VariableSimpleIF v : vars) { sf.format(" name='%s' desc='%s' units=%s' type='%s' dims=(", v.getShortName(), v.getDescription(), v.getUnitsString(), v.getDataType()); for (Dimension d : v.getDimensions()) sf.format("%s ", d); sf.format(")%n"); } if (parseInfo.toString().length() > 0) sf.format("%nparseInfo=%n%s%n", parseInfo); }
protected void addExtraVariables() throws IOException { if (extra == null) return; if (extraMap == null) extraMap = new HashMap<>(); addDimensionsClassic(extra, dimMap); for (VariableSimpleIF vs : extra) { List<Dimension> dims = makeDimensionList(dimMap, vs.getDimensions()); Variable mv = writer.addVariable(null, vs.getShortName(), vs.getDataType(), dims); for (Attribute att : vs.getAttributes()) mv.addAttribute(att); extraMap.put(mv.getShortName(), mv); } }
protected void addExtraVariables() throws IOException { if (extra == null) return; if (extraMap == null) extraMap = new HashMap<>(); addDimensionsClassic(extra, dimMap); for (VariableSimpleIF vs : extra) { List<Dimension> dims = makeDimensionList(dimMap, vs.getDimensions()); Variable mv = writer.addVariable(null, vs.getShortName(), vs.getDataType(), dims); for (Attribute att : vs.getAttributes()) mv.addAttribute(att); extraMap.put(mv.getShortName(), mv); } }
private void createDataVariables(List<VariableSimpleIF> dataVars) throws IOException { // find all dimensions needed by the data variables for (VariableSimpleIF var : dataVars) { List<Dimension> dims = var.getDimensions(); dimSet.addAll(dims); } // add them for (Dimension d : dimSet) { if (!d.isUnlimited()) ncfile.addDimension(d.getShortName(), d.getLength(), d.isShared(), false, d.isVariableLength()); } // add the data variables all using the record dimension for (VariableSimpleIF oldVar : dataVars) { List<Dimension> dims = oldVar.getDimensions(); StringBuilder dimNames = new StringBuilder(recordDimName); for (Dimension d : dims) { if (!d.isUnlimited()) dimNames.append(" ").append(d.getShortName()); } Variable newVar = ncfile.addVariable(oldVar.getShortName(), oldVar.getDataType(), dimNames.toString()); List<Attribute> atts = oldVar.getAttributes(); for (Attribute att : atts) { ncfile.addVariableAttribute(newVar, att); } } }
protected void addCoordinatesExtended(Structure parent, List<VariableSimpleIF> coords) throws IOException { for (VariableSimpleIF vs : coords) { String dims = Dimension.makeDimensionsString(vs.getDimensions()); Variable member = writer.addStructureMember(parent, vs.getShortName(), vs.getDataType(), dims); if (member == null) { logger.warn("Variable already exists =" + vs.getShortName()); // LOOK barf continue; } for (Attribute att : vs.getAttributes()) member.addAttribute(att); } }
private void createDataVariables(List<VariableSimpleIF> dataVars) throws IOException { // find all dimensions needed by the data variables for (VariableSimpleIF var : dataVars) { List<Dimension> dims = var.getDimensions(); dimSet.addAll(dims); } // add them for (Dimension d : dimSet) { if (!d.isUnlimited()) ncfile.addDimension(d.getShortName(), d.getLength(), d.isShared(), false, d.isVariableLength()); } // add the data variables all using the record dimension for (VariableSimpleIF oldVar : dataVars) { List<Dimension> dims = oldVar.getDimensions(); StringBuilder dimNames = new StringBuilder(recordDimName); for (Dimension d : dims) { if (!d.isUnlimited()) dimNames.append(" ").append(d.getShortName()); } Variable newVar = ncfile.addVariable(oldVar.getShortName(), oldVar.getDataType(), dimNames.toString()); List<Attribute> atts = oldVar.getAttributes(); for (Attribute att : atts) { ncfile.addVariableAttribute(newVar, att); } } }
private void createDataVariables(List<VariableSimpleIF> dataVars) throws IOException { // find all dimensions needed by the data variables for (VariableSimpleIF var : dataVars) { List<Dimension> dims = var.getDimensions(); dimSet.addAll(dims); } // add them for (Dimension d : dimSet) { if (!d.isUnlimited()) ncfile.addDimension(d.getShortName(), d.getLength(), d.isShared(), false, d.isVariableLength()); } // add the data variables all using the record dimension for (VariableSimpleIF oldVar : dataVars) { List<Dimension> dims = oldVar.getDimensions(); StringBuilder dimNames = new StringBuilder(recordDimName); for (Dimension d : dims) { if (!d.isUnlimited()) dimNames.append(" ").append(d.getShortName()); } Variable newVar = ncfile.addVariable(oldVar.getShortName(), oldVar.getDataType(), dimNames.toString()); List<Attribute> atts = oldVar.getAttributes(); for (Attribute att : atts) { ncfile.addVariableAttribute(newVar, att); } } }
protected void replaceDataVars(StructureMembers sm) { for (StructureMembers.Member m : sm.getMembers()) { VariableSimpleIF org = this.cols.get(m.getName()); int rank = org.getRank(); List<Dimension> orgDims = org.getDimensions(); // only keep the last n int n = m.getShape().length; List<Dimension> dims = orgDims.subList(rank-n, rank); VariableSimpleImpl result = new VariableSimpleImpl(org.getShortName(), org.getDescription(), org.getUnitsString(), org.getDataType(), dims); for (Attribute att : org.getAttributes()) result.add(att); this.cols.put(m.getName(), result); } }
protected void addCoordinatesExtended(Structure parent, List<VariableSimpleIF> coords) throws IOException { for (VariableSimpleIF vs : coords) { String dims = Dimension.makeDimensionsString(vs.getDimensions()); Variable member = writer.addStructureMember(parent, vs.getShortName(), vs.getDataType(), dims); if (member == null) { logger.warn("Variable already exists =" + vs.getShortName()); // LOOK barf continue; } for (Attribute att : vs.getAttributes()) member.addAttribute(att); } parent.calcElementSize(); }
private void createDataVariables(List<VariableSimpleIF> dataVars) throws IOException { String coordNames = timeName + " " + latName +" "+ lonName; if (altUnits != null) coordNames = coordNames +" " + altName; // find all dimensions needed by the data variables for (VariableSimpleIF var : dataVars) { List<Dimension> dims = var.getDimensions(); dimSet.addAll(dims); } // add them for (Dimension d : dimSet) { if (!d.isUnlimited()) writer.addDimension(null, d.getShortName(), d.getLength(), d.isShared(), false, d.isVariableLength()); } // add the data variables all using the record dimension for (VariableSimpleIF oldVar : dataVars) { List<Dimension> dims = oldVar.getDimensions(); StringBuilder dimNames = new StringBuilder(recordDimName); for (Dimension d : dims) { if (!d.isUnlimited()) dimNames.append(" ").append(d.getShortName()); } Variable newVar = writer.addVariable(null, oldVar.getShortName(), oldVar.getDataType(), dimNames.toString()); List<Attribute> atts = oldVar.getAttributes(); for (Attribute att : atts) { newVar.addAttribute( att); } newVar.addAttribute( new Attribute(CF.COORDINATES, coordNames)); } }
protected void addDataVariablesExtended(StructureData obsData, String coordVars) throws IOException { for (StructureMembers.Member m : obsData.getMembers()) { VariableSimpleIF oldVar = getDataVar(m.getName()); if (oldVar == null) continue; // skip duplicates // if (record.findVariable(oldVar.getShortName()) != null) continue; // make dimension list StringBuilder dimNames = new StringBuilder(); for (Dimension d : oldVar.getDimensions()) { if (d.isUnlimited()) continue; if (d.getShortName() == null || !d.getShortName().equals(recordDimName)) dimNames.append(" ").append(d.getLength()); // anonymous } Variable newVar = writer.addStructureMember(record, oldVar.getShortName(), oldVar.getDataType(), dimNames.toString()); if (newVar == null) { logger.warn("Variable already exists =" + oldVar.getShortName()); // LOOK barf continue; } List<Attribute> atts = oldVar.getAttributes(); for (Attribute att : atts) { String attName = att.getShortName(); if (!reservedVariableAtts.contains(attName) && !attName.startsWith("_Coordinate")) newVar.addAttribute(att); } newVar.addAttribute(new Attribute(CF.COORDINATES, coordVars)); } }
protected void addDataVariablesExtended(StructureData obsData, String coordVars) throws IOException { for (StructureMembers.Member m : obsData.getMembers()) { VariableSimpleIF oldVar = getDataVar(m.getName()); if (oldVar == null) continue; // skip duplicates // if (record.findVariable(oldVar.getShortName()) != null) continue; // make dimension list StringBuilder dimNames = new StringBuilder(); for (Dimension d : oldVar.getDimensions()) { if (d.isUnlimited()) continue; if (d.getShortName() == null || !d.getShortName().equals(recordDimName)) dimNames.append(" ").append(d.getLength()); // anonymous } Variable newVar = writer.addStructureMember(record, oldVar.getShortName(), oldVar.getDataType(), dimNames.toString()); if (newVar == null) { logger.warn("Variable already exists =" + oldVar.getShortName()); // LOOK barf continue; } List<Attribute> atts = oldVar.getAttributes(); for (Attribute att : atts) { String attName = att.getShortName(); if (!reservedVariableAtts.contains(attName) && !attName.startsWith("_Coordinate")) newVar.addAttribute(att); } newVar.addAttribute(new Attribute(CF.COORDINATES, coordVars)); } }
protected void addCoordinatesClassic(Dimension recordDim, List<VariableSimpleIF> coords, Map<String, Variable> varMap) throws IOException { addDimensionsClassic(coords, dimMap); for (VariableSimpleIF oldVar : coords) { List<Dimension> dims = makeDimensionList(dimMap, oldVar.getDimensions()); dims.add(0, recordDim); Variable newVar; if (oldVar.getDataType().equals(DataType.STRING) && !writer.getVersion().isExtendedModel()) { if (oldVar instanceof Variable) newVar = writer.addStringVariable(null, (Variable) oldVar, dims); else newVar = writer.addStringVariable(null, oldVar.getShortName(), dims, 20); // LOOK barf } else { newVar = writer.addVariable(null, oldVar.getShortName(), oldVar.getDataType(), dims); } if (newVar == null) { logger.warn("Variable already exists =" + oldVar.getShortName()); // LOOK barf continue; } for (Attribute att : oldVar.getAttributes()) newVar.addAttribute(att); varMap.put(newVar.getShortName(), newVar); } }
protected void addCoordinatesClassic(Dimension recordDim, List<VariableSimpleIF> coords, Map<String, Variable> varMap) throws IOException { addDimensionsClassic(coords, dimMap); for (VariableSimpleIF oldVar : coords) { List<Dimension> dims = makeDimensionList(dimMap, oldVar.getDimensions()); dims.add(0, recordDim); Variable newVar; if (oldVar.getDataType().equals(DataType.STRING) && !writer.getVersion().isExtendedModel()) { if (oldVar instanceof Variable) newVar = writer.addStringVariable(null, (Variable) oldVar, dims); else newVar = writer.addStringVariable(null, oldVar.getShortName(), dims, 20); // LOOK barf } else { newVar = writer.addVariable(null, oldVar.getShortName(), oldVar.getDataType(), dims); } if (newVar == null) { logger.warn("Variable already exists =" + oldVar.getShortName()); // LOOK barf continue; } for (Attribute att : oldVar.getAttributes()) newVar.addAttribute(att); varMap.put(newVar.getShortName(), newVar); } }