@@ -604,6 +604,81 @@ using Dates
604604 @test next7. cycle == " 10"
605605 end
606606
607+ @testset " datasets() function" begin
608+ # Test HRRRDataset - hourly cycles
609+ hrrr_dsets = datasets (HRRRDataset, DateTime (2024 ,1 ,15 ,0 ), DateTime (2024 ,1 ,15 ,5 ))
610+ @test length (hrrr_dsets) == 6 # hours 0,1,2,3,4,5
611+ @test all (d -> d isa HRRRDataset, hrrr_dsets)
612+ @test all (d -> d. date == Date (2024 ,1 ,15 ), hrrr_dsets)
613+ @test [d. cycle for d in hrrr_dsets] == [" 00" , " 01" , " 02" , " 03" , " 04" , " 05" ]
614+
615+ # Test HRRRDataset - crossing midnight
616+ hrrr_midnight = datasets (HRRRDataset, DateTime (2024 ,1 ,15 ,22 ), DateTime (2024 ,1 ,16 ,2 ))
617+ @test length (hrrr_midnight) == 5 # 22,23,00,01,02
618+ @test hrrr_midnight[1 ]. date == Date (2024 ,1 ,15 )
619+ @test hrrr_midnight[1 ]. cycle == " 22"
620+ @test hrrr_midnight[end ]. date == Date (2024 ,1 ,16 )
621+ @test hrrr_midnight[end ]. cycle == " 02"
622+
623+ # Test RAPDataset - 6-hourly cycles
624+ rap_dsets = datasets (RAPDataset, DateTime (2024 ,1 ,15 ,0 ), DateTime (2024 ,1 ,15 ,23 ))
625+ @test length (rap_dsets) == 4 # t00z, t06z, t12z, t18z
626+ @test all (d -> d isa RAPDataset, rap_dsets)
627+ @test all (d -> d. date == Date (2024 ,1 ,15 ), rap_dsets)
628+ @test [d. cycle for d in rap_dsets] == [" t00z" , " t06z" , " t12z" , " t18z" ]
629+
630+ # Test RAPDataset - partial day
631+ rap_partial = datasets (RAPDataset, DateTime (2024 ,1 ,15 ,7 ), DateTime (2024 ,1 ,15 ,17 ))
632+ @test length (rap_partial) == 1 # only t12z
633+ @test rap_partial[1 ]. cycle == " t12z"
634+
635+ # Test RAPDataset - crossing midnight
636+ rap_midnight = datasets (RAPDataset, DateTime (2024 ,1 ,15 ,12 ), DateTime (2024 ,1 ,16 ,12 ))
637+ @test length (rap_midnight) == 5 # t12z, t18z, t00z, t06z, t12z
638+ @test rap_midnight[1 ]. date == Date (2024 ,1 ,15 )
639+ @test rap_midnight[1 ]. cycle == " t12z"
640+ @test rap_midnight[end ]. date == Date (2024 ,1 ,16 )
641+ @test rap_midnight[end ]. cycle == " t12z"
642+
643+ # Test GFSDataset - 6-hourly cycles
644+ gfs_dsets = datasets (GFSDataset, DateTime (2024 ,1 ,15 ,0 ), DateTime (2024 ,1 ,15 ,23 ))
645+ @test length (gfs_dsets) == 4 # 00, 06, 12, 18
646+ @test all (d -> d isa GFSDataset, gfs_dsets)
647+ @test all (d -> d. date == Date (2024 ,1 ,15 ), gfs_dsets)
648+ @test [d. cycle for d in gfs_dsets] == [" 00" , " 06" , " 12" , " 18" ]
649+
650+ # Test GFSDataset - multi-day
651+ gfs_multiday = datasets (GFSDataset, DateTime (2024 ,1 ,15 ,0 ), DateTime (2024 ,1 ,16 ,23 ))
652+ @test length (gfs_multiday) == 8 # 4 per day × 2 days
653+ @test gfs_multiday[1 ]. date == Date (2024 ,1 ,15 )
654+ @test gfs_multiday[end ]. date == Date (2024 ,1 ,16 )
655+
656+ # Test empty range (no datasets match)
657+ gfs_empty = datasets (GFSDataset, DateTime (2024 ,1 ,15 ,1 ), DateTime (2024 ,1 ,15 ,5 ))
658+ @test length (gfs_empty) == 0
659+
660+ # Test exact boundary match
661+ hrrr_exact = datasets (HRRRDataset, DateTime (2024 ,1 ,15 ,12 ), DateTime (2024 ,1 ,15 ,12 ))
662+ @test length (hrrr_exact) == 1
663+ @test hrrr_exact[1 ]. cycle == " 12"
664+
665+ # Test that default fields are preserved
666+ hrrr_defaults = datasets (HRRRDataset, DateTime (2024 ,1 ,15 ,0 ), DateTime (2024 ,1 ,15 ,0 ))
667+ @test hrrr_defaults[1 ]. region == " conus"
668+ @test hrrr_defaults[1 ]. product == " wrfsfc"
669+ @test hrrr_defaults[1 ]. forecast == " f00"
670+
671+ rap_defaults = datasets (RAPDataset, DateTime (2024 ,1 ,15 ,0 ), DateTime (2024 ,1 ,15 ,0 ))
672+ @test rap_defaults[1 ]. grid == " awp130"
673+ @test rap_defaults[1 ]. product == " pgrb"
674+ @test rap_defaults[1 ]. forecast == " f00"
675+
676+ gfs_defaults = datasets (GFSDataset, DateTime (2024 ,1 ,15 ,0 ), DateTime (2024 ,1 ,15 ,0 ))
677+ @test gfs_defaults[1 ]. resolution == " 0p25"
678+ @test gfs_defaults[1 ]. product == " atmos"
679+ @test gfs_defaults[1 ]. forecast == " f000"
680+ end
681+
607682 @testset " Band subsetting" begin
608683 # Test with HRRR dataset
609684 test_date = Date (2024 , 1 , 15 )
0 commit comments