return addStringVariable(g, stringVar.getShortName(), dims, max_strlen);
return addStringVariable(g, stringVar.getShortName(), dims, max_strlen);
return addStringVariable(g, stringVar.getShortName(), dims, max_strlen);
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); } }
/** * Specify which variable will get written * * @param oldVar add this variable, and all parent groups * @return new Variable. */ public Variable addVariable(Variable oldVar) { List<Dimension> newDims = getNewDimensions(oldVar); Variable newVar; if ((oldVar.getDataType().equals(DataType.STRING)) && (!version.isNetdf4format())) { newVar = writer.addStringVariable(null, oldVar, newDims); } else { newVar = writer.addVariable(null, oldVar.getShortName(), oldVar.getDataType(), newDims); } varMap.put(oldVar, newVar); varList.add(oldVar); for (Attribute att : oldVar.getAttributes()) writer.addVariableAttribute(newVar, att); // atts are immutable return newVar; }
/** * Specify which variable will get written * * @param oldVar add this variable, and all parent groups * @return new Variable. */ public Variable addVariable(Variable oldVar) { List<Dimension> newDims = getNewDimensions(oldVar); Variable newVar; if ((oldVar.getDataType().equals(DataType.STRING)) && (!version.isExtendedModel())) { newVar = writer.addStringVariable(null, oldVar, newDims); } else { newVar = writer.addVariable(null, oldVar.getShortName(), oldVar.getDataType(), newDims); } varMap.put(oldVar, newVar); varList.add(oldVar); for (Attribute att : oldVar.getAttributes()) writer.addVariableAttribute(newVar, att); // atts are immutable return newVar; }
/** * Specify which variable will get written * * @param oldVar add this variable, and all parent groups * @return new Variable. */ public Variable addVariable(Variable oldVar) { List<Dimension> newDims = getNewDimensions(oldVar); Variable newVar; if ((oldVar.getDataType().equals(DataType.STRING)) && (!version.isExtendedModel())) { newVar = writer.addStringVariable(null, oldVar, newDims); } else { newVar = writer.addVariable(null, oldVar.getShortName(), oldVar.getDataType(), newDims); } varMap.put(oldVar, newVar); varList.add(oldVar); for (Attribute orgAtt : oldVar.getAttributes()) writer.addVariableAttribute(newVar, convertAttribute(orgAtt)); return 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
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
private void createProfiles(List<String> profileNames) throws IOException { int nprofiles = profileNames.size(); // find string lengths for (String name : profileNames) { name_strlen = Math.max(name_strlen, name.length()); } // add the dimensions writer.addUnlimitedDimension(recordDimName); List<Dimension> profileDims = new ArrayList<Dimension>(1); Dimension profileDim = writer.addDimension(null, profileDimName, nprofiles); profileDims.add(profileDim); // add the profile Variables using the profile dimension id = writer.addStringVariable(null, idName, profileDims, name_strlen); writer.addVariableAttribute(id, new Attribute(CDM.LONG_NAME, "profile identifier")); writer.addVariableAttribute(id, new Attribute(CF.CF_ROLE, CF.PROFILE_ID)); Variable lat = writer.addVariable(null, latName, DataType.DOUBLE, profileDimName); writer.addVariableAttribute(lat, new Attribute(CDM.UNITS, CDM.LAT_UNITS)); writer.addVariableAttribute(lat, new Attribute(CDM.LONG_NAME, "profile latitude")); Variable lon = writer.addVariable(null, lonName, DataType.DOUBLE, profileDimName); writer.addVariableAttribute(lon, new Attribute(CDM.UNITS, CDM.LON_UNITS)); writer.addVariableAttribute(lon, new Attribute(CDM.LONG_NAME, "profile longitude")); if (altUnits != null) { Variable alt = writer.addVariable(null, altName, DataType.DOUBLE, profileDimName); writer.addVariableAttribute(alt, new Attribute(CDM.UNITS, altUnits)); writer.addVariableAttribute(alt, new Attribute(CDM.LONG_NAME, "profile altitude")); } }
id = writer.addStringVariable(null, idName, stationDims, name_strlen); writer.addVariableAttribute(id, new Attribute(CDM.LONG_NAME, "station identifier")); writer.addVariableAttribute(id, new Attribute(CF.CF_ROLE, CF.TIMESERIES_ID)); // station_id:cf_role = "timeseries_id"; desc = writer.addStringVariable(null, descName, stationDims, desc_strlen); writer.addVariableAttribute(desc, new Attribute(CDM.LONG_NAME, "station description")); writer.addVariableAttribute(desc, new Attribute(CF.STANDARD_NAME, CF.PLATFORM_NAME)); wmoId = writer.addStringVariable(null, wmoName, stationDims, wmo_strlen); writer.addVariableAttribute(wmoId, new Attribute(CDM.LONG_NAME, "station WMO id")); writer.addVariableAttribute(wmoId, new Attribute(CF.STANDARD_NAME, CF.PLATFORM_ID));
Variable tvar = ncfilew.addStringVariable(null, "t", new ArrayList<>(), trouble.length()); ncfilew.addVariableAttribute("t", "yow", trouble);