@@ -4,7 +4,7 @@ using Dates, Scratch, Downloads
44
55export AbstractDataset, RAPDataset, GFSDataset, HRRRDataset
66export Band, bands, index_url
7- export url, local_path, nextcycle, list, clear_cache!!
7+ export url, local_path, nextcycle, list, clear_cache!!, resolution_km, metadata
88
99# -----------------------------------------------------------------------------# __init__
1010" scratch directory for caching downloaded datasets"
@@ -253,6 +253,88 @@ function nextcycle(dset::HRRRDataset)
253253 )
254254end
255255
256+ # -----------------------------------------------------------------------------# resolution_km
257+ """
258+ resolution_km(dset::AbstractDataset) -> Float64
259+
260+ Return the approximate grid resolution in kilometers for the dataset.
261+
262+ # Examples
263+ ```julia
264+ resolution_km(RAPDataset(grid="awp130")) # 13.0
265+ resolution_km(RAPDataset(grid="awp252")) # 32.0
266+ resolution_km(GFSDataset(resolution="0p25")) # 28.0
267+ resolution_km(HRRRDataset()) # 3.0
268+ ```
269+ """
270+ function resolution_km end
271+
272+ function resolution_km (dset:: RAPDataset )
273+ dset. grid == " awp130" && return 13.0
274+ dset. grid == " awp252" && return 32.0
275+ error (" Unknown RAP grid: $(dset. grid) " )
276+ end
277+
278+ function resolution_km (dset:: GFSDataset )
279+ # GFS resolution is in degrees; 1° ≈ 111km at equator
280+ dset. resolution == " 0p25" && return 28.0
281+ dset. resolution == " 0p50" && return 56.0
282+ dset. resolution == " 1p00" && return 111.0
283+ error (" Unknown GFS resolution: $(dset. resolution) " )
284+ end
285+
286+ resolution_km (:: HRRRDataset ) = 3.0
287+
288+ # -----------------------------------------------------------------------------# metadata
289+ """
290+ metadata() -> NamedTuple
291+
292+ Return a table of dataset types with their field options and descriptions.
293+
294+ # Example
295+ ```julia
296+ meta = metadata()
297+ meta.RAPDataset # Options for RAPDataset
298+ ```
299+ """
300+ function metadata ()
301+ (
302+ RAPDataset = (
303+ description = " Rapid Refresh - Continental US weather model" ,
304+ resolution_km = (awp130 = 13.0 , awp252 = 32.0 ),
305+ fields = (
306+ date = " Forecast date (Date)" ,
307+ cycle = [" t00z" , " t06z" , " t12z" , " t18z" ],
308+ grid = [" awp130" , " awp252" ],
309+ product = [" pgrb" , " sfcbf" , " isobf" ],
310+ forecast = " f00 to f18" ,
311+ ),
312+ ),
313+ GFSDataset = (
314+ description = " Global Forecast System - Global weather model" ,
315+ resolution_km = (var"0p25" = 28.0 , var"0p50" = 56.0 , var"1p00" = 111.0 ),
316+ fields = (
317+ date = " Forecast date (Date)" ,
318+ cycle = [" 00" , " 06" , " 12" , " 18" ],
319+ resolution = [" 0p25" , " 0p50" , " 1p00" ],
320+ product = [" atmos" , " wave" ],
321+ forecast = " f000 to f384" ,
322+ ),
323+ ),
324+ HRRRDataset = (
325+ description = " High-Resolution Rapid Refresh - 3km US weather model" ,
326+ resolution_km = 3.0 ,
327+ fields = (
328+ date = " Forecast date (Date)" ,
329+ cycle = " 00 to 23" ,
330+ region = [" conus" , " alaska" ],
331+ product = [" wrfsfc" , " wrfprs" , " wrfnat" , " wrfsub" ],
332+ forecast = " f00 to f48" ,
333+ ),
334+ ),
335+ )
336+ end
337+
256338# -----------------------------------------------------------------------------# Band/Variable Subsetting
257339"""
258340 Band
0 commit comments