ucar.nc2.Variable Java Examples

The following examples show how to use ucar.nc2.Variable. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DatasetViewer.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private void dataPlot(BeanTable from) {
  List<VariableBean> l = from.getSelectedBeans();

  for (VariableBean vb : l) {
    if (vb == null)
      return;
    Variable v = vb.vs;
    if (v != null) {
      try {
        dataPlot.setDataset(ds);
        dataPlot.setVariable(v);
      } catch (Exception ex) {
        ex.printStackTrace();
      }
    } else
      return;
  }
  plotWindow.show();
}
 
Example #2
Source File: WriterCFPointAbstract.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private void writeExtraVariables() throws IOException {
  if (extra == null)
    return;

  for (Variable v : extra) {
    NetcdfFile ncfile = writer.getOutputFile();
    Variable mv = ncfile.findVariable(v.getFullName());
    if (mv == null)
      continue; // may be removed
    try {
      writer.write(mv, v.read());
    } catch (InvalidRangeException e) {
      e.printStackTrace(); // cant happen haha
    }
  }
}
 
Example #3
Source File: DataToCDM.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
protected Array createVar(DataCursor data) throws DapException {
  Array array = null;
  DapVariable d4var = (DapVariable) data.getTemplate();
  switch (d4var.getBaseType().getTypeSort()) {
    default: // atomic var
      array = createAtomicVar(data);
      break;
    case Sequence:
      array = createSequence(data);
      break;
    case Structure:
      array = createStructure(data);
      break;
  }
  if (d4var.isTopLevel() && this.dsp.getChecksumMode().enabled(dsp.getChecksumMode())) {
    // transfer the checksum attribute
    int csum = d4var.getChecksum();
    String scsum = String.format("0x%08x", csum);
    Variable cdmvar = (Variable) nodemap.get(d4var);
    Attribute acsum = new Attribute(DapUtil.CHECKSUMATTRNAME, scsum);
    cdmvar.addAttribute(acsum);
  }
  return array;
}
 
Example #4
Source File: TestEnhance.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Test
public void testStandaloneNoEnhance() throws IOException {
  try (NetcdfFile ncfile = NetcdfDatasets.openFile(dataDir + "testStandaloneNoEnhance.ncml", null)) {
    Variable unvar = ncfile.findVariable("unvar");
    assertThat((Object) unvar).isNotNull();
    assertThat(unvar.getDataType()).isEqualTo(DataType.SHORT);
    assertThat(unvar.attributes().hasAttribute("_Unsigned")).isTrue();
    assertThat(unvar.attributes().findAttributeString("_Unsigned", "")).isEqualTo("true");
    assertThat(unvar.readScalarShort()).isEqualTo(-9981);

    Variable scaledvar = ncfile.findVariable("scaledvar");
    assertThat((Object) scaledvar).isNotNull();
    assertThat(scaledvar.getDataType()).isEqualTo(DataType.SHORT);
    assertThat(scaledvar.attributes().hasAttribute("scale_factor")).isTrue();
    assertThat(scaledvar.attributes().findAttributeDouble("scale_factor", 1.0)).isEqualTo(2.0);
    assertThat(scaledvar.readScalarShort()).isEqualTo(1);
  }
}
 
Example #5
Source File: SimpleGeometryReader.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Returns a Line given a variable name and the geometric index. If the Line is not found it will return null. If the
 * Line is a part of the Multi-Line, it will return the head
 * (the first Line in the series which constitutes the Multi-Line).
 * 
 * @param name of the variable which holds the Line
 * @param index of the Line within the variable
 * @return a new line with all associated information
 */
public Line readLine(String name, int index) {

  Variable linevar = ds.findVariable(name);
  if (linevar == null)
    return null;
  Line line = null;

  // CFConvention
  if (ds.findGlobalAttribute(CF.CONVENTIONS) != null)
    if (ucar.nc2.dataset.conv.CF1Convention.getVersion(ds.findGlobalAttribute(CF.CONVENTIONS).getStringValue()) >= 8)
      line = new CFLine();

  if (line == null)
    return null;
  else
    return line.setupLine(ds, linevar, index);
}
 
Example #6
Source File: CFpointObs.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
protected String matchAxisTypeAndDimension(NetcdfDataset ds, AxisType type, Dimension outer) {
  Variable var = CoordSysEvaluator.findCoordByType(ds, type, axis -> {
    if ((outer == null) && (axis.getRank() == 0))
      return true;
    if ((outer != null) && (axis.getRank() == 1) && (outer.equals(axis.getDimension(0))))
      return true;

    // if axis is structure member, try pulling dimension out of parent structure
    if (axis.getParentStructure() != null) {
      Structure parent = axis.getParentStructure();
      return (outer != null) && (parent.getRank() == 1) && (outer.equals(parent.getDimension(0)));
    }
    return false;
  });
  if (var == null)
    return null;
  return var.getFullName();
}
 
