A high level interface to GRIB encoded files.
Author JuliaGeo
9 Stars
Updated Last
1 Year Ago
Started In
August 2022


Stable Dev Build Status Coverage


GRIBDatasets.jl uses GRIB.jl to provide a higher level interface for reading GRIB files. This package implements the CommonDataModel.jl interface, which mean that the datasets can be accessed in the same way as netCDF files opened with NCDatasets.jl.

To read a GRIB file, just type:

julia> using GRIBDatasets

julia> ds = GRIBDataset("example.grib")
Dataset: example.grib
Group: /

   lon = 120
   lat = 61
   valid_time = 4

  lon   (120)
    Datatype:    Float64 (Float64)
    Dimensions:  lon
     units                = degrees_east
     long_name            = longitude
     standard_name        = longitude

  lat   (61)
    Datatype:    Float64 (Float64)
    Dimensions:  lat
     units                = degrees_north
     long_name            = latitude
     standard_name        = latitude

  valid_time   (4)
    Datatype:    Dates.DateTime (Int64)
    Dimensions:  valid_time
     units                = seconds since 1970-01-01T00:00:00
     calendar             = proleptic_gregorian
     long_name            = time
     standard_name        = time

  z   (120 × 61 × 4)
    Datatype:    Union{Missing, Float64} (Float64)
    Dimensions:  lon × lat × isobaricInhPa × number × valid_time
     units                = m**2 s**-2
     long_name            = Geopotential
     standard_name        = geopotential

  t   (120 × 61 × 4)
    Datatype:    Union{Missing, Float64} (Float64)
    Dimensions:  lon × lat × isobaricInhPa × number × valid_time
     units                = K
     long_name            = Temperature
     standard_name        = air_temperature

Global attributes
  edition              = 1
  source               = /home/tcarion/.julia/dev/GRIBDatasets/test/sample-data/era5-levels-members.grib
  centreDescription    = European Centre for Medium-Range Weather Forecasts
  centre               = ecmf
  subCentre            = 0
  Conventions          = CF-1.7

Indexing on the GRIBDataset object gives you the variable, which is an AbstractArray that can be sliced according to the required dimensions:

julia> t = ds["t"];
julia> t[1:3,1:5,1]
3×5 Matrix{Union{Missing, Float64}}:
 233.31  231.276  230.121  229.144  229.072
 233.31  231.229  230.053  229.212  228.893
 233.31  231.174  229.942  229.064  228.84

julia> ds["valid_time"][:]
4-element Vector{Dates.DateTime}:

The attributes of any variable can be accessed this way:

julia> ds["z"].attrib
Dict{String, Any} with 3 entries:
  "units"         => "m**2 s**-2"
  "long_name"     => "Geopotential"
  "standard_name" => "geopotential"

This package is similar to CfGRIB.jl, but the code has been adapted to be more Julian and to follow the CommonDataModel interface.


  • Only reading of GRIB format is currently possible with this package. But it should normally be straightforward to write a GRIBDataset to netCDF with NCDatasets.
  • GRIB format files may have a (very) large amount of different shapes. GRIBDatasets might not work for your specific edge case. If this happens, do not hesitate to open an issue.

Used By Packages

No packages found.