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

How to use
CoordinateAxis1DTime
in
ucar.nc2.dataset

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

  • Common ways to obtain CoordinateAxis1DTime
private void myMethod () {
CoordinateAxis1DTime c =
  • Codota IconGridCoordSystem gcs;gcs.getTimeAxis1D()
  • Codota IconGridCoordSystem gridCoordSystem;gridCoordSystem.getRunTimeAxis()
  • Codota IconNetcdfDataset ncd;VariableDS org;Formatter errMessages;CoordinateAxis1DTime.factory(ncd, org, errMessages)
  • Smart code suggestions by Codota
}
origin: edu.ucar/netcdf

TimeCoord(CalendarDate runDate, CoordinateAxis1DTime axis) {
 this.runDate = runDate;
 this.axisName = axis.getFullName();
 DateUnit unit = null;
 try {
  unit = new DateUnit(axis.getUnitsString());
 } catch (Exception e) {
  throw new IllegalArgumentException("Not a unit of time " + axis.getUnitsString());
 }
 int n = (int) axis.getSize();
 if (axis.isInterval()) {
  this.isInterval = true;
  this.bound1 = new double[n];
  this.bound2 = new double[n];
  double[] orgBound1 =  axis.getBound1();
  double[] orgBound2 =  axis.getBound2();
  this.bound2 = new double[n];
  for (int i = 0; i < axis.getSize(); i++) {
   this.bound1[i] = getValueInHours(unit, orgBound1[i]);
   this.bound2[i] = getValueInHours(unit, orgBound2[i]);
  }
 } else {
  offset = new double[n];
  for (int i = 0; i < axis.getSize(); i++) {
   offset[i] = getValueInHours(unit, axis.getCoordValue(i));
  }
 }
}
origin: edu.ucar/cdm

private CoordinateAxis1DTime makeTimeAxisForRun(int run_index) {
 VariableDS section;
 try {
  section = (VariableDS) tAxis.slice(0, run_index);
  return CoordinateAxis1DTime.factory(ds, section, null);
 } catch (InvalidRangeException | IOException e) {
  e.printStackTrace();
 }
 return null;
}
origin: Unidata/thredds

private Range makeTimeRange(CalendarDateRange dateRange, CoordinateAxis1DTime timeAxis, int stride_time) throws InvalidRangeException {
 Range timeRange = null;
 if ((dateRange != null) && (timeAxis != null)) {
  int startIndex = timeAxis.findTimeIndexFromCalendarDate(dateRange.getStart());
  int endIndex = timeAxis.findTimeIndexFromCalendarDate(dateRange.getEnd());
  if (startIndex < 0)
   throw new InvalidRangeException("start time=" + dateRange.getStart() + " must be >= " + timeAxis.getCalendarDate(0));
  if (endIndex < 0)
   throw new InvalidRangeException("end time=" + dateRange.getEnd() + " must be >= " + timeAxis.getCalendarDate(0));
  if (stride_time <= 1) stride_time = 1;
  timeRange = new Range(startIndex, endIndex, stride_time);
 }
 return timeRange;
}
origin: edu.ucar/netcdf

/**
 * only if isRegular() LOOK REDO
 *
 * @return time unit
 * @throws Exception on bad unit string
 */
public TimeUnit getTimeResolution() throws Exception {
 String tUnits = getUnitsString();
 StringTokenizer stoker = new StringTokenizer(tUnits);
 double tResolution = getIncrement();
 return new TimeUnit(tResolution, stoker.nextToken());
}
origin: Unidata/thredds

@Override
public List<NamedObject> getNames() {
 List<CalendarDate> cdates = getCalendarDates();
 List<NamedObject> names = new ArrayList<>(cdates.size());
 for (CalendarDate cd : cdates)
  names.add(new NamedAnything(CalendarDateFormatter.toDateTimeStringISO(cd), getShortName())); // "calendar date"));
 return names;
}
origin: edu.ucar/cdm

this.helper= new CoordinateAxisTimeHelper(getCalendarFromAttribute(), getUnitsString());
 Dimension localDim = new Dimension(getShortName(), count, false);
 setDimension(0, localDim);
 setCachedData(shortData, true);
origin: Unidata/thredds

static void readAllTimes1D(Coverage cover, GridDatatype dt, CalendarDate rt_val, int rt_idx,
              CoordinateAxis1DTime timeAxis, CoordinateAxis1D ensAxis, CoordinateAxis1D vertAxis) {
 if (timeAxis == null)
  readAllEnsembles(cover, dt, rt_val, rt_idx, null, -1, ensAxis, vertAxis);
 else {
  for (int i = 0; i < timeAxis.getSize(); i++) {
   CalendarDate timeDate = timeAxis.isInterval() ? timeAxis.getCoordBoundsMidpointDate(i) :  timeAxis.getCalendarDate(i);
   readAllEnsembles(cover, dt, rt_val, rt_idx, timeDate, i, ensAxis, vertAxis);
  }
 }
}
origin: edu.ucar/cdm

