public int[] getShapeNotScalar() { if (isScalar()) return new int[]{1}; return getShape(); }
public void hashCodeShow(Indent indent) { System.out.printf("%sVar hash = %d%n", indent, hashCode()); System.out.printf("%s shortName %s = %d%n", indent, getShortName(), getShortName().hashCode()); System.out.printf("%s isScalar %s%n", indent, isScalar()); System.out.printf("%s dataType %s%n", indent, getDataType()); System.out.printf("%s parentGroup %s = %d%n", indent, getParentGroup(), getParentGroup().hashCode()); System.out.printf("%s isVariableLength %s%n", indent, isVariableLength); System.out.printf("%s dimensions %d len=%d%n", indent, dimensions.hashCode(), dimensions.size()); indent.incr(); for (Dimension d : dimensions) { d.hashCodeShow(indent); } indent.decr(); if (getParentStructure() != null) { System.out.printf("%s parentStructure %d%n", indent, getParentStructure().hashCode()); getParentStructure().hashCodeShow(indent.incr()); indent.decr(); } }
public void hashCodeShow(Indent indent) { System.out.printf("%sVar hash = %d%n", indent, hashCode()); System.out.printf("%s shortName %s = %d%n", indent, getShortName(), getShortName().hashCode()); System.out.printf("%s isScalar %s%n", indent, isScalar()); System.out.printf("%s dataType %s%n", indent, getDataType()); System.out.printf("%s parentGroup %s = %d%n", indent, getParentGroup(), getParentGroup().hashCode()); System.out.printf("%s isVariableLength %s%n", indent, isVariableLength); System.out.printf("%s dimensions %d len=%d%n", indent, dimensions.hashCode(), dimensions.size()); indent.incr(); for (Dimension d : dimensions) { d.hashCodeShow(indent); } indent.decr(); if (getParentStructure() != null) { System.out.printf("%s parentStructure %d%n", indent, getParentStructure().hashCode()); getParentStructure().hashCodeShow(indent.incr()); indent.decr(); } }
/** * Tries to find the coordinate variable of the specified type, which has the specified dimension as its firsst dimension * @param ds look in this dataset * @param a AxisType.LAT, LON, HEIGHT, or TIME * @param dim must use this dimension * @return coordinate variable, or null if not found. */ static public String getCoordinateName(NetcdfDataset ds, AxisType a, Dimension dim) { String name = getCoordinateName(ds, a); if (name == null) return null; Variable v = ds.findVariable(name); if (v == null) return null; if (v.isScalar()) return null; if (!v.getDimension(0).equals(dim)) return null; return name; }
private static List<Range> makeSpec(StringBuilder sb, Variable v, List<Range> orgRanges) throws InvalidRangeException { if (v.isMemberOfStructure()) { orgRanges = makeSpec(sb, v.getParentStructure(), orgRanges); sb.append('.'); } List<Range> ranges = (orgRanges == null) ? v.getRanges() : orgRanges; sb.append(v.isMemberOfStructure() ? NetcdfFile.makeValidSectionSpecName(v.getShortName()) : NetcdfFile.makeFullNameSectionSpec(v)); if (!v.isVariableLength() && !v.isScalar()) { // sequences cant be sectioned sb.append('('); for (int count=0; count<v.getRank(); count++) { Range r = ranges.get(count); if (r == null) r = new Range( 0, v.getDimension(count).getLength()); if (count>0) sb.append(", "); sb.append(r.first()); sb.append(':'); sb.append(r.last()); sb.append(':'); sb.append(r.stride()); } sb.append(')'); } return (orgRanges == null) ? null : ranges.subList(v.getRank(), ranges.size()); }
private static List<Range> makeSpec(StringBuilder sb, Variable v, List<Range> orgRanges) throws InvalidRangeException { if (v.isMemberOfStructure()) { orgRanges = makeSpec(sb, v.getParentStructure(), orgRanges); sb.append('.'); } List<Range> ranges = (orgRanges == null) ? v.getRanges() : orgRanges; sb.append(v.isMemberOfStructure() ? NetcdfFile.makeValidSectionSpecName(v.getShortName()) : NetcdfFile.makeFullNameSectionSpec(v)); if (!v.isVariableLength() && !v.isScalar()) { // sequences cant be sectioned sb.append('('); for (int count=0; count<v.getRank(); count++) { Range r = ranges.get(count); if (r == null) r = new Range( v.getDimension(count).getLength()); if (count>0) sb.append(", "); sb.append(r); } sb.append(')'); } return (orgRanges == null) ? null : ranges.subList(v.getRank(), ranges.size()); }
private static List<Range> makeSpec(StringBuilder sb, Variable v, List<Range> orgRanges) throws InvalidRangeException { if (v.isMemberOfStructure()) { orgRanges = makeSpec(sb, v.getParentStructure(), orgRanges); sb.append('.'); } List<Range> ranges = (orgRanges == null) ? v.getRanges() : orgRanges; sb.append(v.isMemberOfStructure() ? NetcdfFile.makeValidSectionSpecName(v.getShortName()) : NetcdfFile.makeFullNameSectionSpec(v)); if (!v.isVariableLength() && !v.isScalar()) { // sequences cant be sectioned sb.append('('); for (int count=0; count<v.getRank(); count++) { Range r = ranges.get(count); if (r == null) r = new Range( 0, v.getDimension(count).getLength()); if (count>0) sb.append(", "); sb.append(r.first()); sb.append(':'); sb.append(r.last()); sb.append(':'); sb.append(r.stride()); } sb.append(')'); } return (orgRanges == null) ? null : ranges.subList(v.getRank(), ranges.size()); }
/** * Tries to find the coordinate variable of the specified type, which has the specified dimension as its firsst dimension * @param ds look in this dataset * @param a AxisType.LAT, LON, HEIGHT, or TIME * @param dim must use this dimension * @return coordinate variable, or null if not found. */ static public String getCoordinateName(NetcdfDataset ds, AxisType a, Dimension dim) { String name = getCoordinateName(ds, a); if (name == null) return null; Variable v = ds.findVariable(name); if (v == null) return null; if (v.isScalar()) return null; if (!v.getDimension(0).equals(dim)) return null; return name; }
/** * Tries to find the coordinate variable of the specified type, which has the specified dimension as its firsst dimension * @param ds search in this dataset * @param a AxisType.LAT, LON, HEIGHT, or TIME * @param dim must use this dimension * @return coordinate variable, or null if not found. */ static public String getCoordinateName(NetcdfDataset ds, AxisType a, Dimension dim) { String name = getCoordinateName(ds, a); if (name == null) return null; Variable v = ds.findVariable(name); if (v == null) return null; if (v.isScalar()) return null; if (!v.getDimension(0).equals(dim)) return null; return name; }
/** * Override Object.hashCode() to implement equals. */ public int hashCode() { if(CDMNode.OBJECTHASH) return super.hashCode(); else { if (hashCode == 0) { int result = 17; result = 37 * result + getShortName().hashCode(); if (isScalar()) result++; result = 37 * result + getDataType().hashCode(); result = 37 * result + getParentGroup().hashCode(); if (getParentStructure() != null) result = 37 * result + getParentStructure().hashCode(); if (isVariableLength) result++; result = 37 * result + dimensions.hashCode(); hashCode = result; } return hashCode; } }
/** * Instances which have same content are equal. */ public boolean equals(Object oo) { if (this == oo) return true; if (!(oo instanceof Variable)) return false; Variable o = (Variable) oo; if (!getShortName().equals(o.getShortName())) return false; if (isScalar() != o.isScalar()) return false; if (getDataType() != o.getDataType()) return false; if (!getParentGroup().equals(o.getParentGroup())) return false; if ((getParentStructure() != null) && !getParentStructure().equals(o.getParentStructure())) return false; if (isVariableLength() != o.isVariableLength()) return false; if (dimensions.size() != o.getDimensions().size()) return false; for (int i=0; i<dimensions.size(); i++) if (!getDimension(i).equals(o.getDimension(i))) return false; return true; }
/** * Instances which have same content are equal. */ public boolean equals(Object oo) { if (this == oo) return true; if (!(oo instanceof Variable)) return false; Variable o = (Variable) oo; if (!getShortName().equals(o.getShortName())) return false; if (isScalar() != o.isScalar()) return false; if (getDataType() != o.getDataType()) return false; if (!getParentGroup().equals(o.getParentGroup())) return false; if ((getParentStructure() != null) && !getParentStructure().equals(o.getParentStructure())) return false; if (isVariableLength() != o.isVariableLength()) return false; if (dimensions.size() != o.getDimensions().size()) return false; for (int i = 0; i < dimensions.size(); i++) if (!getDimension(i).equals(o.getDimension(i))) return false; return true; }
/** * Override Object.hashCode() to implement equals. */ @Override public int hashCode() { if (hashCode == 0) { int result = 17; result = 37 * result + getShortName().hashCode(); if (isScalar()) result++; result = 37 * result + getDataType().hashCode(); result = 37 * result + getParentGroup().hashCode(); if (getParentStructure() != null) result = 37 * result + getParentStructure().hashCode(); if (isVariableLength) result++; result = 37 * result + dimensions.hashCode(); hashCode = result; } return hashCode; }
/** * Override Object.hashCode() to implement equals. */ @Override public int hashCode() { if (hashCode == 0) { int result = 17; result = 37 * result + getShortName().hashCode(); if (isScalar()) result++; result = 37 * result + getDataType().hashCode(); result = 37 * result + getParentGroup().hashCode(); if (getParentStructure() != null) result = 37 * result + getParentStructure().hashCode(); if (isVariableLength) result++; result = 37 * result + dimensions.hashCode(); hashCode = result; } return hashCode; }
/** * Instances which have same content are equal. */ public boolean equals(Object oo) { if (this == oo) return true; if (!(oo instanceof Variable)) return false; Variable o = (Variable) oo; if (!getShortName().equals(o.getShortName())) return false; if (isScalar() != o.isScalar()) return false; if (getDataType() != o.getDataType()) return false; if (!getParentGroup().equals(o.getParentGroup())) return false; if ((getParentStructure() != null) && !getParentStructure().equals(o.getParentStructure())) return false; if (isVariableLength() != o.isVariableLength()) return false; if (dimensions.size() != o.getDimensions().size()) return false; for (int i = 0; i < dimensions.size(); i++) if (!getDimension(i).equals(o.getDimension(i))) return false; return true; }
public boolean isStationary() { // only check once if (!isStationaryChecked) { Variable lat = ds.findVariable("latitude"); if (lat != null) { if (lat.isScalar()) isStationary = lat.getSize() == 1; else { // if array, check to see if all of the values are // approximately the same Array gar = null; try { gar = lat.read(); Object firstVal = gar.getObject(0); Array gar2 = gar.copy(); for (int i = 1; i < gar.getSize(); i++) { gar2.setObject(i, firstVal); } isStationary = nearlyEquals(gar, gar2); } catch (IOException e) { log.error("Error reading latitude variable {}. Cannot determine if " + "platform is stationary. Setting to default (false).", lat.getFullName()); } } } isStationaryChecked = true; } return isStationary; }
for (Variable v : recordMembers) { if (v == recordVar) continue; if (v.isScalar()) continue; if (v.getDimension(0) == this.obsDim) typedDataVariables.add(v);
if (v.isScalar()) ret = nc4.nc_insert_compound(g4.grpid, typeid, v.getShortName(), new SizeT(offset), field_typeid); else
if (v.isScalar()) ret = nc4.nc_insert_compound(g4.grpid, typeid, v.getShortName(), new SizeT(offset), field_typeid); else