Java Code Examples for ucar.ma2.DataType#FLOAT

The following examples show how to use ucar.ma2.DataType#FLOAT . 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: NcDDS.java    From tds with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private BaseType createScalarVariable(NetcdfFile ncfile, Variable v) {
  DataType dt = v.getDataType();
  if (dt == DataType.DOUBLE)
    return new NcSDFloat64(v);
  else if (dt == DataType.FLOAT)
    return new NcSDFloat32(v);
  else if (dt == DataType.INT)
    return new NcSDInt32(v);
  else if (dt == DataType.UINT)
    return new NcSDUInt32(v);
  else if (dt == DataType.SHORT)
    return new NcSDInt16(v);
  else if (dt == DataType.USHORT)
    return new NcSDUInt16(v);
  else if ((dt == DataType.BYTE) || (dt == DataType.UBYTE))
    return new NcSDByte(v);
  else if (dt == DataType.CHAR)
    return new NcSDString(v);
  else if (dt == DataType.STRING)
    return new NcSDString(v);
  else if (dt == DataType.STRUCTURE)
    return createStructure(ncfile, (Structure) v);
  else
    throw new UnsupportedOperationException("NcDDS Variable data type = " + dt);
}
 
Example 2
Source File: NcStream.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private static DataType decodeAttributeType(ucar.nc2.stream.NcStreamProto.Attribute.Type dtype) {
  switch (dtype) {
    case STRING:
      return DataType.STRING;
    case BYTE:
      return DataType.BYTE;
    case SHORT:
      return DataType.SHORT;
    case INT:
      return DataType.INT;
    case LONG:
      return DataType.LONG;
    case FLOAT:
      return DataType.FLOAT;
    case DOUBLE:
      return DataType.DOUBLE;
  }
  throw new IllegalStateException("illegal att type " + dtype);
}
 
Example 3
Source File: CFPointWriterUtils.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private static void setDataArray(DataType dt, Array arr, Member m) {

    // Set the value (int, short, float, double...)
    if (dt == DataType.SHORT) {
      arr.setShort(0, m.getDataArray().getShort(0));
    }

    if (dt == DataType.INT) {
      arr.setInt(0, m.getDataArray().getInt(0));
    }

    if (dt == DataType.DOUBLE) {
      arr.setDouble(0, m.getDataArray().getDouble(0));
    }

    if (dt == DataType.FLOAT) {
      arr.setFloat(0, m.getDataArray().getFloat(0));
    }

  }
 
Example 4
Source File: NUWGConvention.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public double getDouble(String name) throws NoSuchElementException {
  NavInfo nav = findInfo(name);
  if (nav == null)
    throw new NoSuchElementException("GRIB1 " + name);

  if ((nav.valueType == DataType.DOUBLE) || (nav.valueType == DataType.FLOAT))
    return nav.dvalue;
  else if ((nav.valueType == DataType.INT) || (nav.valueType == DataType.SHORT))
    return (double) nav.ivalue;
  else if (nav.valueType == DataType.BYTE)
    return (double) nav.bvalue;

  throw new IllegalArgumentException("NUWGConvention.GRIB1.getDouble " + name + " type = " + nav.valueType);
}
 
Example 5
Source File: TestPointDatasets.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
static private void checkData(StructureData sdata) {

    for (StructureMembers.Member member : sdata.getMembers()) {
      DataType dt = member.getDataType();
      if (dt == DataType.FLOAT) {
        sdata.getScalarFloat(member);
        sdata.getJavaArrayFloat(member);
      } else if (dt == DataType.DOUBLE) {
        sdata.getScalarDouble(member);
        sdata.getJavaArrayDouble(member);
      } else if (dt == DataType.BYTE) {
        sdata.getScalarByte(member);
        sdata.getJavaArrayByte(member);
      } else if (dt == DataType.SHORT) {
        sdata.getScalarShort(member);
        sdata.getJavaArrayShort(member);
      } else if (dt == DataType.INT) {
        sdata.getScalarInt(member);
        sdata.getJavaArrayInt(member);
      } else if (dt == DataType.LONG) {
        sdata.getScalarLong(member);
        sdata.getJavaArrayLong(member);
      } else if (dt == DataType.CHAR) {
        sdata.getScalarChar(member);
        sdata.getJavaArrayChar(member);
        sdata.getScalarString(member);
      } else if (dt == DataType.STRING) {
        sdata.getScalarString(member);
      }

      if ((dt != DataType.STRING) && (dt != DataType.CHAR) && (dt != DataType.STRUCTURE) && (dt != DataType.SEQUENCE)) {
        sdata.convertScalarFloat(member.getName());
      }

    }
  }
 