/**
* Get the the ith CalendarDate.
* @param idx index
* @return the ith CalendarDate
*/
public CalendarDate getCalendarDate (int idx) {
 List<CalendarDate> cdates = getCalendarDates();  // in case we want to lazily evaluate
 return cdates.get(idx);
}
origin: edu.ucar/netcdf

CoordinateAxis1DTime timeCoordVar = CoordinateAxis1DTime.factory(ncDataset, vds, null);
dateList.addAll(timeCoordVar.getCalendarDates());
origin: Unidata/thredds

 @Test
 public void testFloatingPointCompare() throws Exception {
  String spec = TestDir.cdmUnitTestDir+"ft/fmrc/fp_precision/sediment_thickness_#yyMMddHHmm#.*\\.nc$";
  System.out.printf("%n====================FMRC dataset %s%n", spec);
  Formatter errlog = new Formatter();
  Fmrc fmrc = Fmrc.open(spec, errlog);
  assert (fmrc != null) : errlog;

  try (ucar.nc2.dt.GridDataset gridDs = fmrc.getDatasetBest()) {
   GridDatatype v = gridDs.findGridByShortName("thickness_of_sediment");
   assert v != null;
   GridCoordSystem gcs = v.getCoordinateSystem();
   CoordinateAxis1DTime time = gcs.getTimeAxis1D();

   Assert.assertEquals("hours since 2015-03-08 12:51:00.000 UTC", time.getUnitsString());
   Assert.assertEquals(74, time.getSize());
   Array data = time.read();
   logger.debug("{}", NCdumpW.toString(data));

   for (CalendarDate cd : time.getCalendarDates()) {
    assert cd.getFieldValue(CalendarPeriod.Field.Minute) == 0 : System.out.printf("%s%n", cd);
   }
  }
 }
}
origin: edu.ucar/netcdf

 /**
 * Does not handle non-standard Calendars
 * @deprecated use getCalendarDateRange()
 */
public DateRange getDateRange() {
 CalendarDateRange cdr = getCalendarDateRange();
 return cdr.toDateRange();
}
origin: edu.ucar/netcdf

int startIndex = timeAxis.findTimeIndexFromCalendarDate( timeRange.getStart() );
int endIndex = timeAxis.findTimeIndexFromCalendarDate( timeRange.getEnd() );
if ( startIndex < 0 || startIndex > timeAxis.getSize() -1
   || endIndex < 0 || endIndex > timeAxis.getSize() - 1 )
 CalendarDateRange cdr = timeAxis.getCalendarDateRange();
 String availStart = cdr.getStart().toString();
 String availEnd = cdr.getEnd().toString();
origin: edu.ucar/netcdf

/**
 * Get the list of times as Dates.
 * If 2D, return list of unique dates.
 *
 * @return array of java.util.Date, or Date[0].
 * @deprecated  use getCalendarDates
 */
public java.util.Date[] getTimeDates() {
 if ((timeTaxis != null) && (timeTaxis.getSize() > 0)) {
  return timeTaxis.getTimeDates();
 } else if ((tAxis != null) && (tAxis.getSize() > 0))  {
  return makeTimes2D();
 }
 return new Date[0];
}
origin: edu.ucar/netcdf

@Override
public CoordinateAxis1DTime getTimeAxisForRun(CalendarDate runTime) {
 CoordinateAxis1DTime runTimeAxis = getRunTimeAxis();
 int runIndex = runTimeAxis.findTimeIndexFromCalendarDate(runTime);
 int nruns = (int) runTimeAxis.getSize();
 if ((runIndex < 0) || (runIndex >= nruns))
  throw new IllegalArgumentException("getTimeAxisForRun index out of bounds= " + runIndex);
 if (timeAxisForRun == null)
  timeAxisForRun = new CoordinateAxis1DTime[nruns];
 if (timeAxisForRun[runIndex] == null)
  timeAxisForRun[runIndex] = makeTimeAxisForRun(runIndex);
 return timeAxisForRun[runIndex];
}
origin: Unidata/thredds

