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;
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;
}
}