Example 6
Source File: MetarField.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
void sum(StructureData sdata, StructureMembers.Member m) {
  if (m.getDataType() == DataType.DOUBLE)
    sum(sdata.getScalarDouble(m));
  else if (m.getDataType() == DataType.FLOAT)
    sum(sdata.getScalarFloat(m));
  else if (m.getDataType() == DataType.INT)
    sum(sdata.getScalarInt(m));
}
 
Example 7
Source File: H4header.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
Number get(DataType dataType, int index) {
  if (dataType == DataType.BYTE)
    return bb.get(index);
  if (dataType == DataType.SHORT)
    return bb.asShortBuffer().get(index);
  if (dataType == DataType.INT)
    return bb.asIntBuffer().get(index);
  if (dataType == DataType.LONG)
    return bb.asLongBuffer().get(index);
  if (dataType == DataType.FLOAT)
    return bb.asFloatBuffer().get(index);
  if (dataType == DataType.DOUBLE)
    return bb.asDoubleBuffer().get(index);
  return Double.NaN;
}
 
Example 8
Source File: NUWGConvention.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public int getInt(String name) throws NoSuchElementException {
  NavInfo nav = findInfo(name);
  if (nav == null)
    throw new NoSuchElementException("GRIB1 " + name);

  if ((nav.valueType == DataType.INT) || (nav.valueType == DataType.SHORT))
    return nav.ivalue;
  else if ((nav.valueType == DataType.DOUBLE) || (nav.valueType == DataType.FLOAT))
    return (int) nav.dvalue;
  else if (nav.valueType == DataType.BYTE)
    return (int) nav.bvalue;

  throw new IllegalArgumentException("NUWGConvention.GRIB1.getInt " + name + " type = " + nav.valueType);
}
 
Example 9
Source File: NsslRadarMosaicConvention.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void addCoordSystem(NetcdfDataset ds) {

    double lat = ds.findGlobalAttributeIgnoreCase("Latitude").getNumericValue().doubleValue();
    double lon = ds.findGlobalAttributeIgnoreCase("Longitude").getNumericValue().doubleValue();
    double dlat = ds.findGlobalAttributeIgnoreCase("LatGridSpacing").getNumericValue().doubleValue();
    double dlon = ds.findGlobalAttributeIgnoreCase("LonGridSpacing").getNumericValue().doubleValue();
    int time = ds.findGlobalAttributeIgnoreCase("Time").getNumericValue().intValue();

    if (debug)
      System.out.println(ds.getLocation() + " Lat/Lon=" + lat + "/" + lon);

    int nlat = ds.findDimension("Lat").getLength();
    int nlon = ds.findDimension("Lon").getLength();

    // add lat
    CoordinateAxis v =
        new CoordinateAxis1D(ds, null, "Lat", DataType.FLOAT, "Lat", CDM.LAT_UNITS, "latitude coordinate");
    v.setValues(nlat, lat, -dlat);
    v.addAttribute(new Attribute(_Coordinate.AxisType, AxisType.Lat.toString()));
    ds.addCoordinateAxis(v);

    // add lon
    v = new CoordinateAxis1D(ds, null, "Lon", DataType.FLOAT, "Lon", CDM.LON_UNITS, "longitude coordinate");
    v.setValues(nlon, lon, dlon);
    v.addAttribute(new Attribute(_Coordinate.AxisType, AxisType.Lon.toString()));
    ds.addCoordinateAxis(v);

    // add time
    ds.addDimension(null, new Dimension("Time", 1));
    v = new CoordinateAxis1D(ds, null, "Time", DataType.INT, "Time", "seconds since 1970-1-1 00:00:00",
        "time coordinate");
    v.setValues(1, time, 1);
    v.addAttribute(new Attribute(_Coordinate.AxisType, AxisType.Time.toString()));
    ds.addCoordinateAxis(v);
  }
 