Example #7
Source File: CFGridCoverageWriter.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private void writeCoordinateData(CoverageCollection subsetDataset, NetcdfFormatWriter writer)
    throws IOException, InvalidRangeException {
  for (CoverageCoordAxis axis : subsetDataset.getCoordAxes()) {
    Variable v = writer.findVariable(axis.getName());
    if (v != null) {
      if (show)
        System.out.printf("CFGridCoverageWriter write axis %s%n", v.getNameAndDimensions());
      writer.write(v, axis.getCoordsAsArray());
    } else {
      logger.error("CFGridCoverageWriter No variable for {}", axis.getName());
    }

    if (axis.isInterval()) {
      Variable vb = writer.findVariable(axis.getName() + BOUNDS);
      writer.write(vb, axis.getCoordBoundsAsArray());
    }
  }
}
 
Example #8
Source File: NetcdfUtils.java    From OpenDA with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Write values for all time variables that are present.
 *
 * @param netcdfFileWriter
 * @param timeInfoTimeDimensionMap
 * @throws Exception
 */
public static void writeTimeVariablesValues(NetcdfFileWriter netcdfFileWriter,
		Map<ITimeInfo, Dimension> timeInfoTimeDimensionMap) throws Exception {

	for (Map.Entry<ITimeInfo, Dimension> entry : timeInfoTimeDimensionMap.entrySet()) {
		ITimeInfo timeInfo = entry.getKey();
		Dimension timeDimension = entry.getValue();

		Variable timeVariable = netcdfFileWriter.findVariable(timeDimension.getShortName());
		String timeUnitString = timeVariable.findAttribute(UNITS_ATTRIBUTE_NAME).getStringValue();
		DateUnit dateUnit = new DateUnit(timeUnitString);

		double[] times = timeInfo.getTimes();
		ArrayDouble.D1 timesArray = new ArrayDouble.D1(times.length);
		for (int n = 0; n < times.length; n++) {
			double newTime = dateUnit.makeValue(new Date(Time.mjdToMillies(times[n])));
			timesArray.set(n, newTime);
		}

		netcdfFileWriter.write(timeVariable, timesArray);
	}
}
 
Example #9
Source File: PointIteratorMultidim.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public PointIteratorMultidim(String name, List<Variable> vars, int outerIndex, Filter filter) {
  this.vars = vars;
  this.outerIndex = outerIndex;
  this.filter = filter;

  Variable v = vars.get(0);
  npts = v.getDimension(1).getLength();

  StructureMembers.Builder builder = StructureMembers.builder().setName(name);
  for (Variable var : vars) {
    int[] shape = var.getShape();
    int[] newShape = new int[shape.length - 2];
    System.arraycopy(shape, 2, newShape, 0, shape.length - 2);
    builder.addMember(var.getShortName(), var.getDescription(), var.getUnitsString(), var.getDataType(), newShape);
  }
  members = builder.build();
}
 
Example #10
Source File: TestAggExistingNew.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public void testNoCoords() throws IOException {
  String filename = "file:./" + TestNcMLRead.topDir + "exclude/aggExistingNoCoords.xml";
  logger.debug("{}", filename);
  NetcdfDataset ncd = null;

  try {
    ncd = NetcdfDatasets.openDataset(filename, true, null);
    Variable time = ncd.getRootGroup().findVariableLocal("time");
    Array data = time.read();
    // all missing
    // assert data.getInt(0) ==
  } finally {
    if (ncd != null)
      ncd.close();
  }
  // logger.debug("{}", ncd);
  // assert false;
}
 
Example #11
Source File: TestSequence.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public void testSequence() {
  String url = "http://tsds.net/tsds/test/Scalar";
  try {
    NetcdfDataset ds = NetcdfDatasets.openDataset(url);
    System.out.println(ds);
    Structure struct = (Structure) ds.findVariable("TimeSeries");
    Variable var = struct.findVariable("time");
    Array arr = var.read();
    int n = (int) arr.getSize();
    int i;
    for (i = 0; arr.hasNext() && i < n; i++)
      System.out.println(arr.nextDouble());
    if (i != n) {
      System.err.println("short sequence");
      System.exit(1);
    }
  } catch (Exception e) {
    e.printStackTrace();
  }
}
 
