public CalendarDate[] getCoordBoundsDate( int i) { double[] intv = getCoordBounds(i); CalendarDate[] e = new CalendarDate[2]; e[0] = helper.makeCalendarDateFromOffset(intv[0]); e[1] = helper.makeCalendarDateFromOffset(intv[1]); return e; }
public CoordinateAxisTimeHelper getCoordinateAxisTimeHelper() { return new CoordinateAxisTimeHelper(getCalendarFromAttribute(), getUnitsString()); }
this.helper= new CoordinateAxisTimeHelper(getCalendarFromAttribute(), getUnitsString()); double val = ii.getDoubleNext(); if (Double.isNaN(val)) continue; // WTF ?? result.add( helper.makeCalendarDateFromOffset(val)); count++;
public int findTimeIndexFromCalendarDate(int run_idx, CalendarDate want) throws IOException, InvalidRangeException { CoordinateAxisTimeHelper helper = getCoordinateAxisTimeHelper(); double wantOffset = helper.offsetFromRefDate(want); if (isInterval()) { ArrayDouble.D3 bounds = getCoordBoundsArray(); if (bounds == null) throw new IllegalStateException("getCoordBoundsArray returned null for coordinate "+getFullName()); ArrayDouble.D2 boundsForRun = (ArrayDouble.D2) bounds.slice(0,run_idx ); int idx = findSingleHit(boundsForRun, wantOffset); if (idx >= 0) return idx; if (idx == -1) return -1; // multiple hits = choose closest to the midpoint return findClosest(boundsForRun, wantOffset); } else { ArrayDouble.D2 values = getCoordValuesArray(); ArrayDouble.D1 valuesForRun = (ArrayDouble.D1) values.slice(0,run_idx ); for (int i=0; i<valuesForRun.getSize(); i++) { if (Misc.nearlyEquals(valuesForRun.get(i), wantOffset)) return i; } return -1; } }
this.helper= new CoordinateAxisTimeHelper(getCalendarFromAttribute(), getUnitsString()); double val = ii.getDoubleNext(); if (Double.isNaN(val)) continue; // WTF ?? result.add( helper.makeCalendarDateFromOffset(val)); count++;
new CoordinateAxisTimeHelper(cal, tca.findAttributeIgnoreCase("units").getStringValue()); CalendarDate date = coordAxisTimeHelper.makeCalendarDateFromOffset(times.getInt(0));
public CalendarDate[] getCoordBoundsDate( int i) { double[] intv = getCoordBounds(i); CalendarDate[] e = new CalendarDate[2]; e[0] = helper.makeCalendarDateFromOffset(intv[0]); e[1] = helper.makeCalendarDateFromOffset(intv[1]); return e; }
public CoordinateAxisTimeHelper getCoordinateAxisTimeHelper() { return new CoordinateAxisTimeHelper(getCalendarFromAttribute(), getUnitsString()); }
new CoordinateAxisTimeHelper(cal, tca.findAttributeIgnoreCase("units").getStringValue()); CalendarDate date = coordAxisTimeHelper.makeCalendarDateFromOffset(times.getInt(0));
private CalendarDate makeCalendarDateFromStringCoord(String coordValue, VariableDS org, Formatter errMessages) throws IOException { CalendarDate cd = helper.makeCalendarDateFromOffset(coordValue); if (cd == null) { if (errMessages != null) { errMessages.format("String time coordinate must be ISO formatted= %s%n", coordValue); logger.info("Char time coordinate must be ISO formatted= {} file = {}", coordValue, org.getDatasetLocation()); } throw new IllegalArgumentException(); } return cd; }
/** * Constructor for CHAR or STRING variables. * Must be ISO dates. * * @param ncd the containing dataset * @param org the underlying Variable * @param errMessages put error messages here; may be null * @param dims list of dimensions * @throws IOException on read error * @throws IllegalArgumentException if cant convert coordinate values to a Date */ private CoordinateAxis1DTime(NetcdfDataset ncd, VariableDS org, Formatter errMessages, String dims) throws IOException { super(ncd, org.getParentGroup(), org.getShortName(), DataType.STRING, dims, org.getUnitsString(), org.getDescription()); this.ncd = ncd; //Gotta set the original var. Otherwise it would be unable to read the values this.orgVar = org; this.orgName = org.orgName; this.helper = new CoordinateAxisTimeHelper(getCalendarFromAttribute(), null); if (org.getDataType() == DataType.CHAR) cdates = makeTimesFromChar(org, errMessages); else cdates = makeTimesFromStrings(org, errMessages); List<Attribute> atts = org.getAttributes(); for (Attribute att : atts) { addAttribute(att); } }
public CalendarDate getCoordBoundsMidpointDate( int i) { double[] intv = getCoordBounds(i); double midpoint = (intv[0]+intv[1])/2; return helper.makeCalendarDateFromOffset(midpoint); }
/** * Constructor for CHAR or STRING variables. * Must be ISO dates. * * @param ncd the containing dataset * @param org the underlying Variable * @param errMessages put error messages here; may be null * @param dims list of dimensions * @throws IOException on read error * @throws IllegalArgumentException if cant convert coordinate values to a Date */ private CoordinateAxis1DTime(NetcdfDataset ncd, VariableDS org, Formatter errMessages, String dims) throws IOException { super(ncd, org.getParentGroup(), org.getShortName(), DataType.STRING, dims, org.getUnitsString(), org.getDescription()); //Gotta set the original var. Otherwise it would be unable to read the values this.orgVar = org; this.orgName = org.orgName; this.helper = new CoordinateAxisTimeHelper(getCalendarFromAttribute(), null); if (org.getDataType() == DataType.CHAR) cdates = makeTimesFromChar(org, errMessages); else cdates = makeTimesFromStrings(org, errMessages); List<Attribute> atts = org.getAttributes(); for (Attribute att : atts) { addAttribute(att); } }
private CalendarDate makeCalendarDateFromStringCoord(String coordValue, VariableDS org, Formatter errMessages) throws IOException { CalendarDate cd = helper.makeCalendarDateFromOffset(coordValue); if (cd == null) { if (errMessages != null) { errMessages.format("String time coordinate must be ISO formatted= %s%n", coordValue); logger.info("Char time coordinate must be ISO formatted= {} file = {}", coordValue, org.getDatasetLocation()); } throw new IllegalArgumentException(); } return cd; }
timeBounds[1] = timeCoord2DBoundsArray.get(rtIndex, t, 1); CalendarDate[] timeBoundsDate = new CalendarDate[2]; timeBoundsDate[0] = helper.makeCalendarDateFromOffset(timeBounds[0]); timeBoundsDate[1] = helper.makeCalendarDateFromOffset(timeBounds[1]); dtCoords.setTimeOffsetIntv(timeBounds); dtCoords.set("timeDateIntv", timeBoundsDate); } else { double timeCoord = tcoord2D.getCoordValue(rtIndex, t); CalendarDate timeCoordDate = helper.makeCalendarDateFromOffset(timeCoord); dtCoords.setTime(timeCoordDate);