Example 10
Source File: HdfEosOmiConvention.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 *
 */
private CoordinateAxis makeLonCoordAxis(NetcdfDataset ds, Group g, int n, String dimName) {
  double incr = 360.0 / n;
  CoordinateAxis v = new CoordinateAxis1D(ds, g, "lon", DataType.FLOAT, dimName, CDM.LON_UNITS, "longitude");
  v.setValues(n, -180.0 + 0.5 * incr, incr);
  v.addAttribute(new Attribute(_Coordinate.AxisType, AxisType.Lon.toString()));
  return v;
}
 
Example 11
Source File: HdfEosOmiConvention.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 *
 */
private CoordinateAxis makeLatCoordAxis(NetcdfDataset ds, Group g, int n, String dimName) {
  double incr = 180.0 / n;
  CoordinateAxis v = new CoordinateAxis1D(ds, g, "lat", DataType.FLOAT, dimName, CDM.LAT_UNITS, "latitude");
  v.setValues(n, -90.0 + 0.5 * incr, incr);
  v.addAttribute(new Attribute(_Coordinate.AxisType, AxisType.Lat.toString()));
  return v;
}
 
Example 12
Source File: Attribute.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * Write CDL representation into a Formatter.
 *
 * @param f write into this
 * @param strict if true, create strict CDL, escaping names
 * @deprecated use CDLWriter
 */
@Deprecated
protected void writeCDL(Formatter f, boolean strict, String parentname) {
  if (strict && (isString() || this.getEnumType() != null))
    // Force type explicitly for string.
    f.format("string "); // note lower case and trailing blank
  if (strict && parentname != null)
    f.format(NetcdfFiles.makeValidCDLName(parentname));
  f.format(":");
  f.format("%s", strict ? NetcdfFiles.makeValidCDLName(getShortName()) : getShortName());
  if (isString()) {
    f.format(" = ");
    for (int i = 0; i < getLength(); i++) {
      if (i != 0)
        f.format(", ");
      String val = getStringValue(i);
      if (val != null)
        f.format("\"%s\"", encodeString(val));
    }
  } else if (getEnumType() != null) {
    f.format(" = ");
    for (int i = 0; i < getLength(); i++) {
      if (i != 0)
        f.format(", ");
      EnumTypedef en = getEnumType();
      String econst = getStringValue(i);
      Integer ecint = en.lookupEnumInt(econst);
      if (ecint == null)
        throw new ForbiddenConversionException("Illegal enum constant: " + econst);
      f.format("\"%s\"", encodeString(econst));
    }
  } else {
    f.format(" = ");
    for (int i = 0; i < getLength(); i++) {
      if (i != 0)
        f.format(", ");

      Number number = getNumericValue(i);
      if (dataType.isUnsigned()) {
        // 'number' is unsigned, but will be treated as signed when we print it below, because Java only has signed
        // types. If it is large enough ( >= 2^(BIT_WIDTH-1) ), its most-significant bit will be interpreted as the
        // sign bit, which will result in an invalid (negative) value being printed. To prevent that, we're going
        // to widen the number before printing it.
        number = DataType.widenNumber(number);
      }
      f.format("%s", number);

      if (dataType.isUnsigned()) {
        f.format("U");
      }

      if (dataType == DataType.FLOAT)
        f.format("f");
      else if (dataType == DataType.SHORT || dataType == DataType.USHORT) {
        f.format("S");
      } else if (dataType == DataType.BYTE || dataType == DataType.UBYTE) {
        f.format("B");
      } else if (dataType == DataType.LONG || dataType == DataType.ULONG) {
        f.format("L");
      }
    }
  }
}
 
