congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
CoverageCoordAxis1D.getCoordMidpoint
Code IndexAdd Tabnine to your IDE (free)

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

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

origin: Unidata/thredds

 public Object next() {
  return getCoordMidpoint(current++);
 }
}
origin: Unidata/thredds

public LatLonPoint getLatLon(int yindex, int xindex) {
 if (isProjection) {
  double x = xAxis.getCoordMidpoint(xindex);
  double y = yAxis.getCoordMidpoint(xindex);
  ProjectionImpl proj = transform.getProjection();
  return proj.projToLatLon(x, y);
 } else {
  double lat = latAxis.getCoordMidpoint(yindex);
  double lon = lonAxis.getCoordMidpoint(xindex);
  return new LatLonPointImpl(lat, lon);
 }
}
origin: Unidata/thredds

private int findClosest(double target) {
 double minDiff = Double.MAX_VALUE;
 double useValue = Double.MIN_VALUE;
 int idxFound = -1;
 for (int i = 0; i < axis.getNcoords(); i++) {
  double coord = axis.getCoordMidpoint(i);
  double diff = Math.abs(coord - target);
  if (diff < minDiff || (diff == minDiff && coord > useValue)) {
   minDiff = diff;
   idxFound = i;
   useValue = coord;
  }
 }
 return idxFound;
}
origin: Unidata/thredds

public Object getCoordObject(int index) {
 if (axisType == AxisType.RunTime)
  return makeDate(getCoordMidpoint(index));
 if (isInterval())
  return new double[]{getCoordEdge1(index), getCoordEdge2(index)};
 return getCoordMidpoint(index);
}
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

@Nonnull
private CoverageCoordAxisBuilder subsetValuesLatest() {
 int last = axis.getNcoords() - 1;
 double val = axis.getCoordMidpoint(last);
 CoverageCoordAxisBuilder builder = new CoverageCoordAxisBuilder(axis);
 builder.subset(1, val, val, 0.0, makeValues(last));
 try {
  builder.setRange(new Range(last, last));
 } catch (InvalidRangeException e) {
  throw new RuntimeException(e); // cant happen
 }
 return builder;
}
origin: Unidata/thredds

@Override
public Array getCoordsAsArray() {
 Array result;
 switch (dependenceType) {
  case scalar:
   result = Array.factory(getDataType(), new int[0]);
   break;
  default:
   result = Array.factory(getDataType(), new int[]{ncoords});
   break;
 }
 for (int i = 0; i < ncoords; i++)
  result.setDouble(i, getCoordMidpoint(i));
 return result;
}
origin: Unidata/thredds

Optional<CoverageCoordAxisBuilder> subsetContaining(double want) {
 int index = findCoordElement(want, false); // not bounded, may not be valid index
 if (index < 0 || index >= axis.getNcoords())
  return Optional.empty(String.format("value %f not in axis %s", want, axis.getName()));
 double val = axis.getCoordMidpoint(index);
 CoverageCoordAxisBuilder builder = new CoverageCoordAxisBuilder(axis);
 builder.subset(1, val, val, 0.0, makeValues(index));
 try {
  builder.setRange(new Range(index, index));
 } catch (InvalidRangeException e) {
  throw new RuntimeException(e); // cant happen
 }
 return Optional.of(builder);
}
origin: Unidata/thredds

public List<NamedObject> getCoordValueNames() {
 loadValuesIfNeeded();
 if (timeHelper != null)
  return timeHelper.getCoordValueNames(this);
 List<NamedObject> result = new ArrayList<>();
 for (int i = 0; i < ncoords; i++) {
  Object value = null;
  switch (spacing) {
   case regularPoint:
   case irregularPoint:
    value = Format.d(getCoordMidpoint(i), 3);
    break;
   case regularInterval:
   case contiguousInterval:
   case discontiguousInterval:
    value = new CoordInterval(getCoordEdge1(i), getCoordEdge2(i), 3);
    break;
  }
  result.add(new NamedAnything(value, value + " " + getUnits()));
 }
 return result;
}
origin: Unidata/thredds

@Override
public PointFeature next() {
 double obsTime = timeAxis.getCoordMidpoint(curr);
 StructureDataScalar coords = new StructureDataScalar("Coords");
 for (VarIter vi : varIters) {
  coords.addMember(vi.cov.getName(), null, null, vi.cov.getDataType(), (Number) vi.dataIter.getObjectNext());
 }
 curr++;
 PointFeature pf = new MyPointFeature(MyStationFeature.this, obsTime, 0.0, timeUnit, coords);
 calcBounds(pf);
 return pf;
}
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

public Optional<CoordReturn> findXYindexFromCoord(double x, double y) {
 CoordReturn result = new CoordReturn();
 if (isProjection) {
  CoordAxisHelper xhelper = new CoordAxisHelper(xAxis);
  CoordAxisHelper yhelper = new CoordAxisHelper(yAxis);
  result.x = xhelper.findCoordElement(x, false);
  result.y = yhelper.findCoordElement(y, false);
  if (result.x >= 0 && result.x < xAxis.getNcoords() && result.y >= 0 && result.y < yAxis.getNcoords()) {
   result.xcoord = xAxis.getCoordMidpoint(result.x);
   result.ycoord = yAxis.getCoordMidpoint(result.y);
   return Optional.of(result);
  } else {
   return Optional.empty("not in grid");
  }
 } else { // 1D lat lon case
  CoordAxisHelper xhelper = new CoordAxisHelper(lonAxis);
  CoordAxisHelper yhelper = new CoordAxisHelper(latAxis);
  double lon = LatLonPointImpl.lonNormalFrom(x, lonAxis.getStartValue());
  result.x = xhelper.findCoordElement(lon, false);
  result.y = yhelper.findCoordElement(y, false);
  if (result.x >= 0 && result.x < lonAxis.getNcoords() && result.y >= 0 && result.y < latAxis.getNcoords()) {
   result.xcoord = lonAxis.getCoordMidpoint(result.x);
   result.ycoord = latAxis.getCoordMidpoint(result.y);
   return Optional.of(result);
  } else {
   return Optional.empty("not in grid");
  }
 }
}
origin: Unidata/thredds