static void readAllRuntimes(Coverage cover, GridDatatype dt, CoordinateAxis1DTime runtimeAxis, CoordinateAxis1D ensAxis, CoordinateAxis1D vertAxis) {
 GridCoordSystem csys = dt.getCoordinateSystem();
 CoordinateAxis1DTime timeAxis1D = csys.getTimeAxis1D();
 CoordinateAxis timeAxis = csys.getTimeAxis();
 CoordinateAxis2D timeAxis2D = (timeAxis instanceof CoordinateAxis2D) ? (CoordinateAxis2D) timeAxis : null;
 if (runtimeAxis == null)
  readAllTimes1D(cover, dt, null, -1, timeAxis1D, ensAxis, vertAxis);
 else if (timeAxis2D == null) {  // 1D time or no time
  for (int i = 0; i < runtimeAxis.getSize(); i++)
   readAllTimes1D(cover, dt, runtimeAxis.getCalendarDate(i), i, timeAxis1D, ensAxis, vertAxis);
 } else {  // 2D time
  TimeHelper helper = TimeHelper.factory(timeAxis.getUnitsString(), timeAxis.getAttributeContainer());
  if (timeAxis2D.isInterval()) {
   ArrayDouble.D3 bounds = timeAxis2D.getCoordBoundsArray();
   for (int i = 0; i < runtimeAxis.getSize(); i++)
     readAllTimes2D(cover, dt, runtimeAxis.getCalendarDate(i), i, helper, bounds.slice(0, i), ensAxis, vertAxis);
  } else {
   ArrayDouble.D2 coords = timeAxis2D.getCoordValuesArray();
   for (int i = 0; i < runtimeAxis.getSize(); i++)
    readAllTimes2D(cover, dt, runtimeAxis.getCalendarDate(i), i, helper, coords.slice(0, i), ensAxis, vertAxis);
  }
 }
}
origin: edu.ucar/netcdf

/**
 * Does not handle non-standard Calendars
 * @deprecated use findTimeIndexFromCalendarDate
 */
public int findTimeIndexFromDate(java.util.Date d) {
 return findTimeIndexFromCalendarDate( CalendarDate.of(d));
}
origin: edu.ucar/netcdf

Date[] runDates = runtimeCoord.getTimeDates();
baseDate = runDates[0];
runtimes = Arrays.asList(runDates);
runtimeDimName = runtimeCoord.getDimension(0).getShortName();
coordSet.add(runtimeCoord.getFullName());
Date[] forecastDates = timeCoordRun.getTimeDates();
origin: Unidata/thredds

assert !runAxis.isScalar();
Assert.assertEquals(10, runAxis.getSize());
 Assert.assertNotNull(gridName, cov);
 CoverageCoordAxis ccaRuntime = cd.findCoordAxis(runAxis.getFullName());
 Assert.assertNotNull(runAxis.getFullName(), ccaRuntime);
 Assert.assertEquals(CoverageCoordAxis.Spacing.irregularPoint, ccaRuntime.getSpacing());
origin: edu.ucar/netcdf

/**
 * Does not handle non-standard Calendars
 * @deprecated use getCalendarDate()
 */
 public java.util.Date getTimeDate (int idx) {
  return getCalendarDate(idx).toDate();
 }
origin: edu.ucar/netcdf

@Override
public CoordinateAxis1DTime getTimeAxisForRun(int run_index) {
 if (!hasTimeAxis() || hasTimeAxis1D() || runTimeAxis == null) return null;
 int nruns = (int) runTimeAxis.getSize();
 if ((run_index < 0) || (run_index >= nruns))
  throw new IllegalArgumentException("getTimeAxisForRun index out of bounds= " + run_index);
 if (timeAxisForRun == null)
  timeAxisForRun = new CoordinateAxis1DTime[nruns];
 if (timeAxisForRun[run_index] == null)
  timeAxisForRun[run_index] = makeTimeAxisForRun(run_index);
 return timeAxisForRun[run_index];
}
ucar.nc2.datasetCoordinateAxis1DTime

Javadoc

A 1-dimensional Coordinate Axis representing Calendar time. Its coordinate values can be represented as Dates.

May use udunit dates, or ISO Strings.

Most used methods

  • getSize
  • factory
  • findTimeIndexFromCalendarDate
    Given a Date, find the corresponding time index on the time coordinate axis. Can only call this is h
  • getCalendarDate
    Get the the ith CalendarDate.
  • getCalendarDateRange
    Get calendar date range
  • getCalendarDates
    Get the list of datetimes in this coordinate as CalendarDate objects.
  • getFullName
  • getShortName
  • getTimeDates
    Does not handle non-standard Calendars
  • getUnitsString
  • isInterval
  • <init>
    Constructor for CHAR or STRING variables. Must be ISO dates.
  • isInterval,
  • <init>,
  • addAttribute,
  • findAttribute,
  • findTimeIndexFromDate,
  • getBound1,
  • getBound2,
  • getCalendarFromAttribute,
  • getCoordBounds,
  • getCoordValue

Popular in Java

  • Finding current android device location
  • getSupportFragmentManager (FragmentActivity)
  • scheduleAtFixedRate (Timer)
    Schedules the specified task for repeated fixed-rate execution, beginning after the specified delay.
  • putExtra (Intent)
  • FileOutputStream (java.io)
    A file output stream is an output stream for writing data to aFile or to a FileDescriptor. Whether
  • System (java.lang)
    Provides access to system-related information and resources including standard input and output. Ena
  • MalformedURLException (java.net)
    Thrown to indicate that a malformed URL has occurred. Either no legal protocol could be found in a s
  • Path (java.nio.file)
  • Locale (java.util)
    A Locale object represents a specific geographical, political, or cultural region. An operation that
  • ThreadPoolExecutor (java.util.concurrent)
    An ExecutorService that executes each submitted task using one of possibly several pooled threads, n
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