Example #12
Source File: H5diagNew.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public void showCompress(Formatter f) throws IOException {
  Size totalSize = new Size(0, 0);
  for (Variable v : ncfile.getVariables()) {
    H5headerNew.Vinfo vinfo = (H5headerNew.Vinfo) v.getSPobject();
    showCompress(v, vinfo, totalSize, f);
  }
  f.format("%n");
  f.format(" total bytes   = %d%n", totalSize.nominal);
  f.format(" total storage = %d%n", totalSize.storage);
  f.format(" compression = %f%n", totalSize.getRatio());
  f.format(" nchunks     = %d%n", totalSize.count);

  File raf = new File(ncfile.getLocation());
  f.format(" file size    = %d%n", raf.length());
  float overhead = totalSize.storage == 0 ? 0 : ((float) raf.length() / totalSize.storage);
  f.format(" overhead     = %f%n", overhead);
}
 
Example #13
Source File: HdfEos.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private void fixAttributes(Group.Builder g) {
  for (Variable.Builder v : g.vbuilders) {
    AttributeContainerMutable attHelper = v.getAttributeContainer();
    for (Attribute a : ImmutableList.copyOf(attHelper)) {
      if (a.getShortName().equalsIgnoreCase("UNIT") || a.getShortName().equalsIgnoreCase("UNITS")) {
        attHelper.replace(a, CDM.UNITS);
      }
      if (a.getShortName().equalsIgnoreCase("SCALE_FACTOR") || a.getShortName().equalsIgnoreCase("FACTOR")) {
        attHelper.replace(a, CDM.SCALE_FACTOR);
      }
      if (a.getShortName().equalsIgnoreCase("OFFSET")) {
        attHelper.replace(a, CDM.ADD_OFFSET);
      }
    }
  }

  for (Group.Builder ng : g.gbuilders) {
    fixAttributes(ng);
  }

}
 
Example #14
Source File: WriterCFPointAbstract.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private void writeStructureDataClassic(int[] origin, StructureData sdata, Set<String> varSet)
    throws IOException, InvalidRangeException {
  for (StructureMembers.Member m : sdata.getMembers()) {
    Variable mv = findVariable(m.getName());
    if (!varSet.contains(m.getName()) || mv == null) {
      continue; // normal to fail here
    }

    Array org = sdata.getArray(m);
    if (m.getDataType() == DataType.STRING) { // convert to ArrayChar
      int strlen = mv.getDimension(mv.getDimensions().size() - 1).getLength();
      org = ArrayChar.makeFromStringArray((ArrayObject) org, strlen);
    }

    Array orgPlus1 = Array.makeArrayRankPlusOne(org); // add dimension on the left (slow)
    int[] useOrigin = origin;

    if (org.getRank() > 0) { // if rank 0 (common case, this is a nop, so skip)
      useOrigin = new int[org.getRank() + 1];
      useOrigin[0] = origin[0]; // the rest are 0
    }

    writer.write(mv, useOrigin, orgPlus1);
  }

}
 
Example #15
Source File: EPSG_OGC_CF_Helper.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public String getWcs1_0CrsId(GridDatatype gridDatatype, GridDataset gridDataset) throws IllegalArgumentException {
  gridDataset.getTitle();
  gridDatatype.getFullName();

  StringBuilder buf = new StringBuilder();

  Attribute gridMappingAtt = gridDatatype.findAttributeIgnoreCase(CF.GRID_MAPPING);
  if (gridMappingAtt != null) {
    String gridMapping = gridMappingAtt.getStringValue();
    Variable gridMapVar = gridDataset.getNetcdfFile().getRootGroup().findVariableLocal(gridMapping);
    if (gridMapVar != null) {
      String gridMappingNameAtt = gridMapVar.attributes().findAttributeString(CF.GRID_MAPPING_NAME, null);
      if (gridMappingNameAtt != null)
        buf.append("EPSG:").append(ProjectionStandardsInfo.getProjectionByCfName(gridMappingNameAtt));
    }
  }

  return buf.toString();
}
 
Example #16
Source File: H5diag.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public void showCompress(Formatter f) throws IOException {
  NetcdfFile ncfile = iosp.getNetcdfFile();

  Size totalSize = new Size(0, 0);
  for (Variable v : ncfile.getVariables()) {
    H5header.Vinfo vinfo = (H5header.Vinfo) v.getSPobject();
    showCompress(v, vinfo, totalSize, f);
  }
  f.format("%n");
  f.format(" total bytes   = %d%n", totalSize.nominal);
  f.format(" total storage = %d%n", totalSize.storage);
  f.format(" compression = %f%n", totalSize.getRatio());
  f.format(" nchunks     = %d%n", totalSize.count);

  File raf = new File(ncfile.getLocation());
  f.format(" file size    = %d%n", raf.length());
  float overhead = totalSize.storage == 0 ? 0 : ((float) raf.length() / totalSize.storage);
  f.format(" overhead     = %f%n", overhead);
}
 
