@@ -756,6 +756,42 @@ public void testDiscontiguousIntervalSubsetTimeRange() throws IOException, Inval
756756 }
757757 }
758758
759+ @ Test
760+ public void testRegularIntervalSubsetTimeRange () throws IOException , InvalidRangeException {
761+ String endpoint = TestDir .cdmUnitTestDir + "tds/ncep/NAM_CONUS_12km_20100915_1200.grib2" ;
762+ String covName = "Total_precipitation_surface_3_Hour_Accumulation" ;
763+
764+ logger .debug ("testRegularIntervalSubsetTimeRange Dataset {} coverage {}" , endpoint , covName );
765+
766+ try (FeatureDatasetCoverage featureDatasetCoverage = CoverageDatasetFactory .open (endpoint )) {
767+ assertThat (featureDatasetCoverage ).isNotNull ();
768+ CoverageCollection coverageCollection = featureDatasetCoverage .findCoverageDataset (FeatureType .GRID );
769+ assertThat (coverageCollection ).isNotNull ();
770+ Coverage coverage = coverageCollection .findCoverage (covName );
771+ assertThat (coverage ).isNotNull ();
772+ SubsetParams params = new SubsetParams ();
773+
774+ CalendarDate subsetTimeStart = CalendarDate .parseISOformat (null , "2010-09-15T16:00:00Z" );
775+ CalendarDate subsetTimeEnd = CalendarDate .parseISOformat (null , "2010-09-15T23:00:00Z" );
776+ // expect times are regular offsets 3, 6, 9, ... from reftime 2010-09-15T12:00:00Z
777+ int expectedStartIndex = 1 ;
778+ int expectedEndIndex = 3 ;
779+ params .setTimeRange (CalendarDateRange .of (subsetTimeStart , subsetTimeEnd ));
780+ logger .debug (" subset {}" , params );
781+
782+ GeoReferencedArray geo = coverage .readData (params );
783+ assertThat (geo ).isNotNull ();
784+ assertThat (geo .getData ().getSize ()).isGreaterThan (0 );
785+ assertThat (geo .getData ().getDouble (0 )).isEqualTo (1.0 );
786+ assertThat (geo .getData ().getDouble (1 )).isEqualTo (0.0 );
787+
788+ CoverageCoordAxis timeAxis = geo .findCoordAxis ("time1" );
789+ assertThat (timeAxis ).isNotNull ();
790+ assertThat (timeAxis .getSpacing ()).isEqualTo (Spacing .regularInterval );
791+ assertThat (timeAxis .getRange ()).isEqualTo (new Range (expectedStartIndex , expectedEndIndex ));
792+ }
793+ }
794+
759795 ///////////////////////////////////////////////////////////////////////////////////////////
760796 // ENsemble
761797
0 commit comments