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

How to use
getDimension
method
in
ucar.nc2.Variable

Best Java code snippets using ucar.nc2.Variable.getDimension (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

public static int getDimensionLength(Variable var, final int dimensionIndex) {
  return var.getDimension(dimensionIndex).getLength();
}
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();
}
origin: geotools/geotools

/**
 * Get Z Dimension Lenght for standard CF variables
 *
 * @param var
 * @return
 */
public static int getZDimensionLength(Variable var) {
  final int rank = var.getRank();
  if (rank > 2) {
    return var.getDimension(rank - Z_DIMENSION).getLength();
  }
  // TODO: Should I avoid use this method in case of 2D Variables?
  return 0;
}
origin: bcdev/beam

private static ModisBandReader[] createBandReaderArray(Variable variable, boolean is3d) {
  final ModisBandReader[] modisBandReaders;
  if (is3d) {
    final Dimension numLayers = variable.getDimension(0);
    modisBandReaders = new ModisBandReader[numLayers.getLength()];
  } else {
    modisBandReaders = new ModisBandReader[1];
  }
  return modisBandReaders;
}
origin: bcdev/beam

private void determineScanLineLayout() {
  final String mode = getGlobalAttribute(ChrisConstants.ATTR_NAME_CHRIS_MODE).substring(0, 1);
  if (!(scanLineLayoutMap == null || mode == null || scanLineLayoutMap.get(mode) == null)) {
    scanLineLayout = scanLineLayoutMap.get(mode);
  } else {
    scanLineLayout = new ScanLineLayout(0, rciImageSds.getDimension(2).getLength(), 0);
  }
  globalAttributes.put(ChrisConstants.ATTR_NAME_NUMBER_OF_SAMPLES,
             Integer.toString(scanLineLayout.imagePixelCount));
}
origin: edu.ucar/cdm

 private int[] computeChunkingGrib(Variable v) {
  int n = v.getRank();
  int[] result = new int[n];
  if( n < 2 ) {
    result[0] = 1; // Unlimited variable with rank 1

  } else {
    for (int i=0; i<n; i++)
      result[i] = (i<n-2) ? 1 : v.getDimension(i).getLength();
  }    
  return result;
 }
}
origin: Unidata/thredds

 private int[] computeChunkingGrib(Variable v) {
  int n = v.getRank();
  int[] result = new int[n];
  if( n < 2 ) {
    result[0] = 1; // Unlimited variable with rank 1

  } else {
    for (int i=0; i<n; i++)
      result[i] = (i<n-2) ? 1 : v.getDimension(i).getLength();
  }    
  return result;
 }
}
origin: org.geotools/gt-unidata

public static int getZDimensionLength(Variable var) {
  final int rank = var.getRank();
  if (rank > 2) {
    return var.getDimension(rank - Z_DIMENSION).getLength();
  }
  // TODO: Should I avoid use this method in case of 2D Variables?
  return 0;
}
origin: senbox-org/s1tbx

private void addTiePointGridsToProduct(final Variable[] variables) throws IOException {
  for (Variable variable : variables) {
    final int rank = variable.getRank();
    final int gridWidth = variable.getDimension(rank - 1).getLength();
    int gridHeight = variable.getDimension(rank - 2).getLength();
    if (rank >= 3 && gridHeight <= 1)
      gridHeight = variable.getDimension(rank - 3).getLength();
    final TiePointGrid tpg = NetCDFUtils.createTiePointGrid(variable, gridWidth, gridHeight,
                                product.getSceneRasterWidth(), product.getSceneRasterHeight());
    product.addTiePointGrid(tpg);
  }
}
origin: senbox-org/s1tbx

public boolean fitsTo(final Variable varX, final Variable varY) {
  return varX.getRank() == 1 &&
      varY.getRank() == 1 &&
      varX.getDimension(0).getLength() == dimX.getLength() &&
      varY.getDimension(0).getLength() == dimY.getLength();
}
origin: edu.ucar/netcdf

private void addDimensionsAll(List<Dimension> result, Variable v) {
 if (v.isMemberOfStructure())
  addDimensionsAll(result, v.getParentStructure());
 for (int i=0; i<v.getRank(); i++)
  result.add( v.getDimension(i));
}
origin: edu.ucar/netcdf

