Tabnine Logo
CoverageCoordAxis1D.getSpacing
Code IndexAdd Tabnine to your IDE (free)

How to use
getSpacing
method
in
ucar.nc2.ft2.coverage.CoverageCoordAxis1D

Best Java code snippets using ucar.nc2.ft2.coverage.CoverageCoordAxis1D.getSpacing (Showing top 13 results out of 315)

origin: Unidata/thredds

/**
 * Given a coordinate interval, find what grid element matches it.
 * @param target  interval in this coordinate system
 * @param bounded if true, always return a valid index. otherwise can return < 0 or > n-1
 * @return index of grid point containing it, or < 0 or > n-1 if outside grid area
 */
int findCoordElement(double[] target, boolean bounded) {
 switch (axis.getSpacing()) {
  case regularInterval:
   // can use midpoint
   return findCoordElementRegular((target[0]+target[1])/2, bounded);
  case contiguousInterval:
   // can use midpoint
   return findCoordElementContiguous((target[0]+target[1])/2, bounded);
  case discontiguousInterval:
   // cant use midpoint
   return findCoordElementDiscontiguousInterval(target, bounded);
 }
 throw new IllegalStateException("unknown spacing" + axis.getSpacing());
}
origin: Unidata/thredds

/**
 * Given a coordinate position, find what grid element contains it.
 * This means that
 * <pre>
 * edge[i] <= target < edge[i+1] (if values are ascending)
 * edge[i] > target >= edge[i+1] (if values are descending)
 * </pre>
 *
 * @param target  position in this coordinate system
 * @param bounded if true, always return a valid index. otherwise can return < 0 or > n-1
 * @return index of grid point containing it, or < 0 or > n-1 if outside grid area
 */
int findCoordElement(double target, boolean bounded) {
 switch (axis.getSpacing()) {
  case regularInterval:
  case regularPoint:
   return findCoordElementRegular(target, bounded);
  case irregularPoint:
  case contiguousInterval:
   return findCoordElementContiguous(target, bounded);
  case discontiguousInterval:
   return findCoordElementDiscontiguousInterval(target, bounded);
 }
 throw new IllegalStateException("unknown spacing" + axis.getSpacing());
}
origin: Unidata/thredds

@Override
public String getSummary() {
 if (axisType != AxisType.RunTime)
  return super.getSummary();
 if (ncoords < 7) {
  Formatter f = new Formatter();
  for (int i = 0; i < ncoords; i++) {
   CalendarDate cd = makeDate(getCoordMidpoint(i));
   if (i > 0) f.format(", ");
   f.format("%s", cd);
  }
  return f.toString();
 }
 Formatter f = new Formatter();
 CalendarDate start = makeDate(getStartValue());
 f.format("start=%s", start);
 CalendarDate end = makeDate(getEndValue());
 f.format(", end=%s", end);
 f.format(" (npts=%d spacing=%s)", getNcoords(), getSpacing());
 return f.toString();
}
origin: Unidata/thredds

private double[] makeValues(int index) {
 double[] subsetValues = null; // null for regular
 switch (axis.getSpacing()) {
  case irregularPoint:
   subsetValues = new double[1];
   subsetValues[0] = axis.getCoordMidpoint(index);
   break;
  case discontiguousInterval:
  case contiguousInterval:
   subsetValues = new double[2];
   subsetValues[0] = axis.getCoordEdge1(index);
   subsetValues[1] = axis.getCoordEdge2(index);
   break;
 }
 return subsetValues;
}
origin: Unidata/thredds

private Optional<CoverageCoordAxisBuilder> subsetValues(double minValue, double maxValue, int stride) {
 if (axis.getSpacing() == CoverageCoordAxis.Spacing.discontiguousInterval)
  return subsetValuesDiscontinuous(minValue, maxValue, stride);
 double lower = axis.isAscending() ? Math.min(minValue, maxValue) : Math.max(minValue, maxValue);
 double upper = axis.isAscending() ? Math.max(minValue, maxValue) : Math.min(minValue, maxValue);
 int minIndex = findCoordElement(lower, false);
 int maxIndex = findCoordElement(upper, false);
 if (minIndex >= axis.getNcoords())
  return Optional.empty(String.format("no points in subset: lower %f > end %f", lower, axis.getEndValue()));
 if (maxIndex < 0)
  return Optional.empty(String.format("no points in subset: upper %f < start %f", upper, axis.getStartValue()));
 if (minIndex < 0)
  minIndex = 0;
 if (maxIndex >= axis.getNcoords())
  maxIndex = axis.getNcoords() - 1;
 int count = maxIndex - minIndex + 1;
 if (count <= 0)
  throw new IllegalArgumentException("no points in subset");
 try {
  return Optional.of(subsetByIndex(new Range(minIndex, maxIndex, stride)));
 } catch (InvalidRangeException e) {
  return Optional.empty(e.getMessage());
 }
}
origin: Unidata/thredds

public List<NamedObject> getCoordValueNames(CoverageCoordAxis1D axis) {
 axis.loadValuesIfNeeded();
 List<NamedObject> result = new ArrayList<>();
 for (int i = 0; i < axis.getNcoords(); i++) {
  double value;
  switch (axis.getSpacing()) {
   case regularPoint:
   case irregularPoint:
    value = axis.getCoordMidpoint(i);
    result.add(new NamedAnything(makeDate(value), axis.getAxisType().toString()));
    break;
   case regularInterval:
   case contiguousInterval:
   case discontiguousInterval:
    CoordInterval coord = new CoordInterval(axis.getCoordEdge1(i), axis.getCoordEdge2(i), 3);
    result.add(new NamedAnything(coord, coord + " " + axis.getUnits()));
    break;
  }
 }
 return result;
}
origin: Unidata/thredds

