@@ -35,6 +35,41 @@ using Dates
3535 @test dset_partial. forecast == " f03"
3636 end
3737
38+ @testset " Base.read(::Type{RAPDataset}, path)" begin
39+ # Test parsing a standard RAP filename
40+ path1 = " rap_20240115_t00z_awp130_f00.grib2"
41+ dset1 = read (RapidRefreshData. RAPDataset, path1)
42+ @test dset1. date == Date (2024 , 1 , 15 )
43+ @test dset1. cycle_time == " t00z"
44+ @test dset1. grid == " awp130"
45+ @test dset1. forecast == " f00"
46+
47+ # Test parsing with different parameters
48+ path2 = " rap_20241225_t12z_awp252_f06.grib2"
49+ dset2 = read (RapidRefreshData. RAPDataset, path2)
50+ @test dset2. date == Date (2024 , 12 , 25 )
51+ @test dset2. cycle_time == " t12z"
52+ @test dset2. grid == " awp252"
53+ @test dset2. forecast == " f06"
54+
55+ # Test parsing with full path
56+ full_path = " /some/directory/rap_20240305_t18z_awp130_f03.grib2"
57+ dset3 = read (RapidRefreshData. RAPDataset, full_path)
58+ @test dset3. date == Date (2024 , 3 , 5 )
59+ @test dset3. cycle_time == " t18z"
60+ @test dset3. grid == " awp130"
61+ @test dset3. forecast == " f03"
62+
63+ # Test that read works with broadcast
64+ paths = [" rap_20240101_t00z_awp130_f00.grib2" , " rap_20240102_t06z_awp252_f12.grib2" ]
65+ dsets = read .(RapidRefreshData. RAPDataset, paths)
66+ @test length (dsets) == 2
67+ @test dsets[1 ]. date == Date (2024 , 1 , 1 )
68+ @test dsets[2 ]. date == Date (2024 , 1 , 2 )
69+ @test dsets[1 ]. cycle_time == " t00z"
70+ @test dsets[2 ]. cycle_time == " t06z"
71+ end
72+
3873 @testset " url() function" begin
3974 # Test URL generation with default dataset
4075 test_date = Date (2024 , 1 , 15 )
@@ -234,6 +269,46 @@ using Dates
234269 @test dset_partial. forecast == " f012"
235270 end
236271
272+ @testset " Base.read(::Type{GFSDataset}, path)" begin
273+ # Test parsing a standard GFS filename
274+ path1 = " gfs_20240115_00_0p25_atmos_f000.grib2"
275+ dset1 = read (RapidRefreshData. GFSDataset, path1)
276+ @test dset1. date == Date (2024 , 1 , 15 )
277+ @test dset1. cycle == " 00"
278+ @test dset1. resolution == " 0p25"
279+ @test dset1. product == " atmos"
280+ @test dset1. forecast == " f000"
281+
282+ # Test parsing with different parameters
283+ path2 = " gfs_20241225_12_0p50_wave_f024.grib2"
284+ dset2 = read (RapidRefreshData. GFSDataset, path2)
285+ @test dset2. date == Date (2024 , 12 , 25 )
286+ @test dset2. cycle == " 12"
287+ @test dset2. resolution == " 0p50"
288+ @test dset2. product == " wave"
289+ @test dset2. forecast == " f024"
290+
291+ # Test parsing with full path
292+ full_path = " /some/directory/gfs_20240305_06_1p00_atmos_f012.grib2"
293+ dset3 = read (RapidRefreshData. GFSDataset, full_path)
294+ @test dset3. date == Date (2024 , 3 , 5 )
295+ @test dset3. cycle == " 06"
296+ @test dset3. resolution == " 1p00"
297+ @test dset3. product == " atmos"
298+ @test dset3. forecast == " f012"
299+
300+ # Test that read works with broadcast
301+ paths = [" gfs_20240101_00_0p25_atmos_f000.grib2" , " gfs_20240102_18_0p50_wave_f384.grib2" ]
302+ dsets = read .(RapidRefreshData. GFSDataset, paths)
303+ @test length (dsets) == 2
304+ @test dsets[1 ]. date == Date (2024 , 1 , 1 )
305+ @test dsets[2 ]. date == Date (2024 , 1 , 2 )
306+ @test dsets[1 ]. cycle == " 00"
307+ @test dsets[2 ]. cycle == " 18"
308+ @test dsets[1 ]. product == " atmos"
309+ @test dsets[2 ]. product == " wave"
310+ end
311+
237312 @testset " GFSDataset url() function" begin
238313 # Test URL generation with default dataset
239314 test_date = Date (2024 , 1 , 15 )
0 commit comments