Example #17
Source File: NetcdfUtils.java    From OpenDA with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static void writeSelectedData(NetcdfFileWriter netcdfFileWriter, Variable variable, int[] origin, int[] sizeArray, double[] values) {
	//replace NaN values with missing value for variable.
	double missingValue = getMissingValueDouble(variable);
	if (!Double.isNaN(missingValue)) {
		double[] newValues = new double[values.length];
		System.arraycopy(values, 0, newValues, 0, values.length);
		for (int n = 0; n < newValues.length; n++) {
			if (Double.isNaN(newValues[n])) {
				newValues[n] = missingValue;
			}
		}
		values = newValues;
	} else {//if missingValue is Double.NaN, then NaN values in values array are already equal to missingValue.
		//do nothing.
	}

	//prepare array for writing.
	ucar.ma2.Array array = ucar.ma2.Array.factory(DataType.DOUBLE, sizeArray, values);

	//write data.
	try {
		netcdfFileWriter.write(variable, origin, array);
	} catch (IOException | InvalidRangeException e) {
		throw new RuntimeException("Error while writing data to netcdf variable '" + variable.getShortName()
				+ "' in netcdf file " + netcdfFileWriter.getNetcdfFile().getLocation() + ". Message was: " + e.getMessage(), e);
	}
}
 
Example #18
Source File: TestHttpOpen.java    From tds with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private long readAllData(NetcdfFile ncfile) throws IOException {
  System.out.println("------Open " + ncfile.getLocation());

  long total = 0;
  for (Variable v : ncfile.getVariables()) {
    long nbytes = v.getSize() * v.getElementSize();
    System.out.println("  Try to read variable " + v.getFullName() + " " + nbytes);
    v.read();
    total += v.getSize() * v.getElementSize();
  }
  ncfile.close();
  return total;
}
 
Example #19
Source File: DatasetWriter.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private List<VariableBean> makeVariableBeans(NetcdfFile ds) {
  List<VariableBean> vlist = new ArrayList<>();
  for (Variable v : ds.getVariables()) {
    vlist.add(new VariableBean(v));
  }
  return vlist;
}
 
Example #20
Source File: NidsRadialAdapter.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public float[] getElevation() {
  float[] spArray = null;
  try {
    Variable sp = ds.findVariable("elevation");
    Array spData = sp.read();
    sp.setCachedData(spData, false);
    spArray = (float[]) spData.get1DJavaArray(float.class);

  } catch (IOException e) {
    e.printStackTrace();
  }

  return spArray;
}
 
Example #21
Source File: NetcdfFormatWriter.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/** Add a Variable to the root group. */
public Variable.Builder addVariable(String shortName, DataType dataType, List<Dimension> dims) {
  if (!isNewFile && !useJna) {
    throw new UnsupportedOperationException("Cant add variable to existing netcdf-3 files");
  }
  Variable.Builder vb = Variable.builder().setName(shortName).setDataType(dataType).setParentGroupBuilder(rootGroup)
      .setDimensions(dims);
  rootGroup.addVariable(vb);
  return vb;
}
 
Example #22
Source File: Nimbus.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private boolean setAxisType(NetcdfDataset ds, String varName, AxisType atype) {
  Variable v = ds.findVariable(varName);
  if (v == null)
    return false;

  v.addAttribute(new Attribute(_Coordinate.AxisType, atype.toString()));
  return true;
}
 
Example #23
Source File: TestCoverageFileWritingCompare.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public boolean attCheckOk(Variable v, Attribute att) {
  if (att.getName().equals("_ChunkSizes"))
    return false;
  if (!att.isString())
    return true;
  String val = att.getStringValue();
  if (val == null)
    return true;
  return !val.contains("Translation Date");
}
 
Example #24
Source File: NidsRadialAdapter.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public float getTime(int ray) throws IOException {
  Variable sp = ds.findVariable("rays_time");
  Array timeData = sp.read();
  sp.setCachedData(timeData, false);
  Index index = timeData.getIndex();
  return timeData.getFloat(index.set(ray));
}
 
