Codota Logo
Variable.getDimensions
Code IndexAdd Codota to your IDE (free)

How to use
getDimensions
method
in
ucar.nc2.Variable

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

  • Common ways to obtain Variable
private void myMethod () {
Variable v =
  • Codota IconNetcdfFile ds;String fullNameEscaped;ds.findVariable(fullNameEscaped)
  • Codota IconNetcdfDataset ds;String obsTimeVName;ds.findVariable(obsTimeVName)
  • Codota IconGroup group;String varShortName;group.findVariable(varShortName)
  • Smart code suggestions by Codota
}
origin: geotools/geotools

private static Variable getAuxiliaryCoordinate(
    NetcdfDataset dataset, Group group, Variable var, String dimName) {
  Variable coordinateVariable = null;
  Attribute attribute = var.findAttribute(NetCDFUtilities.COORDINATES);
  if (attribute != null) {
    String coordinates = attribute.getStringValue();
    String[] coords = coordinates.split(" ");
    for (String coord : coords) {
      Variable coordVar = dataset.findVariable(group, coord);
      List<Dimension> varDimensions = coordVar.getDimensions();
      if (varDimensions != null
          && varDimensions.size() == 1
          && varDimensions.get(0).getFullName().equalsIgnoreCase(dimName)) {
        coordinateVariable = coordVar;
        break;
      }
    }
  }
  return coordinateVariable;
}
origin: geotools/geotools

  return false;
} else if (checkType == CheckType.NOSCALARS) {
  List<Dimension> dimensions = var.getDimensions();
  if (dimensions.size() < 2) {
    return false;
  List<Dimension> dimensions = var.getDimensions();
  if (dimensions.size() < 2) {
    return false;
origin: Unidata/thredds

public static Set<Dimension> makeDomain(Iterable<? extends Variable> axes) {
 Set<Dimension> domain = new HashSet<>();
 for (Variable axis : axes) {
  for (Dimension dim : axis.getDimensions()) {
    domain.add(dim);
  }
 }
 return domain;
}
origin: edu.ucar/netcdf

public static List<Dimension> makeDomain(Variable[] axes) {
 List<Dimension> domain = new ArrayList<Dimension>(10);
 for (Variable axis : axes) {
  for (Dimension dim : axis.getDimensions()) {
   if (!domain.contains(dim))
    domain.add(dim);
  }
 }
 return domain;
}
origin: edu.ucar/cdm

public static List<Dimension> makeDomain(Variable[] axes) {
 List<Dimension> domain = new ArrayList<>(10);
 for (Variable axis : axes) {
  for (Dimension dim : axis.getDimensions()) {
   if (!domain.contains(dim))
    domain.add(dim);
  }
 }
 return domain;
}
origin: Unidata/thredds

public static int countDomain(Variable[] axes) {
 Set<Dimension> domain = new HashSet<>();
 for (Variable axis : axes) {
  for (Dimension dim : axis.getDimensions()) {
    domain.add(dim);
  }
 }
 return domain.size();
}
origin: bcdev/beam

static List<Dimension> filterDimensions(List<String> variables, NetcdfFile netcdfFile) {
  final List<Dimension> filteredDimensions = new ArrayList<Dimension>();
  for (String variableName : variables) {
    final Variable variable = netcdfFile.findVariable(variableName);
    for (Dimension dimension : variable.getDimensions()) {
      if (!filteredDimensions.contains(dimension)) {
        filteredDimensions.add(dimension);
      }
    }
  }
  return filteredDimensions;
}
origin: edu.ucar/netcdf

 public Section mapIndex(Variable targetVar, Variable fromVar, int[] fromIndex) throws InvalidRangeException {
  List<Dimension> toDims = targetVar.getDimensions();
  List<Dimension> fromDims = fromVar.getDimensions();
  Section result = new Section();

  // each dimension in the target must be present in the source
  for (int i=0; i<toDims.size(); i++) {
   Dimension dim = toDims.get(i);
   int varIndex = fromDims.indexOf(toDims.get(i));
   if (varIndex < 0) throw new IllegalArgumentException("Dimension "+dim+" does not exist");
   result.appendRange(fromIndex[varIndex], fromIndex[varIndex]);
  }
  return result;
 }
}
origin: bcdev/beam

private static Variable getRciSds(NetcdfFile ncFile) throws IOException {
  final Variable sds = getVariable(ncFile, ChrisConstants.SDS_NAME_RCI_IMAGE, true);
  if (sds.getDimensions().size() != 3) {
    throw new IOException("Wrong number of dimensions, expected 3");
  }
  if (sds.getDataType() != DataType.INT) {
    throw new IOException("Wrong data type, 32-bit integer expected");
  }
  return sds;
}
origin: bcdev/beam

private static Variable getMaskSds(NetcdfFile ncFile) throws IOException {
  final Variable sds = getVariable(ncFile, ChrisConstants.SDS_NAME_MASK, false);
  if (sds != null) {
    if (sds.getDimensions().size() != 3) {
      throw new IOException("Wrong number of dimensions, expected 3");
    }
    if (sds.getDataType() != DataType.SHORT) {
      throw new IOException("Wrong data type, 16-bit integer expected");
    }
  }
  return sds;
}
origin: edu.ucar/netcdf

private long[] _computeChunking(Variable v) {
 List<Dimension> dims = v.getDimensions();
 long[] result = new long[dims.size()];
 int count = 0;
 for (Dimension d : dims) {
  if (d.isUnlimited()) result[count++] = 1;
  else result[count++] = d.getLength();
 }
 return result;
}
origin: edu.ucar/netcdf

private long[] _computeChunkingUnlimited(Variable v) {
 List<Dimension> dims = v.getDimensions();
 long[] result = new long[dims.size()];
 int count = 0;
 for (Dimension d : dims) {
  if (d.isUnlimited()) result[count++] = 1;
  else result[count++] = d.getLength();
 }
 return result;
}
origin: edu.ucar/cdm

static private void writeNcMLDimension( Variable v, PrintStream out) {
 out.print(" shape='");
 java.util.List<Dimension> dims = v.getDimensions();
 for (int j = 0; j < dims.size(); j++) {
  Dimension dim = dims.get(j);
  if (j != 0)
   out.print(" ");
  if (dim.isShared())
   out.print(StringUtil2.quoteXmlAttribute(dim.getShortName()));
  else
   out.print(dim.getLength());
 }
 out.print("'");
}
origin: edu.ucar/cdm

static private void writeNcMLDimension(Variable v, Formatter out) {
 out.format(" shape='");
 java.util.List<Dimension> dims = v.getDimensions();
 for (int j = 0; j < dims.size(); j++) {
  Dimension dim = dims.get(j);
  if (j != 0)
   out.format(" ");
  if (dim.isShared())
   out.format("%s", StringUtil2.quoteXmlAttribute(dim.getShortName()));
  else
   out.format("%d", dim.getLength());
 }
 out.format("'");
}
origin: edu.ucar/cdm

private boolean isTiled(Variable v) {
 for (Dimension d : v.getDimensions()) {
  for (Range r : section.getRanges()) {
   if (d.getShortName().equals(r.getName()))
    return true;
  }
 }
 return false;
}
origin: edu.ucar/netcdf

private boolean isTiled(Variable v) {
 for (Dimension d : v.getDimensions()) {
  for (Range r : section.getRanges()) {
   if (d.getShortName().equals(r.getName()))
    return true;
  }
 }
 return false;
}
origin: Unidata/thredds

private boolean isTiled(Variable v) {
 for (Dimension d : v.getDimensions()) {
  for (Range r : section.getRanges()) {
   if (d.getShortName().equals(r.getName()))
    return true;
  }
 }
 return false;
}
origin: bcdev/beam

@Override
public HdfDataField getDatafield(String name) throws ProductIOException {
  final Variable variable = netCDFVariables.get(name);
  final java.util.List<ucar.nc2.Dimension> dimensions = variable.getDimensions();
  final HdfDataField result = new HdfDataField();
  final String[] dimensionNames = new String[dimensions.size()];
  for (int i = 0; i < dimensions.size(); i++) {
    ucar.nc2.Dimension dimension = dimensions.get(i);
    dimensionNames[i] = dimension.getShortName();
  }
  result.setDimensionNames(dimensionNames);
  return result;
}
origin: bcdev/beam

@Override
public HdfDataField getDatafield(String name) throws ProductIOException {
  final Variable variable = netCDFVariables.get(name);
  final List<ucar.nc2.Dimension> dimensions = variable.getDimensions();
  final HdfDataField result = new HdfDataField();
  final String[] dimensionNames = new String[dimensions.size()];
  for (int i = 0; i < dimensions.size(); i++) {
    ucar.nc2.Dimension dimension = dimensions.get(i);
    dimensionNames[i] = dimension.getShortName();
  }
  result.setDimensionNames(dimensionNames);
  return result;
}
origin: Unidata/thredds

@Test
public void testHybridCoordinates() throws IOException {
 String filename = TestDir.cdmUnitTestDir + "formats/grib1/07010418_arw_d01.GrbF01500";
 System.out.println("\n\nReading File " + filename);
 NetcdfFile ncfile = NetcdfFile.open(filename);
 Group best = ncfile.findGroup("Best");
 Variable hybrid = ncfile.findVariable(best, "hybrid1");
 assert hybrid != null;
 assert (hybrid.getDimensions().size() == 1);
 Dimension d = hybrid.getDimension(0);
 assert (d.getLength() == 2);
 ncfile.close();
}
ucar.nc2VariablegetDimensions

Javadoc

Get the list of dimensions used by this variable. The most slowly varying (leftmost for Java and C programmers) dimension is first. For scalar variables, the list is empty.

Popular methods of Variable

  • read
    Read a section of the data for this Variable and return a memory resident Array. The Array has the s
  • getDataType
    Get the data type of the Variable.
  • findAttribute
    Find an Attribute by name.
  • getFullName
  • getRank
    Get the number of dimensions of the Variable.
  • getAttributes
    Returns the set of attributes for this variable.
  • getShape
    Get the size of the ith dimension
  • addAttribute
    Add new or replace old if has same name
  • getDimension
  • getSize
    Get the total number of elements in the Variable. If this is an unlimited Variable, will use the cur
  • getShortName
  • getUnitsString
    Get the Unit String for the Variable. Looks for the CDM.UNITS attribute value
  • getShortName,
  • getUnitsString,
  • getSPobject,
  • <init>,
  • setSPobject,
  • getDimensionsString,
  • getElementSize,
  • getNameAndDimensions,
  • isUnsigned

Popular in Java

  • Running tasks concurrently on multiple threads
  • requestLocationUpdates (LocationManager)
  • runOnUiThread (Activity)
  • notifyDataSetChanged (ArrayAdapter)
  • FileNotFoundException (java.io)
    Thrown when a file specified by a program cannot be found.
  • UnknownHostException (java.net)
    Thrown when a hostname can not be resolved.
  • NumberFormat (java.text)
    The abstract base class for all number formats. This class provides the interface for formatting and
  • Collectors (java.util.stream)
  • Filter (javax.servlet)
    A filter is an object that performs filtering tasks on either the request to a resource (a servlet o
  • LogFactory (org.apache.commons.logging)
    A minimal incarnation of Apache Commons Logging's LogFactory API, providing just the common Log look
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