Example 13
Source File: CDMTypeFcns.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public static DataType daptype2cdmtype(DapType type) {
  assert (type != null);
  switch (type.getTypeSort()) {
    case Char:
      return DataType.CHAR;
    case UInt8:
      return DataType.UBYTE;
    case Int8:
      return DataType.BYTE;
    case Int16:
      return DataType.SHORT;
    case UInt16:
      return DataType.USHORT;
    case Int32:
      return DataType.INT;
    case UInt32:
      return DataType.UINT;
    case Int64:
      return DataType.LONG;
    case UInt64:
      return DataType.ULONG;
    case Float32:
      return DataType.FLOAT;
    case Float64:
      return DataType.DOUBLE;
    case String:
    case URL:
      return DataType.STRING;
    case Opaque:
      return DataType.OPAQUE;
    case Enum:
      // Coverity[FB.BC_UNCONFIRMED_CAST]
      DapEnumeration dapenum = (DapEnumeration) type;
      switch (dapenum.getBaseType().getTypeSort()) {
        case Char:
        case UInt8:
        case Int8:
          return DataType.ENUM1;
        case Int16:
        case UInt16:
          return DataType.ENUM2;
        case Int32:
        case UInt32:
          return DataType.ENUM4;
        case Int64:
        case UInt64:
          // since there is no ENUM8, use ENUM4
          return DataType.ENUM4;
        default:
          break;
      }
      break;
    case Structure:
      return DataType.STRUCTURE;
    case Sequence:
      return DataType.SEQUENCE;
    default:
      break;
  }
  return null;
}
 
Example 14
Source File: H5headerNew.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
DataType getNCtype(int hdfType, int size, boolean unsigned) {
  if ((hdfType == 0) || (hdfType == 4)) { // integer, bit field
    DataType.Signedness signedness = unsigned ? DataType.Signedness.UNSIGNED : DataType.Signedness.SIGNED;

    if (size == 1)
      return DataType.BYTE.withSignedness(signedness);
    else if (size == 2)
      return DataType.SHORT.withSignedness(signedness);
    else if (size == 4)
      return DataType.INT.withSignedness(signedness);
    else if (size == 8)
      return DataType.LONG.withSignedness(signedness);
    else if (warnings) {
      log.debug("WARNING HDF5 file " + raf.getLocation() + " not handling hdf integer type (" + hdfType
          + ") with size= " + size);
      log.warn(
          "HDF5 file " + raf.getLocation() + " not handling hdf integer type (" + hdfType + ") with size= " + size);
      return null;
    }

  } else if (hdfType == 1) {
    if (size == 4)
      return DataType.FLOAT;
    else if (size == 8)
      return DataType.DOUBLE;
    else if (warnings) {
      log.debug("WARNING HDF5 file " + raf.getLocation() + " not handling hdf float type with size= " + size);
      log.warn("HDF5 file " + raf.getLocation() + " not handling hdf float type with size= " + size);
      return null;
    }

  } else if (hdfType == 3) { // fixed length strings. String is used for Vlen type = 1
    return DataType.CHAR;

  } else if (hdfType == 6) {
    return DataType.STRUCTURE;

  } else if (hdfType == 7) { // reference
    return DataType.ULONG;

  } else if (hdfType == 9) {
    return null; // dunno

  } else if (warnings) {
    log.debug("WARNING not handling hdf type = " + hdfType + " size= " + size);
    log.warn("HDF5 file " + raf.getLocation() + " not handling hdf type = " + hdfType + " size= " + size);
  }
  return null;
}
 