double[] values = axis.getValues();  // will be null for regular
double[] subsetValues = null;
switch (axis.getSpacing()) {
 case regularInterval:
 case regularPoint:
origin: Unidata/thredds

@Test
public void testScalarRuntimeCoordinate() throws IOException {
 String filename = TestDir.cdmUnitTestDir + "ncss/GFS/CONUS_80km/GFS_CONUS_80km_20120227_0000.grib1.ncx4";
 String gridName = "Pressure_surface";
 try (FeatureDatasetCoverage cc = CoverageDatasetFactory.open(filename)) {
  Assert.assertNotNull(filename, cc);
  Assert.assertEquals(1, cc.getCoverageCollections().size());
  CoverageCollection cd = cc.getCoverageCollections().get(0);
  Coverage cov = cd.findCoverage(gridName);
  Assert.assertNotNull(gridName, cov);
  CoverageCoordSys csys = cov.getCoordSys();
  Assert.assertNotNull("CoverageCoordSys", csys);
  CoverageCoordAxis1D runtime = (CoverageCoordAxis1D) csys.getAxis(AxisType.RunTime);
  Assert.assertNotNull(AxisType.RunTime.toString(), runtime);
  Assert.assertTrue(runtime.getClass().getName(), runtime instanceof CoverageCoordAxis1D);
  Assert.assertEquals(CoverageCoordAxis.Spacing.regularPoint, runtime.getSpacing());
  Assert.assertEquals(CoverageCoordAxis.DependenceType.scalar, runtime.getDependenceType());
  CalendarDate startDate = runtime.makeDate(runtime.getCoordMidpoint(0));
  Assert.assertEquals(CalendarDate.parseISOformat(null, "2012-02-27T00:00:00Z"), startDate);
 }
}
origin: Unidata/thredds

builder.setDependsOn(timeAxisSubset.getName());
builder.spacing = timeAxisSubset.getSpacing();
builder.ncoords = timeAxisSubset.ncoords;
builder.isSubset = true;
switch (timeAxisSubset.getSpacing()) {
 case regularInterval:
 case regularPoint:
origin: Unidata/thredds

builder.setDependsOn(timeAxisSubset.getName());
builder.spacing = timeAxisSubset.getSpacing();
builder.ncoords = timeAxisSubset.ncoords;
builder.isSubset = true;
switch (timeAxisSubset.getSpacing()) {
 case regularInterval:
 case regularPoint:
origin: Unidata/thredds

Assert.assertNotNull(timeAxis);
Assert.assertEquals(92, timeAxis.getNcoords());
Assert.assertEquals(CoverageCoordAxis.Spacing.discontiguousInterval, timeAxis.getSpacing());
Assert2.assertNearlyEquals(0.0, timeAxis.getStartValue());
Assert2.assertNearlyEquals(384.0, timeAxis.getEndValue());
origin: Unidata/thredds

Assert.assertNotNull(runtimeAxis);
Assert.assertEquals(4, runtimeAxis.getNcoords());
Assert.assertEquals(CoverageCoordAxis.Spacing.regularPoint, runtimeAxis.getSpacing());
Assert2.assertNearlyEquals(0.0, runtimeAxis.getCoordMidpoint(0));
Assert2.assertNearlyEquals(6.0, runtimeAxis.getResolution());
origin: Unidata/thredds

Assert.assertNotNull(runtimeAxis);
Assert.assertEquals(3, runtimeAxis.getNcoords());
Assert.assertEquals(CoverageCoordAxis.Spacing.irregularPoint, runtimeAxis.getSpacing());
Assert2.assertNearlyEquals(0.0, runtimeAxis.getCoordMidpoint(0));
Assert2.assertNearlyEquals(6.0, runtimeAxis.getResolution());
ucar.nc2.ft2.coverageCoverageCoordAxis1DgetSpacing

Popular methods of CoverageCoordAxis1D

  • getCoordMidpoint
  • getEndValue
  • getNcoords
  • getResolution
  • makeDate
  • <init>
  • getCoordEdge1
  • getCoordEdge2
  • getDependenceType
  • getStartValue
  • convert
  • copy
  • convert,
  • copy,
  • getAxisType,
  • getCalendar,
  • getCalendarDateUnit,
  • getCoordEdgeFirst,
  • getCoordEdgeLast,
  • getCoordObject,
  • getCoordsAsArray

Popular in Java

  • Making http post requests using okhttp
  • onCreateOptionsMenu (Activity)
  • startActivity (Activity)
  • onRequestPermissionsResult (Fragment)
  • Font (java.awt)
    The Font class represents fonts, which are used to render text in a visible way. A font provides the
  • BufferedImage (java.awt.image)
    The BufferedImage subclass describes an java.awt.Image with an accessible buffer of image data. All
  • URI (java.net)
    A Uniform Resource Identifier that identifies an abstract or physical resource, as specified by RFC
  • SecureRandom (java.security)
    This class generates cryptographically secure pseudo-random numbers. It is best to invoke SecureRand
  • Timestamp (java.sql)
    A Java representation of the SQL TIMESTAMP type. It provides the capability of representing the SQL
  • Table (org.hibernate.mapping)
    A relational table
  • Github Copilot alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now