public Optional < TimeOffsetAxis > subsetFromTime ( SubsetParams params , CalendarDate runDate ) { CoordAxisHelper helper = new CoordAxisHelper ( this ) ; CoverageCoordAxisBuilder builder = null ; if ( params . isTrue ( SubsetParams . timePresent ) ) { double offset = getOffsetInTimeUnits ( runDate , CalendarDate . present ( ) ) ; builder = helper . subsetClosest ( offset ) ; } CalendarDate dateWanted = ( CalendarDate ) params . get ( SubsetParams . time ) ; if ( dateWanted != null ) { // convertFrom, convertTo double offset = getOffsetInTimeUnits ( runDate , dateWanted ) ; builder = helper . subsetClosest ( offset ) ; } Integer stride = ( Integer ) params . get ( SubsetParams . timeStride ) ; if ( stride == null || stride < 0 ) stride = 1 ; CalendarDateRange dateRange = ( CalendarDateRange ) params . get ( SubsetParams . timeRange ) ; if ( dateRange != null ) { double min = getOffsetInTimeUnits ( runDate , dateRange . getStart ( ) ) ; double max = getOffsetInTimeUnits ( runDate , dateRange . getEnd ( ) ) ; Optional < CoverageCoordAxisBuilder > buildero = helper . subset ( min , max , stride ) ; if ( buildero . isPresent ( ) ) builder = buildero . get ( ) ; else return Optional . empty ( buildero . getErrorMessage ( ) ) ; } assert ( builder != null ) ; // all the offsets are reletive to rundate builder . setReferenceDate ( runDate ) ; return Optional . of ( new TimeOffsetAxis ( builder ) ) ; }
normal case already handled this is the case where a time has been specified and only one runtime