Example 15
Source File: VariableEnhancer.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public Array convert(Array in, boolean convertUnsigned, boolean applyScaleOffset, boolean convertMissing) {
  if (!in.getDataType().isNumeric() || (!convertUnsigned && !applyScaleOffset && !convertMissing)) {
    return in; // Nothing to do!
  }

  if (getSignedness() == Signedness.SIGNED) {
    convertUnsigned = false;
  }
  if (!hasScaleOffset()) {
    applyScaleOffset = false;
  }

  DataType outType = origDataType;
  if (convertUnsigned) {
    outType = getUnsignedConversionType();
  }
  if (applyScaleOffset) {
    outType = getScaledOffsetType();
  }

  if (outType != DataType.FLOAT && outType != DataType.DOUBLE) {
    convertMissing = false;
  }

  Array out = Array.factory(outType, in.getShape());
  IndexIterator iterIn = in.getIndexIterator();
  IndexIterator iterOut = out.getIndexIterator();

  while (iterIn.hasNext()) {
    Number value = (Number) iterIn.getObjectNext();

    if (convertUnsigned) {
      value = convertUnsigned(value);
    }
    if (applyScaleOffset) {
      value = applyScaleOffset(value);
    }
    if (convertMissing) {
      value = convertMissing(value);
    }

    iterOut.setObjectNext(value);
  }

  return out;
}
 
Example 16
Source File: H4type.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public static DataType setDataType(short type, Variable v) {
  DataType dt;
  switch (type) {
    case 3:
    case 21:
      dt = DataType.UBYTE;
      break;
    case 4:
      dt = DataType.CHAR;
      break;
    case 5:
      dt = DataType.FLOAT;
      break;
    case 6:
      dt = DataType.DOUBLE;
      break;
    case 20:
      dt = DataType.BYTE;
      break;
    case 22:
      dt = DataType.SHORT;
      break;
    case 23:
      dt = DataType.USHORT;
      break;
    case 24:
      dt = DataType.INT;
      break;
    case 25:
      dt = DataType.UINT;
      break;
    case 26:
      dt = DataType.LONG;
      break;
    case 27:
      dt = DataType.ULONG;
      break;
    default:
      throw new IllegalStateException("unknown type= " + type);
  }

  if (v != null) {
    v.setDataType(dt);
  }

  return dt;
}
 
Example 17
Source File: CDLWriter.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private void writeCDL(Attribute att, String parentname) {
  if (strict && (att.isString() || att.getEnumType() != null)) {
    // Force type explicitly for string.
    out.format("string "); // note lower case and trailing blank
  }
  if (strict && parentname != null) {
    out.format(NetcdfFiles.makeValidCDLName(parentname));
  }
  out.format(":");
  out.format("%s", strict ? NetcdfFiles.makeValidCDLName(att.getShortName()) : att.getShortName());
  if (att.isString()) {
    out.format(" = ");
    for (int i = 0; i < att.getLength(); i++) {
      if (i != 0) {
        out.format(", ");
      }
      String val = att.getStringValue(i);
      if (val != null) {
        out.format("\"%s\"", encodeString(val));
      }
    }
  } else if (att.getEnumType() != null) {
    out.format(" = ");
    for (int i = 0; i < att.getLength(); i++) {
      if (i != 0) {
        out.format(", ");
      }
      EnumTypedef en = att.getEnumType();
      String econst = att.getStringValue(i);
      Integer ecint = en.lookupEnumInt(econst);
      if (ecint == null) {
        throw new ForbiddenConversionException("Illegal enum constant: " + econst);
      }
      out.format("\"%s\"", encodeString(econst));
    }
  } else {
    out.format(" = ");
    for (int i = 0; i < att.getLength(); i++) {
      if (i != 0)
        out.format(", ");

      DataType dataType = att.getDataType();
      Number number = att.getNumericValue(i);
      if (dataType.isUnsigned()) {
        // 'number' is unsigned, but will be treated as signed when we print it below, because Java only has signed
        // types. If it is large enough ( >= 2^(BIT_WIDTH-1) ), its most-significant bit will be interpreted as the
        // sign bit, which will result in an invalid (negative) value being printed. To prevent that, we're going
        // to widen the number before printing it.
        number = DataType.widenNumber(number);
      }
      out.format("%s", number);

      if (dataType.isUnsigned()) {
        out.format("U");
      }

      if (dataType == DataType.FLOAT)
        out.format("f");
      else if (dataType == DataType.SHORT || dataType == DataType.USHORT) {
        out.format("S");
      } else if (dataType == DataType.BYTE || dataType == DataType.UBYTE) {
        out.format("B");
      } else if (dataType == DataType.LONG || dataType == DataType.ULONG) {
        out.format("L");
      }
    }
  }
}
 
