@@ -14,11 +14,18 @@ function __init__()
1414end
1515
1616# -----------------------------------------------------------------------------# RAPDataset
17- # Products:
18- # pgrb: Pressure Levels
19- # sfcbf: Surface Fields
20- # isobf: Isentropic
21-
17+ """
18+ RAPDataset(; date, cycle_time, grid, product, forecast)
19+
20+ NOAA Rapid Refresh (RAP) dataset descriptor.
21+
22+ # Fields
23+ - `date::Date`: Forecast initialization date (default: today)
24+ - `cycle_time::String`: Model run time - "t00z", "t06z", "t12z", or "t18z" (default: "t00z")
25+ - `grid::String`: Grid resolution - "awp130" (~13km) or "awp252" (~32km) (default: "awp130")
26+ - `product::String`: Data type - "pgrb" (pressure), "sfcbf" (surface), or "isobf" (isentropic) (default: "pgrb")
27+ - `forecast::String`: Forecast hour - "f00" to "f18" (default: "f00")
28+ """
2229@kwdef struct RAPDataset
2330 date:: Date = today ()
2431 cycle_time:: String = " t00z"
@@ -43,33 +50,65 @@ function Base.parse(::Type{RAPDataset}, local_path::String)
4350 return RAPDataset (; date, cycle_time, grid, forecast)
4451end
4552
53+ """
54+ url(dset::RAPDataset) -> String
55+
56+ Generate AWS S3 URL for the RAP dataset.
57+ """
4658function url (dset:: RAPDataset )
4759 " $rap_base_url$(Dates. format (dset. date, " yyyymmdd" )) /rap.$(dset. cycle_time) .$(dset. grid) pgrb$(dset. forecast) .grib2"
4860end
4961
62+ """
63+ local_path(dset::RAPDataset) -> String
64+
65+ Get local cache path for the RAP dataset.
66+ """
5067function local_path (dset:: RAPDataset )
5168 joinpath (dir, " rap_$(Dates. format (dset. date, " yyyymmdd" )) _$(dset. cycle_time) _$(dset. grid) _$(dset. forecast) .grib2" )
5269end
5370
71+ """
72+ get(dset::RAPDataset) -> String
73+
74+ Download RAP dataset to cache (if needed) and return filepath.
75+ """
5476function Base. get (dset:: RAPDataset )
5577 isfile (local_path (dset)) ? local_path (dset) : Base. download (url (dset), local_path (dset))
5678end
5779
80+ """
81+ local_datasets(RAPDataset) -> Vector{RAPDataset}
82+
83+ List all cached RAP datasets.
84+ """
5885function local_datasets (:: Type{RAPDataset} )
5986 files = filter (f -> startswith (f, " rap_" ) && endswith (f, " .grib2" ), readdir (dir))
6087 parse .(RAPDataset, files)
6188end
6289
90+ """
91+ clear_local_dataset!(dset::RAPDataset)
92+
93+ Remove RAP dataset from local cache.
94+ """
6395function clear_local_dataset! (dset:: RAPDataset )
6496 isfile (local_path (dset)) && rm (local_path (dset))
6597end
6698
6799# -----------------------------------------------------------------------------# GFSDataset
68- # GFS (Global Forecast System) from NOAA
69- # Resolutions: 0p25 (0.25°), 0p50 (0.50°), 1p00 (1.00°)
70- # Products: atmos, wave
71- # Forecast: f000 to f384 (hourly to 120h, then 3-hourly to 384h)
72-
100+ """
101+ GFSDataset(; date, cycle, resolution, product, forecast)
102+
103+ NOAA Global Forecast System (GFS) dataset descriptor.
104+
105+ # Fields
106+ - `date::Date`: Forecast initialization date (default: today)
107+ - `cycle::String`: Model run time - "00", "06", "12", or "18" (default: "00")
108+ - `resolution::String`: Grid resolution - "0p25" (0.25°), "0p50" (0.50°), or "1p00" (1.00°) (default: "0p25")
109+ - `product::String`: Product type - "atmos" or "wave" (default: "atmos")
110+ - `forecast::String`: Forecast hour - "f000" to "f384" (default: "f000")
111+ """
73112@kwdef struct GFSDataset
74113 date:: Date = today ()
75114 cycle:: String = " 00" # "00", "06", "12", "18"
@@ -95,23 +134,48 @@ function Base.parse(::Type{GFSDataset}, local_path::String)
95134 return GFSDataset (; date, cycle, resolution, product, forecast)
96135end
97136
137+ """
138+ url(dset::GFSDataset) -> String
139+
140+ Generate AWS S3 URL for the GFS dataset.
141+ """
98142function url (dset:: GFSDataset )
99143 " $(gfs_base_url) gfs.$(Dates. format (dset. date, " yyyymmdd" )) /$(dset. cycle) /$(dset. product) /gfs.t$(dset. cycle) z.pgrb2.$(dset. resolution) .$(dset. forecast) "
100144end
101145
146+ """
147+ local_path(dset::GFSDataset) -> String
148+
149+ Get local cache path for the GFS dataset.
150+ """
102151function local_path (dset:: GFSDataset )
103152 joinpath (dir, " gfs_$(Dates. format (dset. date, " yyyymmdd" )) _$(dset. cycle) _$(dset. resolution) _$(dset. product) _$(dset. forecast) .grib2" )
104153end
105154
155+ """
156+ get(dset::GFSDataset) -> String
157+
158+ Download GFS dataset to cache (if needed) and return filepath.
159+ """
106160function Base. get (dset:: GFSDataset )
107161 isfile (local_path (dset)) ? local_path (dset) : Base. download (url (dset), local_path (dset))
108162end
109163
164+ """
165+ local_datasets(GFSDataset) -> Vector{GFSDataset}
166+
167+ List all cached GFS datasets.
168+ """
110169function local_datasets (:: Type{GFSDataset} )
111170 files = filter (f -> startswith (f, " gfs_" ), readdir (dir))
112171 parse .(GFSDataset, files)
113172end
114173
174+ """
175+ clear_local_dataset!(dset::GFSDataset)
176+
177+ Remove GFS dataset from local cache.
178+ """
115179function clear_local_dataset! (dset:: GFSDataset )
116180 isfile (local_path (dset)) && rm (local_path (dset))
117181end
0 commit comments