protected Variable findVariableWithStandardNameAndNotDimension(NetcdfDataset ds, String standard_name, Dimension outer, Formatter errlog) {
 for (Variable v : ds.getVariables()) {
  String stdName = ds.findAttValueIgnoreCase(v, CF.STANDARD_NAME, null);
  if ((stdName != null) && stdName.equals(standard_name) && v.getRank() > 0 && !v.getDimension(0).equals(outer))
   return v;
 }
 return null;
}
origin: edu.ucar/cdm

private void addDimensionsAll(List<Dimension> result, Variable v) {
 if (v.isMemberOfStructure())
  addDimensionsAll(result, v.getParentStructure());
 for (int i = 0; i < v.getRank(); i++)
  result.add(v.getDimension(i));
}
origin: Unidata/thredds

private void addDimensionsAll(List<Dimension> result, Variable v) {
 if (v.isMemberOfStructure())
  addDimensionsAll(result, v.getParentStructure());
 for (int i = 0; i < v.getRank(); i++)
  result.add(v.getDimension(i));
}
origin: Unidata/thredds

private int[] getWeights( Variable v) {
 int rank = v.getRank();
 int[] w = new int[rank];
 for (int n=0; n<rank; n++) {
  Dimension dim = v.getDimension(n);
  String dimName = dim.getShortName();
  if (dimName.equals("time")) w[n]  = 1000;
  if (dimName.equals("z")) w[n]  = 100;
  if (dimName.equals("y")) w[n]  = 10;
  if (dimName.equals("x")) w[n]  = 1;
 }
 return w;
}
origin: edu.ucar/netcdf

protected Variable findVariableWithAttributeAndDimension(NetcdfDataset ds, String att_name, String att_value, Dimension outer, Formatter errlog) {
 for (Variable v : ds.getVariables()) {
  String stdName = ds.findAttValueIgnoreCase(v, att_name, null);
  if ((stdName != null) && stdName.equalsIgnoreCase(att_value)) {
   if (v.getRank() > 0 && v.getDimension(0).equals(outer))
    return v;
   if (isEffectivelyScaler(v) && (outer == null))
    return v;
  }
 }
 return null;
}
origin: Unidata/thredds

@org.junit.Test
public void test2() throws IOException {
 try (NetcdfFile ncfile = TestH5.openH5("HIRDLS/HIRDLS1_v4.0.2a-aIrix-c2_2003d106.he5")) {
  Variable v = ncfile.findVariable("HDFEOS/SWATHS/HIRDLS_L1_Swath/Data_Fields/Elevation_Angle");
  assert v != null;
  assert v.getRank() == 4;
  assert v.getDimension(0).getShortName().equals("MaF");
  assert v.getDimension(1).getShortName().equals("MiF");
  assert v.getDimension(2).getShortName().equals("CR");
  assert v.getDimension(3).getShortName().equals("CC");
 }
}
origin: Unidata/thredds

private void testReadData(Variable v) throws IOException {
 if (show) System.out.printf(" read %s%n", v.getNameAndDimensions());
 assert (null != v);
 assert (null != v.getDimension(0));
 Array a = v.read();
 assert (null != a);
 assert (v.getSize() == a.getSize());
}
origin: Unidata/thredds

@org.junit.Test
public void test1() throws IOException {
 try (NetcdfFile ncfile = TestH5.openH5("HIRDLS/HIR2ARSP_c3_na.he5")) {
  Variable v = ncfile.findVariable("HDFEOS/SWATHS/H2SO4_H2O_Tisdale/Data_Fields/Wavenumber");
  assert v != null;
  Dimension dim = v.getDimension(0);
  assert dim != null;
  assert dim.getShortName() != null;
  assert dim.getShortName().equals("nChans");
 }
}
origin: Unidata/thredds

@Category(NeedsCdmUnitTest.class)
public void testAlias() throws IOException {
 String filename = TestDir.cdmUnitTestDir + "ft/grid/ensemble/demeter/MM_cnrm_129_red.ncml";
 NetcdfDataset ncd = ucar.nc2.dataset.NetcdfDataset.openDataset(filename);
 Variable v = ncd.findCoordinateAxis("number");
 assert v != null;
 //assert v.isCoordinateVariable();
 assert v instanceof CoordinateAxis1D;
 assert null != ncd.findDimension("ensemble");
 assert v.getDimension(0) == ncd.findDimension("ensemble");
 ncd.close();
}
ucar.nc2VariablegetDimension

Javadoc

Get the ith dimension.

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.
  • getDimensions
    Get the list of dimensions used by this variable. The most slowly varying (leftmost for Java and C p
  • getShape
    Get the size of the ith dimension
  • addAttribute
    Add new or replace old if has same name
  • 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