Example 18
Source File: NcStream.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public static DataType convertDataType(ucar.nc2.stream.NcStreamProto.DataType dtype) {
  switch (dtype) {
    case CHAR:
      return DataType.CHAR;
    case BYTE:
      return DataType.BYTE;
    case SHORT:
      return DataType.SHORT;
    case INT:
      return DataType.INT;
    case LONG:
      return DataType.LONG;
    case FLOAT:
      return DataType.FLOAT;
    case DOUBLE:
      return DataType.DOUBLE;
    case STRING:
      return DataType.STRING;
    case STRUCTURE:
      return DataType.STRUCTURE;
    case SEQUENCE:
      return DataType.SEQUENCE;
    case ENUM1:
      return DataType.ENUM1;
    case ENUM2:
      return DataType.ENUM2;
    case ENUM4:
      return DataType.ENUM4;
    case OPAQUE:
      return DataType.OPAQUE;
    case UBYTE:
      return DataType.UBYTE;
    case USHORT:
      return DataType.USHORT;
    case UINT:
      return DataType.UINT;
    case ULONG:
      return DataType.ULONG;
  }
  throw new IllegalStateException("illegal data type " + dtype);
}
 
Example 19
Source File: AbstractRadialAdapter.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public DataType getDataType() {
  return DataType.FLOAT;
}
 
Example 20
Source File: CoverageDatasetCapabilities.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private Element writeAxis(CoverageCoordAxis axis) {
  Element varElem = new Element("axis");
  varElem.setAttribute("name", axis.getName());
  varElem.setAttribute("shape", Arrays.toString(axis.getShape()));

  DataType dt = axis.getDataType();
  varElem.setAttribute("type", dt.toString());

  AxisType axisType = axis.getAxisType();
  if (null != axisType)
    varElem.setAttribute("axisType", axisType.toString());

  if (axis.getDependsOn() != null && !axis.getDependsOn().trim().isEmpty())
    varElem.setAttribute("dependsOn", axis.getDependsOn().trim());

  // attributes
  for (Attribute att : axis.getAttributes()) {
    varElem.addContent(ncmlWriter.makeAttributeElement(att));
  }

  /*
   * f.format("%s  npts: %d [%f,%f] spacing=%s", indent, ncoords, startValue, endValue, spacing);
   * if (getResolution() != 0.0)
   * f.format(" resolution=%f", resolution);
   * f.format(" %s :", getDependenceType());
   * for (String s : dependsOn)
   */

  Element values = new Element("values");
  if (!axis.isRegular()) {
    Array array = axis.getCoordsAsArray();
    boolean isRealType = (array.getDataType() == DataType.DOUBLE) || (array.getDataType() == DataType.FLOAT);
    IndexIterator iter = array.getIndexIterator();

    StringBuilder buff = new StringBuilder();
    buff.append(isRealType ? iter.getDoubleNext() : iter.getIntNext());

    while (iter.hasNext()) {
      buff.append(" ");
      buff.append(isRealType ? iter.getDoubleNext() : iter.getIntNext());
    }

    values.setText(buff.toString());
  }

  values.setAttribute("spacing", axis.getSpacing().toString());
  values.setAttribute("npts", Long.toString(axis.getNcoords()));
  values.setAttribute("start", Double.toString(axis.getStartValue()));
  values.setAttribute("end", Double.toString(axis.getEndValue()));
  if (axis.getResolution() != 0.0)
    values.setAttribute("resolution", Double.toString(axis.getResolution()));

  varElem.addContent(values);
  return varElem;
}