本文整理了Java中ucar.nc2.Group.getDimensions()
方法的一些代码示例,展示了Group.getDimensions()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Group.getDimensions()
方法的具体详情如下:
包路径:ucar.nc2.Group
类名称:Group
方法名:getDimensions
[英]Get the shared Dimensions contained directly in this group.
[中]获取此组中直接包含的共享维度。
代码示例来源:origin: bcdev/beam
@Override
public String getDimensions() {
return Dimension.makeDimensionList(netcdfFileWriteable.getRootGroup().getDimensions());
}
代码示例来源:origin: edu.ucar/netcdf
void dumpClasses(Group g, PrintStream out) {
out.println("Dimensions:");
for (Dimension ds : g.getDimensions()) {
out.println(" " + ds.getShortName() + " " + ds.getClass().getName());
}
out.println("Atributes:");
for (Attribute a : g.getAttributes()) {
out.println(" " + a.getShortName() + " " + a.getClass().getName());
}
out.println("Variables:");
dumpVariables(g.getVariables(), out);
out.println("Groups:");
for (Group nested : g.getGroups()) {
out.println(" " + nested.getFullName() + " " + nested.getClass().getName());
dumpClasses(nested, out);
}
}
代码示例来源:origin: Unidata/thredds
void dumpClasses(Group g, PrintWriter out) {
out.println("Dimensions:");
for (Dimension ds : g.getDimensions()) {
out.println(" " + ds.getShortName() + " " + ds.getClass().getName());
}
out.println("Atributes:");
for (Attribute a : g.getAttributes()) {
out.println(" " + a.getShortName() + " " + a.getClass().getName());
}
out.println("Variables:");
dumpVariables(g.getVariables(), out);
out.println("Groups:");
for (Group nested : g.getGroups()) {
out.println(" " + nested.getFullName() + " " + nested.getClass().getName());
dumpClasses(nested, out);
}
}
代码示例来源:origin: edu.ucar/cdm
void dumpClasses(Group g, PrintWriter out) {
out.println("Dimensions:");
for (Dimension ds : g.getDimensions()) {
out.println(" " + ds.getShortName() + " " + ds.getClass().getName());
}
out.println("Atributes:");
for (Attribute a : g.getAttributes()) {
out.println(" " + a.getShortName() + " " + a.getClass().getName());
}
out.println("Variables:");
dumpVariables(g.getVariables(), out);
out.println("Groups:");
for (Group nested : g.getGroups()) {
out.println(" " + nested.getFullName() + " " + nested.getClass().getName());
dumpClasses(nested, out);
}
}
代码示例来源:origin: edu.ucar/netcdf
Iterator iter = ncfile.getRootGroup().getDimensions().iterator();
while (iter.hasNext()) {
Dimension dim = (Dimension) iter.next();
代码示例来源:origin: edu.ucar/cdm
Iterator iter = ncfile.getRootGroup().getDimensions().iterator();
while (iter.hasNext()) {
Dimension dim = (Dimension) iter.next();
代码示例来源:origin: Unidata/thredds
Iterator iter = ncfile.getRootGroup().getDimensions().iterator();
while (iter.hasNext()) {
Dimension dim = (Dimension) iter.next();
代码示例来源:origin: Unidata/thredds
/**
* If an equivilent shared dimension already exists, use it, else add d to shared dimensions.
* Equivilent is same name and length.
*
* @param group from this group, if null, use rootGroup
* @param d find equivilent shared dimension to this one.
* @return equivilent shared dimension or d.
*/
Dimension getSharedDimension(Group group, Dimension d) {
if (d.getShortName() == null) return d;
if (group == null) group = rootGroup;
for (Dimension sd : group.getDimensions()) {
if (sd.getShortName().equals(d.getShortName()) && sd.getLength() == d.getLength())
return sd;
}
d.setShared(true);
group.addDimension(d);
return d;
}
代码示例来源:origin: Unidata/thredds
private void count(Group g) {
ndims += g.getDimensions().size();
nvars += g.getVariables().size();
ngatts += g.getAttributes().size();
ngroups += g.getGroups().size();
for (Variable v : g.getVariables()) {
natts += v.getAttributes().size();
if (v instanceof Structure) {
nstructFields += ((Structure) v).getVariables().size();
}
}
for (Group ng : g.getGroups())
count(ng);
}
}
代码示例来源:origin: Unidata/thredds
private void count(Group g) {
ndims += g.getDimensions().size();
nvars += g.getVariables().size();
ngatts += g.getAttributes().size();
ngroups += g.getGroups().size();
for (Variable v : g.getVariables()) {
natts += v.getAttributes().size();
if (v instanceof Structure) {
nstructFields += ((Structure) v).getVariables().size();
}
}
for (Group ng : g.getGroups())
count(ng);
}
}
代码示例来源:origin: edu.ucar/netcdf
newGroup.addAttribute(att);
for (Dimension dim : oldGroup.getDimensions()) {
ncOut.addDimension(newGroup, dim.getShortName(), dim.getLength(), true, dim.isUnlimited(), dim.isVariableLength());
代码示例来源:origin: edu.ucar/netcdf
private Element writeGroup(Element elem, Group group) {
for (Dimension dim : group.getDimensions()) {
elem.addContent(writeDimension(dim, ncNS));
代码示例来源:origin: edu.ucar/cdm
private void convertGroup(Group g, Group from) {
for (EnumTypedef et : from.getEnumTypedefs())
g.addEnumeration(et);
for (Dimension d : from.getDimensions())
g.addDimension(new Dimension(d.getShortName(), d));
for (Attribute a : from.getAttributes())
g.addAttribute(a);
for (Variable v : from.getVariables())
g.addVariable(convertVariable(g, v));
for (Group nested : from.getGroups()) {
Group nnested = new Group(this, g, nested.getShortName());
g.addGroup(nnested);
convertGroup(nnested, nested);
}
}
代码示例来源:origin: edu.ucar/netcdf
private void convertGroup(Group g, Group from) {
for (EnumTypedef et : from.getEnumTypedefs())
g.addEnumeration(et);
for (Dimension d : from.getDimensions())
g.addDimension(new Dimension(d.getShortName(), d));
for (Attribute a : from.getAttributes())
g.addAttribute(a);
for (Variable v : from.getVariables())
g.addVariable(convertVariable(g, v));
for (Group nested : from.getGroups()) {
Group nnested = new Group(this, g, nested.getShortName());
g.addGroup(nnested);
convertGroup(nnested, nested);
}
}
代码示例来源:origin: Unidata/thredds
private void convertGroup(Group g, Group from) {
for (EnumTypedef et : from.getEnumTypedefs())
g.addEnumeration(et);
for (Dimension d : from.getDimensions())
g.addDimension(new Dimension(d.getShortName(), d));
for (Attribute a : from.getAttributes())
g.addAttribute(a);
for (Variable v : from.getVariables())
g.addVariable(convertVariable(g, v));
for (Group nested : from.getGroups()) {
Group nnested = new Group(this, g, nested.getShortName());
g.addGroup(nnested);
convertGroup(nnested, nested);
}
}
代码示例来源:origin: Unidata/thredds
public Element makeGroupElement(Group group) {
Element elem = new Element("group", namespace);
elem.setAttribute("name", group.getShortName());
// enumTypeDef
for (EnumTypedef etd : group.getEnumTypedefs()) {
elem.addContent(makeEnumTypedefElement(etd));
}
// dimensions
for (Dimension dim : group.getDimensions()) {
elem.addContent(makeDimensionElement(dim));
}
// regular variables
for (Variable var : group.getVariables()) {
boolean showValues = writeVariablesPredicate.apply(var);
elem.addContent(makeVariableElement(var, showValues));
}
// nested groups
for (Group g : group.getGroups()) {
Element groupElem = new Element("group", namespace);
groupElem.setAttribute("name", g.getShortName());
elem.addContent(makeGroupElement(g));
}
// attributes
for (Attribute att : group.getAttributes()) {
elem.addContent(makeAttributeElement(att));
}
return elem;
}
代码示例来源:origin: Unidata/thredds
static NcStreamProto.Group.Builder encodeGroup(Group g, int sizeToCache) throws IOException {
NcStreamProto.Group.Builder groupBuilder = NcStreamProto.Group.newBuilder();
groupBuilder.setName(g.getShortName());
for (Dimension dim : g.getDimensions())
groupBuilder.addDims(NcStream.encodeDim(dim));
for (Attribute att : g.getAttributes())
groupBuilder.addAtts(NcStream.encodeAtt(att));
for (EnumTypedef enumType : g.getEnumTypedefs())
groupBuilder.addEnumTypes(NcStream.encodeEnumTypedef(enumType));
for (Variable var : g.getVariables()) {
if (var instanceof Structure)
groupBuilder.addStructs(NcStream.encodeStructure((Structure) var));
else
groupBuilder.addVars(NcStream.encodeVar(var, sizeToCache));
}
for (Group ng : g.getGroups())
groupBuilder.addGroups(encodeGroup(ng, sizeToCache));
return groupBuilder;
}
代码示例来源:origin: edu.ucar/netcdf
static NcStreamProto.Group.Builder encodeGroup(Group g, int sizeToCache) throws IOException {
NcStreamProto.Group.Builder groupBuilder = NcStreamProto.Group.newBuilder();
groupBuilder.setName(g.getShortName());
for (Dimension dim : g.getDimensions())
groupBuilder.addDims(NcStream.encodeDim(dim));
for (Attribute att : g.getAttributes())
groupBuilder.addAtts(NcStream.encodeAtt(att));
for (EnumTypedef enumType : g.getEnumTypedefs())
groupBuilder.addEnumTypes(NcStream.encodeEnumTypedef(enumType));
for (Variable var : g.getVariables()) {
if (var instanceof Structure)
groupBuilder.addStructs(NcStream.encodeStructure((Structure) var));
else
groupBuilder.addVars(NcStream.encodeVar(var, sizeToCache));
}
for (Group ng : g.getGroups())
groupBuilder.addGroups(encodeGroup(ng, sizeToCache));
return groupBuilder;
}
代码示例来源:origin: edu.ucar/cdm
static NcStreamProto.Group.Builder encodeGroup(Group g, int sizeToCache) throws IOException {
NcStreamProto.Group.Builder groupBuilder = NcStreamProto.Group.newBuilder();
groupBuilder.setName(g.getShortName());
for (Dimension dim : g.getDimensions())
groupBuilder.addDims(NcStream.encodeDim(dim));
for (Attribute att : g.getAttributes())
groupBuilder.addAtts(NcStream.encodeAtt(att));
for (EnumTypedef enumType : g.getEnumTypedefs())
groupBuilder.addEnumTypes(NcStream.encodeEnumTypedef(enumType));
for (Variable var : g.getVariables()) {
if (var instanceof Structure)
groupBuilder.addStructs(NcStream.encodeStructure((Structure) var));
else
groupBuilder.addVars(NcStream.encodeVar(var, sizeToCache));
}
for (Group ng : g.getGroups())
groupBuilder.addGroups(encodeGroup(ng, sizeToCache));
return groupBuilder;
}
代码示例来源:origin: bcdev/beam
public void testWriteFlagCoding() throws Exception {
Band flagBand = new Band("flag_band", ProductData.TYPE_UINT8, 10, 10);
FlagCoding flagCoding = new FlagCoding("some_flags");
flagBand.setSampleCoding(flagCoding);
flagCoding.setDescription("A Flag Coding");
for (int i = 0; i < 8; i++) {
addFlag(flagCoding, i);
}
NetcdfFileWriteable writeable = NetcdfFileWriteable.createNew("not stored");
writeable.addDimension("y", flagBand.getSceneRasterHeight());
writeable.addDimension("x", flagBand.getSceneRasterWidth());
final DataType ncDataType = DataTypeUtils.getNetcdfDataType(flagBand.getDataType());
Variable variable = writeable.addVariable(flagBand.getName(), ncDataType, writeable.getRootGroup().getDimensions());
CfBandPart.writeCfBandAttributes(flagBand, new N3Variable(variable, writeable));
CfFlagCodingPart.writeFlagCoding(flagBand, new N3FileWriteable(writeable));
Variable someFlagsVariable = writeable.findVariable("flag_band");
assertNotNull(someFlagsVariable);
Attribute flagMasksAttrib = someFlagsVariable.findAttribute("flag_masks");
assertNotNull(flagMasksAttrib);
assertEquals(someFlagsVariable.getDataType(), flagMasksAttrib.getDataType());
assertEquals(8, flagMasksAttrib.getLength());
assertTrue(flagMasksAttrib.isUnsigned());
for (int i = 0; i < 8; i++) {
assertEquals(1 << i, flagMasksAttrib.getValues().getInt(i));
}
Attribute descriptionAttrib = someFlagsVariable.findAttribute("long_name");
assertNotNull(flagCoding.getDescription(), descriptionAttrib.getStringValue());
}
内容来源于网络,如有侵权,请联系作者删除!