@Nonnull
private CoverageCoordAxisBuilder subsetValuesClosest(double want) {
 int closest_index = findCoordElement(want, true); // bounded, always valid index
 CoverageCoordAxisBuilder builder = new CoverageCoordAxisBuilder(axis);
 if (axis.spacing == CoverageCoordAxis.Spacing.regularPoint) {
  double val = axis.getCoordMidpoint(closest_index);
  builder.subset(1, val, val, 0.0, null);
 } else if (axis.spacing == CoverageCoordAxis.Spacing.regularInterval) {
  double val1 = axis.getCoordEdge1(closest_index);
  double val2 = axis.getCoordEdge2(closest_index);
  builder.subset(1, val1, val2, val2-val1, null);
 } else {
  builder.subset(1, 0, 0, 0.0, makeValues(closest_index));
 }
 try {
  builder.setRange(new Range(closest_index, closest_index));
 } catch (InvalidRangeException e) {
  throw new RuntimeException(e); // cant happen
 }
 return builder;
}
origin: Unidata/thredds

private void addAdjustedTimeCoords(SubsetParams result, CoverageCoordAxis1D axis, int coordIdx, CalendarDate runtime) {
 // this must be adjusted to be offset from the runtime.
 // adjust = end - start
 // axisCoordOffset + axis.reftime = offset + runtime
 // offset = axisCoordOffset + axis.reftime - runtime
 // offset = axisCoordOffset + adjust
 // offset = axisCoordOffset + end - start = axisCoordOffset + axis.reftime - runtime
 // therefore: end = reftime, start = runtime
 double adjust = axis.getOffsetInTimeUnits(runtime, axis.getRefDate());
 if (axis.isInterval()) {
  double[] adjustVal = new double[] {axis.getCoordEdge1(coordIdx)+adjust, axis.getCoordEdge2(coordIdx)+adjust};
  result.setTimeOffsetIntv(adjustVal);
  double mid = (adjustVal[0]+adjustVal[1]) / 2.0;
  result.set(SubsetParams.timeOffsetUnit, axis.makeDateInTimeUnits(runtime, mid)); // validation
  result.set(SubsetParams.timeOffsetUnit, axis.getCalendarDateUnit()); // validation
 } else {
  double adjustVal = axis.getCoordMidpoint(coordIdx) + adjust;
  result.setTimeOffset(adjustVal);
  result.set(SubsetParams.timeOffsetDate, axis.makeDateInTimeUnits(runtime, adjustVal)); // validation
  result.set(SubsetParams.timeOffsetUnit, axis.getCalendarDateUnit()); // validation
 }
}
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

assertNotNull("time", time);
Assert.assertEquals(1, time.getNcoords());
CalendarDate date = time.makeDate(time.getCoordMidpoint(0));
logger.debug("date = {}", date);
Assert.assertEquals(date, CalendarDate.parseISOformat(null, "2012-04-19T00:00:00Z"));
assertNotNull("vert", vert);
Assert.assertEquals(1, vert.getNcoords());
double vertCoord = vert.getCoordMidpoint(0);
logger.debug("date = {}", date);
Assert2.assertNearlyEquals(800.0, vertCoord);
origin: Unidata/thredds

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());
 Assert2.assertNearlyEquals(offsetVal, timeAxis1D.getCoordMidpoint(0));
origin: Unidata/thredds

CoverageCoordAxis1D runtimeAxis1D = (CoverageCoordAxis1D) runtimeAxis;
if (runtime != null)
 Assert.assertEquals("runtime coord", runtime, runtimeAxis.makeDate(runtimeAxis1D.getCoordMidpoint(0)));
  Assert.assertTrue("time coord lower", !upper.isBefore(time));         // upper >= time
 } else {
  Assert.assertEquals("time coord", time, timeAxis1D.makeDate(timeAxis1D.getCoordMidpoint(0)));
origin: Unidata/thredds

Assert.assertEquals(1, runtimeAxis.getNcoords());
CoverageCoordAxis1D runtimeAxis1D = (CoverageCoordAxis1D) runtimeAxis;
Assert.assertEquals("runtime coord", runtime, runtimeAxis.makeDate(runtimeAxis1D.getCoordMidpoint(0)));
ucar.nc2.ft2.coverageCoverageCoordAxis1DgetCoordMidpoint

Popular methods of CoverageCoordAxis1D

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

Popular in Java

  • Making http post requests using okhttp
  • getSharedPreferences (Context)
  • putExtra (Intent)
  • setScale (BigDecimal)
  • Runnable (java.lang)
    Represents a command that can be executed. Often used to run code in a different Thread.
  • InetAddress (java.net)
    An Internet Protocol (IP) address. This can be either an IPv4 address or an IPv6 address, and in pra
  • BitSet (java.util)
    The BitSet class implements abit array [http://en.wikipedia.org/wiki/Bit_array]. Each element is eit
  • Hashtable (java.util)
    A plug-in replacement for JDK1.5 java.util.Hashtable. This version is based on org.cliffc.high_scale
  • Executors (java.util.concurrent)
    Factory and utility methods for Executor, ExecutorService, ScheduledExecutorService, ThreadFactory,
  • JOptionPane (javax.swing)
  • Best plugins for Eclipse
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