The goal of grib is to read GRIB and GRIB2 files. Right now it does pretty much nothing and is proof-of-concept only.
You can install the development version from GitHub with:
# install.packages("remotes")
remotes::install_github("paleolimbot/grib")
This is a basic example which shows you how to solve a common problem:
library(grib)
grib2_info("~/Desktop/CMC_hrdps_maritimes_PRATE_SFC_0_ps2.5km_2020091400_P001-00.grib2")
#> [[1]]
#> [[1]]$listsec0
#> [1] 0 2 22451
#>
#> [[1]]$listsec1
#> [1] 54 0 4 0 1 2020 9 14 0 0 0 0 2
#>
#> [[1]]$numfields
#> [1] 1
#>
#> [[1]]$numlocal
#> [1] 0
data <- grib2_field(
"~/Desktop/CMC_hrdps_maritimes_PRATE_SFC_0_ps2.5km_2020091400_P001-00.grib2",
expand = TRUE
)
summary(data$fld)
#> Min. 1st Qu. Median Mean 3rd Qu. Max.
#> 0.000e+00 0.000e+00 0.000e+00 3.755e-05 0.000e+00 6.131e-03