Example #25
Source File: DatasetWriter.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void showDeclaration(BeanTable from, boolean isNcml) {
  Variable v = getCurrentVariable(from);
  if (v == null) {
    return;
  }

  infoTA.clear();

  if (isNcml) {
    NcmlWriter ncmlWriter = new NcmlWriter();
    // LOOK ncmlWriter.setNamespace(null);
    ncmlWriter.getXmlFormat().setOmitDeclaration(true);

    Element varElement = ncmlWriter.makeVariableElement(v, false);
    infoTA.appendLine(ncmlWriter.writeToString(varElement));
  } else {
    infoTA.appendLine(v.toString());
  }

  if (Debug.isSet("Xdeveloper")) {
    infoTA.appendLine("\n");
    infoTA.appendLine("FULL NAME = " + v.getFullName());
    infoTA.appendLine("\n");
    infoTA.appendLine(v.toStringDebug());
  }

  infoTA.gotoTop();
  infoWindow.setTitle("Variable Info");
  infoWindow.show();
}
 
Example #26
Source File: CFGridWriter.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void addCoordinateTransform(GridCoordSystem gcs, NetcdfFile ncd, List<String> varNameList,
    List<Variable> varList) {

  for (CoordinateTransform ct : gcs.getCoordinateTransforms()) {
    Variable v = ncd.findVariable(ct.getName());
    if (!varNameList.contains(ct.getName()) && (null != v)) {
      varNameList.add(ct.getName());
      varList.add(v);
    }
  }

}
 
Example #27
Source File: TestCFPointWriterCompare.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public boolean attCheckOk(Variable v, Attribute att) {
  if (att.getName().equals("_ChunkSizes")) {
    return false;
  }
  if (!att.isString()) {
    return true;
  }
  String val = att.getStringValue();
  if (val == null) {
    return true;
  }
  return !val.contains("Translation Date");
}
 
Example #28
Source File: AggregationOuterDimension.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void getDetailInfo(Formatter f) {
  super.getDetailInfo(f);
  f.format("  timeUnitsChange=%s%n", timeUnitsChange);
  f.format("  totalCoords=%d%n", totalCoords);

  if (!aggVarNames.isEmpty()) {
    f.format("  Aggregation Variables specified in NcML%n");
    for (String vname : aggVarNames)
      f.format("   %s%n", vname);
  }

  f.format("%nAggregation Variables%n");
  for (VariableDS vds : aggVars) {
    f.format("   ");
    vds.getNameAndDimensions(f, true, false);
    f.format("%n");
  }

  if (!cacheList.isEmpty()) {
    f.format("%nCache Variables%n");
    for (CacheVar cv : cacheList)
      f.format("   %s%n", cv);
  }

  f.format("%nVariable Proxies%n");
  for (Variable v : ncDataset.getVariables()) {
    if (v.hasCachedData()) {
      f.format("   %20s cached%n", v.getShortName());
    } else {
      f.format("   %20s proxy %s%n", v.getShortName(), v.getProxyReader().getClass().getName());
    }
  }


}
 
Example #29
Source File: CSMConvention.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
protected void augmentDataset(CancelTask cancelTask) throws IOException {
  for (Variable.Builder vb : rootGroup.vbuilders) {
    VariableDS.Builder vds = (VariableDS.Builder) vb;
    String unit = vds.getUnits();
    if (unit != null && (unit.equalsIgnoreCase("hybrid_sigma_pressure") || unit.equalsIgnoreCase("sigma_level"))) {
      // both a coordinate axis and transform
      vds.addAttribute(new Attribute(_Coordinate.AxisType, AxisType.GeoZ.toString()));
      vds.addAttribute(new Attribute(_Coordinate.TransformType, TransformType.Vertical.toString()));
      vds.addAttribute(new Attribute(_Coordinate.Axes, vds.getFullName()));
    }
  }
}
 
Example #30
Source File: LCMSNetCDFParser.java    From act with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Print top-level details about a NetCDF file.  Used for debugging.
 * @param netcdfFile The NetCDF file whose details to print.
 */
public static void printNetcdfFileDetails(NetcdfFile netcdfFile) {
  System.out.format("Details: %s\n", netcdfFile.getDetailInfo());
  System.out.format("File type description: %s\n", netcdfFile.getFileTypeDescription());
  System.out.format("Title: %s\n", netcdfFile.getTitle());
  System.out.println("Variables:");
  for (Variable v : netcdfFile.getVariables()) {
    System.out.format("  %s\n", v.getNameAndDimensions());
  }
  System.out.println("Global attributes:");
  for (Attribute a : netcdfFile.getGlobalAttributes()) {
    System.out.format("  %s: %s (%s)\n", a.getFullName(), a.getStringValue(), a.getDataType().toString());
  }
}