Codota Logo
CoordinateAxis
Code IndexAdd Codota to your IDE (free)

How to use
CoordinateAxis
in
ucar.nc2.dataset

Best Java code snippets using ucar.nc2.dataset.CoordinateAxis (Showing top 20 results out of 315)

  • Common ways to obtain CoordinateAxis
private void myMethod () {
CoordinateAxis c =
  • Codota IconGridCoordSystem gcs;gcs.getTimeAxis()
  • Codota IconGridCoordSystem gridCoordSystem;gridCoordSystem.getXHorizAxis()
  • Codota IconGridCoordSystem gridCoordSystem;gridCoordSystem.getYHorizAxis()
  • Smart code suggestions by Codota
}
origin: geotools/geotools

Set<String> ignored = NetCDFUtilities.getIgnoredDimensions();
for (CoordinateAxis axis : dataset.getCoordinateAxes()) {
  final int axisDimensions = axis.getDimensions().size();
  if (axisDimensions > 0 && axisDimensions < 3) {
    String axisName = axis.getFullName();
    if (axis.getAxisType() != null) {
      coordinates.put(axisName, CoordinateVariable.create(axis));
    } else {
        axis.setAxisType(AxisType.GeoZ);
        coordinates.put(axisName, CoordinateVariable.create(axis));
          LOGGER.fine(
              "Detected unparseable unit string in time axis: '"
                  + axis.getUnitsString()
                  + "'.");
        axis.setAxisType(AxisType.Time);
        coordinates.put(axisName, CoordinateVariable.create(axis));
      } else if (!ignored.contains(axisName)) {
origin: geotools/geotools

/**
 * Check whether the Y axis need to be flipped. Note that the method is synchronized since it
 * access the underlying Variable
 *
 * @param axis
 * @return
 * @throws IOException
 */
private synchronized boolean needFlipYAxis(CoordinateAxis axis) throws IOException {
  boolean flipYAxis = false;
  try {
    Array yAxisStart = axis.read(new Section().appendRange(2));
    float y1 = yAxisStart.getFloat(0);
    float y2 = yAxisStart.getFloat(1);
    if (y2 > y1) {
      flipYAxis = true;
    }
  } catch (InvalidRangeException e) {
    throw new RuntimeException(e);
  }
  return flipYAxis;
}
origin: geotools/geotools

try {
  if (zAxis != null) {
    String axisName = zAxis.getFullName();
    if (!NetCDFCRSUtilities.VERTICAL_AXIS_NAMES.contains(axisName)) {
      return null;
    String units = zAxis.getUnitsString();
    AxisType axisType = zAxis.getAxisType();
        || axisType == AxisType.RadialElevation) v_datumType = "geoidal";
    else if (axisType == AxisType.Height) {
      if (!zAxis.getShortName().equalsIgnoreCase("height")) {
        v_datumType = "depth";
        v_crsName =
      if (CF.POSITIVE_DOWN.equalsIgnoreCase(zAxis.getPositive())) {
        direction = OPPOSITES.get(axisType);
                csMap,
                getAxis(
                    zAxis.getShortName(),
                    getDirection(direction),
                    units));
origin: geotools/geotools

@Override
public boolean canHandle(CoordinateAxis axis) {
  if (axis != null
      && "time".equalsIgnoreCase(axis.getShortName())
      && CLIMATOLOGICAL_UNITS.equalsIgnoreCase(axis.getUnitsString())) {
    if (LOGGER.isLoggable(Level.FINEST)) {
      LOGGER.finest("Climatological Time Handler Spi can handle the axis");
    }
    return true;
  }
  return false;
}
origin: geotools/geotools

protected void init() {
  if (!coordinateAxis.isNumeric()
      || !(coordinateAxis instanceof CoordinateAxis1D)
      || (coordinateAxis.hasMissing()
          && !AxisType.Time.equals(coordinateAxis.getAxisType()))) {
    // Not sure time variable can have actual NoData values in the array.
    // Let's exclude it from GeneralHelper case.
    // We may revisit it if we find some data with FillValues in the array.
    axisHelper = new CoordinateAxisGeneralHelper();
  } else {
    axisHelper = new CoordinateAxis1DNumericHelper();
  }
}
origin: geotools/geotools

public static Class<?> suggestBinding(CoordinateAxis coordinateAxis) {
  Utilities.ensureNonNull("coordinateAxis", coordinateAxis);
  final AxisType axisType = coordinateAxis.getAxisType();
    case Spectral:
      final DataType dataType = coordinateAxis.getDataType();
      Attribute scaleFactor = coordinateAxis.findAttribute("scale_factor");
      Attribute offsetFactor = coordinateAxis.findAttribute("offset");
      if (scaleFactor != null || offsetFactor != null) {
        return Double.class;
    case RunTime:
      LOGGER.log(Level.FINE, "Date mapping for axis:" + coordinateAxis.toString());
      return java.util.Date.class;
    default:
  LOGGER.log(Level.FINE, "Unable to find mapping for axis:" + coordinateAxis.toString());
  return null;
origin: edu.ucar/netcdf

varElem.setAttribute("name", var.getFullName());
List dims = var.getDimensions();
for (int i=0; i<dims.size(); i++) {
 Dimension dim = (Dimension) dims.get(i);
DataType dt = var.getDataType();
varElem.setAttribute("type", dt.toString());
for (Attribute att : var.getAttributes()) {
 varElem.addContent(makeAttribute(att, "attribute"));
if (var.isMetadata() || (showCoords && var.getRank() <= 1))
 varElem.addContent( makeValues( var));
varElem.setAttribute(CDM.UNITS, var.getUnitsString());
if (var.getAxisType() != null)
 varElem.setAttribute("axisType", var.getAxisType().toString());
String positive = var.getPositive();
if (positive != null)
 varElem.setAttribute(CF.POSITIVE, positive);
String boundaryRef = var.getBoundaryRef();
if (boundaryRef != null)
 varElem.setAttribute("boundaryRef", boundaryRef);
List csys = var.getCoordinateSystems();
if (csys.size() > 0) {
origin: edu.ucar/cdm

private Element writeAxis2(CoordinateAxis axis, String name) {
  if (axis == null) return null;
  Element varElem = new Element(name);
  varElem.setAttribute("name", axis.getFullName());
  varElem.setAttribute("shape", getShapeString(axis.getShape())); // axis.getDimensionsString());
  DataType dt = axis.getDataType();
  varElem.setAttribute("type", dt.toString());
  AxisType axisType = axis.getAxisType();
  if (null != axisType)
    varElem.setAttribute("axisType", axisType.toString());
  // attributes
  for (Attribute att : axis.getAttributes())
    varElem.addContent(ucar.nc2.ncml.NcMLWriter.writeAttribute(att, "attribute", null));
  Element values = ucar.nc2.ncml.NcMLWriter.writeValues(axis, null, false);
  values.setAttribute("npts", Long.toString(axis.getSize()));
  varElem.addContent(values);
  return varElem;
}
origin: edu.ucar/netcdf

@Override
public boolean isZPositive() {
 CoordinateAxis vertZaxis = getVerticalAxis();
 if (vertZaxis == null) return false;
 if (vertZaxis.getPositive() != null) {
  return vertZaxis.getPositive().equalsIgnoreCase(ucar.nc2.constants.CF.POSITIVE_UP);
 }
 if (vertZaxis.getAxisType() == AxisType.Height) return true;
 if (vertZaxis.getAxisType() == AxisType.Pressure) return false;
 return true; // default
}
origin: edu.ucar/cdm

if ((axis.getAxisType() == AxisType.Lat) || (axis.getAxisType() == AxisType.Lon)|| (axis.getAxisType() == AxisType.Time))
 for (Dimension dim : axis.getDimensions())
  dimSet.add(dim);
if ((time != null) && (time.getRank() == 0)) {
 st.addJoin(new JoinArray(time, JoinArray.Type.scalar, 0));
 st.time = time.getShortName();
if ((axis.getAxisType() == AxisType.Time) && axis.isCoordinateVariable()) {
 time = axis;
 break;
Dimension obsDim = time.getDimension(0);
TableConfig st = new TableConfig(Table.Type.Structure, obsDim.getShortName());
st.structureType = TableConfig.StructureType.PsuedoStructure;
origin: geotools/geotools

try {
  if (timeAxis != null) {
    AxisType type = timeAxis.getAxisType();
    String units = timeAxis.getUnitsString();
      if (CF.POSITIVE_DOWN.equalsIgnoreCase(timeAxis.getPositive())) {
        direction = OPPOSITES.get(type);
        origin = unitsParts[1].trim();
      } else {
        final Attribute attribute = timeAxis.findAttribute("time_origin");
        if (attribute != null) {
          origin = attribute.getStringValue();
    String axisName = timeAxis.getShortName();
origin: geotools/geotools

static String[] getUnitDirection(CoordinateAxis axis) {
  AxisType type = axis.getAxisType();
  String units = axis.getUnitsString();
    if (CF.POSITIVE_DOWN.equalsIgnoreCase(axis.getPositive())) {
      direction = OPPOSITES.get(type);
origin: Unidata/thredds

if ((axis.getAxisType() == AxisType.Lat) || (axis.getAxisType() == AxisType.Lon)|| (axis.getAxisType() == AxisType.Time))
 for (Dimension dim : axis.getDimensions())
  dimSet.add(dim);
if ((time != null) && (time.getRank() == 0)) {
 st.addJoin(new JoinArray(time, JoinArray.Type.scalar, 0));
 st.time = time.getShortName();
if ((axis.getAxisType() == AxisType.Time) && axis.isIndependentCoordinate()) {
 time = axis;
 break;
Dimension obsDim = time.getDimension(0);
TableConfig st = new TableConfig(Table.Type.Structure, obsDim.getShortName());
st.structureType = TableConfig.StructureType.PsuedoStructure;
origin: geotools/geotools

/**
 * @param binding
 * @param coordinateAxis
 */
public CoordinateVariable(Class<T> binding, CoordinateAxis coordinateAxis) {
  Utilities.ensureNonNull("coordinateAxis", coordinateAxis);
  Utilities.ensureNonNull("binding", binding);
  this.binding = binding;
  this.coordinateAxis = coordinateAxis;
  this.conversionFactor = 1d;
  AxisType axisType = coordinateAxis.getAxisType();
  // Special management for projected coordinates with unit = km
  if ((axisType == AxisType.GeoX || axisType == AxisType.GeoY)
      && coordinateAxis.getUnitsString().equalsIgnoreCase("km")) {
    conversionFactor = KM_TO_M;
    convertAxis = true;
  }
}
origin: Unidata/thredds

@Test
@Category(NeedsCdmUnitTest.class)
public void testRegular() throws Exception {
 try(GridDataset dataset = GridDataset.open(TestDir.cdmUnitTestDir + "conventions/nuwg/03061219_ruc.nc")) {
  GeoGrid grid = dataset.findGridByName("T");
  assert null != grid;
  GridCoordSystem gcs = grid.getCoordinateSystem();
  assert null != gcs;
  assert grid.getRank() == 4;
  CoordinateAxis zaxis = gcs.getVerticalAxis();
  assert zaxis.getUnitsString().equals("hectopascals");
  GeoGrid grid_section = grid.subset(null, null, null, 3, 3, 3);
  GridCoordSystem gcs_section = grid_section.getCoordinateSystem();
  CoordinateAxis zaxis2 = gcs_section.getVerticalAxis();
  assert zaxis2.getSize() == 7;
  assert zaxis2.getUnitsString().equals("hectopascals");
  assert gcs_section.getTimeAxis().equals(gcs.getTimeAxis());
  Array data = grid_section.readDataSlice(-1, -1, -1, -1);
  assert data.getShape()[0] == 2 : data.getShape()[0];
  assert data.getShape()[1] == 7 : data.getShape()[1];
  assert data.getShape()[2] == 22 : data.getShape()[2];
  assert data.getShape()[3] == 31 : data.getShape()[3];
  // check axes
  for (CoordinateAxis axis : gcs_section.getCoordinateAxes()) {
   assert axis.getAxisType() != null;
  }
 }
}
origin: Unidata/thredds

public int compare(CoordinateAxis c1, CoordinateAxis c2) {
 AxisType t1 = c1.getAxisType();
 AxisType t2 = c2.getAxisType();
 if ((t1 == null) && (t2 == null))
  return c1.getShortName().compareTo(c2.getShortName());
 if (t1 == null)
  return -1;
 if (t2 == null)
  return 1;
 return t1.axisOrder() - t2.axisOrder();
}
origin: edu.ucar/netcdf

private boolean isSwath(java.util.List<CoordinateSystem> csysList) {
 CoordinateSystem use = null;
 for (CoordinateSystem csys : csysList) {
  if (use == null) use = csys;
  else if (csys.getCoordinateAxes().size() > use.getCoordinateAxes().size())
   use = csys;
 }
 if (use == null) return false;
 CoordinateAxis lat = use.getLatAxis();
 CoordinateAxis lon = use.getLonAxis();
 CoordinateAxis time = use.getTaxis();
 if ((lat == null) || (lat.getRank() != 2)) return false;
 if ((lon == null) || (lon.getRank() != 2)) return false;
 if ((time == null)) return false; // must have time - otherwise it can be a grid
 // lat/lon must have the same dimensions
 if (!lat.getDimension(0).equals(lon.getDimension(0))) return false;
 if (!lat.getDimension(1).equals(lon.getDimension(1))) return false;
 Set<Dimension> dims = new HashSet<Dimension>(10);
 for (Dimension d : lat.getDimensions()) dims.add(d);
 for (Dimension d : lon.getDimensions()) dims.add(d);
 // diff with grid - time dimension(s) are a subset of lat/lon dimensions
 for (Dimension d : time.getDimensions()) {
  if (!dims.contains(d)) return false;
 }
 return true;
}
origin: geotools/geotools

private String getTimeAttribute(CoordinateSystem cs) {
  CoordinateAxis timeAxis = cs.getTaxis();
  String name = timeAxis != null ? timeAxis.getFullName() : NetCDFUtilities.TIME_DIM;
  DimensionMapper dimensionMapper = reader.georeferencing.getDimensionMapper();
  String timeAttribute = dimensionMapper.getDimension(name.toUpperCase());
  if (timeAttribute == null) {
    // Fallback on standard name
    timeAttribute = dimensionMapper.getDimension(NetCDFUtilities.TIME_DIM);
  }
  return timeAttribute;
}
origin: edu.ucar/cdm

AxisType axisType = axis.getAxisType();
if (axisType != null) {
 if (axisType == AxisType.GeoX) xAxis = lesserRank(xAxis, axis);
List<Dimension> dims = axis.getDimensions();
for (Dimension dim : dims) {
 if (!domain.contains(dim))
origin: Unidata/thredds

@Test
@Category(NeedsCdmUnitTest.class)
public void testWRF() throws Exception {
 try(GridDataset dataset = GridDataset.open(TestDir.cdmUnitTestDir + "conventions/wrf/wrfout_v2_Lambert.nc")) {
  GeoGrid grid = dataset.findGridByName("T");
  assert null != grid;
  GridCoordSystem gcs = grid.getCoordinateSystem();
  assert null != gcs;
  assert grid.getRank() == 4;
  CoordinateAxis zaxis = gcs.getVerticalAxis();
  assert zaxis.getSize() == 27;
  VerticalTransform vt = gcs.getVerticalTransform();
  assert vt != null;
  assert vt.getUnitString().equals("Pa");
  GeoGrid grid_section = grid.subset(null, null, null, 3, 3, 3);
  Array data = grid_section.readDataSlice(-1, -1, -1, -1);
  assert data.getShape()[0] == 13 : data.getShape()[0];
  assert data.getShape()[1] == 9 : data.getShape()[1];
  assert data.getShape()[2] == 20 : data.getShape()[2];
  assert data.getShape()[3] == 25 : data.getShape()[3];
  GridCoordSystem gcs_section = grid_section.getCoordinateSystem();
  CoordinateAxis zaxis2 = gcs_section.getVerticalAxis();
  assert zaxis2.getSize() == 9 : zaxis2.getSize();
  assert zaxis2.getUnitsString().equals(zaxis.getUnitsString());
  assert gcs_section.getTimeAxis().equals(gcs.getTimeAxis());
  VerticalTransform vt_section = gcs_section.getVerticalTransform();
  assert vt_section != null;
  assert vt_section.getUnitString().equals(vt.getUnitString());
 }
}
ucar.nc2.datasetCoordinateAxis

Javadoc

A Coordinate Axis is a Variable that specifies one of the coordinates of a CoordinateSystem. Mathematically it is a scalar function F from index space to S:
 
F:D -> S 
where D is a product set of dimensions (aka index space), and S is the set of reals (R) or Strings. 

If its element type is char, it is considered a string-valued Coordinate Axis and rank is reduced by one, since the outermost dimension is considered the string length: v(i, j, .., strlen). If its element type is String, it is a string-valued Coordinate Axis. Otherwise it is numeric-valued, and isNumeric() is true.

The one-dimensional case F(i) -> R is the common case which affords important optimizations. In that case, use the subtype CoordinateAxis1D. The factory methods will return either a CoordinateAxis1D if the variable is one-dimensional, a CoordinateAxis2D if its 2D, or a CoordinateAxis for the general case.

A CoordinateAxis is optionally marked as georeferencing with an AxisType. It should have a units string and optionally a description string.

A Structure cannot be a CoordinateAxis, although members of Structures can.

Most used methods

  • getAxisType
    Get type of axis
  • getUnitsString
  • read
  • getPositive
    Get the direction of increasing values, used only for vertical Axes.
  • getFullName
  • getShortName
  • getSize
  • getDimensions
  • equals
    Instances which have same content are equal.
  • findAttribute
  • getDimension
  • getMaxValue
    The largest coordinate value. Only call if isNumeric.
  • getDimension,
  • getMaxValue,
  • getMinValue,
  • getRank,
  • setAxisType,
  • getDataType,
  • getFullNameEscaped,
  • getNameAndDimensions,
  • getShape,
  • isNumeric

Popular in Java

  • Making http requests using okhttp
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • onRequestPermissionsResult (Fragment)
  • getSystemService (Context)
  • Path (java.nio.file)
  • BitSet (java.util)
    This class implements a vector of bits that grows as needed. Each component of the bit set has a boo
  • Comparator (java.util)
    A Comparator is used to compare two objects to determine their ordering with respect to each other.
  • List (java.util)
    A List is a collection which maintains an ordering for its elements. Every element in the List has a
  • Map (java.util)
    A Map is a data structure consisting of a set of keys and values in which each key is mapped to a si
  • SortedSet (java.util)
    A Set that further provides a total ordering on its elements. The elements are ordered using their C
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now