Skip to content

Commit ea9e89d

Browse files
committed
Add resolution_km and metadata functions
1 parent cffc28c commit ea9e89d

2 files changed

Lines changed: 128 additions & 5 deletions

File tree

README.md

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,49 @@ path = get(dset, wind_bands)
3939

4040
## Dataset Types
4141

42-
- `HRRRDataset(; date, cycle, region, product, forecast)`
43-
- `RAPDataset(; date, cycle_time, grid, product, forecast)`
44-
- `GFSDataset(; date, cycle, resolution, product, forecast)`
42+
### HRRRDataset (High-Resolution Rapid Refresh)
4543

46-
See docstrings for field options.
44+
3km resolution US weather model with hourly updates.
45+
46+
| Field | Options | Description |
47+
|-------|---------|-------------|
48+
| `date` | `Date` | Forecast initialization date |
49+
| `cycle` | `"00"` to `"23"` | Model run hour (hourly) |
50+
| `region` | `"conus"`, `"alaska"` | Geographic region |
51+
| `product` | `"wrfsfc"`, `"wrfprs"`, `"wrfnat"`, `"wrfsub"` | Surface, pressure, native, or subhourly |
52+
| `forecast` | `"f00"` to `"f48"` | Forecast hour |
53+
54+
### RAPDataset (Rapid Refresh)
55+
56+
Continental US weather model with 6-hour update cycles.
57+
58+
| Field | Options | Resolution |
59+
|-------|---------|------------|
60+
| `grid` | `"awp130"` | ~13 km |
61+
| `grid` | `"awp252"` | ~32 km |
62+
63+
| Field | Options | Description |
64+
|-------|---------|-------------|
65+
| `date` | `Date` | Forecast initialization date |
66+
| `cycle` | `"t00z"`, `"t06z"`, `"t12z"`, `"t18z"` | Model run time (6-hourly) |
67+
| `grid` | `"awp130"`, `"awp252"` | Grid resolution |
68+
| `product` | `"pgrb"`, `"sfcbf"`, `"isobf"` | Pressure, surface, or isentropic |
69+
| `forecast` | `"f00"` to `"f18"` | Forecast hour |
70+
71+
### GFSDataset (Global Forecast System)
72+
73+
Global weather model with 6-hour update cycles.
74+
75+
| Field | Options | Resolution |
76+
|-------|---------|------------|
77+
| `resolution` | `"0p25"` | ~28 km |
78+
| `resolution` | `"0p50"` | ~56 km |
79+
| `resolution` | `"1p00"` | ~111 km |
80+
81+
| Field | Options | Description |
82+
|-------|---------|-------------|
83+
| `date` | `Date` | Forecast initialization date |
84+
| `cycle` | `"00"`, `"06"`, `"12"`, `"18"` | Model run time (6-hourly) |
85+
| `resolution` | `"0p25"`, `"0p50"`, `"1p00"` | Grid resolution in degrees |
86+
| `product` | `"atmos"`, `"wave"` | Atmospheric or wave |
87+
| `forecast` | `"f000"` to `"f384"` | Forecast hour |

src/RapidRefreshData.jl

Lines changed: 83 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ using Dates, Scratch, Downloads
44

55
export AbstractDataset, RAPDataset, GFSDataset, HRRRDataset
66
export 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
)
254254
end
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

Comments
 (0)