Internals

GRIBDatasets.COMPUTED_KEYSConstant

Dictionary which maps a key to a conversion method. The first function is the 'to' conversion, the second is 'from'.

Currently converts:

    "time" => (from_grib_date_time, to_grib_date_time)

    "valid_time" => (
        message -> from_grib_date_time(message, date_key="validityDate", time_key="validityTime"),
        message -> to_grib_date_time(message, date_key="validityDate", time_key="validityTime"),
    )

    "verifying_time" => (from_grib_month, m -> throw(ErrorException("Unimplemented")))

    "indexing_time" => (
        message -> from_grib_date_time(message, date_key="indexingDate", time_key="indexingTime"),
        message -> to_grib_date_time(message, date_key="indexingDate", time_key="indexingTime"),
    )

Example

A GRIB message containing 20160501 as the date key and 0 as the time key would end up calling:

julia> GDS.COMPUTED_KEYS["time"][1](20160501, 0)
1462060800
source
GRIBDatasets.ArtificialDimensionType
ArtificialDimension <: AbstractDim

This type needs to be used when it is needed to create an artificial dimension. Typically this happens when some variables are defined on a similar type of level, but not on the same level values. For example, u10 and t2 are both defined on heightAboveGround, but the first is only defined at 10m and the second at 2m. In that case a height and a height_2 level will be created.

source
GRIBDatasets.DiskValuesType
DiskValues{T, N, M} <: DA.AbstractDiskArray{T, N}

Object that maps the dimensions lookup to GRIB messages offsets. message_dims are the dimensions that are found in the GRIB message (namely longitudes and latitudes). other_dims are the dimensions that have been infered from reading the GRIB file index.

Example

julia> dv.other_dims
Dimensions:
         number = 10
         valid_time = 4
         level = 2

julia> size(dv.offsets)
(10, 4, 2)
julia> dv.message_dims
Dimensions:
         longitude = 120
         latitude = 61
source
GRIBDatasets.DiskValuesMethod
DiskValues(layer_index::FileIndex{T}, dims::Dimensions) where T

Create a DiskValues object from matching the GRIB messages headers in layer_index to the dimensions values in dims.

source
GRIBDatasets.FileIndexType

Store for the messages of a GRIB file. Keeps track of the offset of the GRIB messages so they can be easily seeked. The unique_headers property gives all the different values for the keys in the GRIB file.

source
GRIBDatasets.FileIndexMethod
FileIndex(grib_path::String; index_keys = ALL_KEYS, filter_by_values = Dict())

Construct a FileIndex for the file grib_path, storing only the keys in index_keys. It is possible to read only specific values by specifying them in filter_by_values. The values of the headers can be accessed with getindex.

source
GRIBDatasets.GRIBDatasetType
GRIBDataset{T, N}

Mapping of a GRIB file to a structure that follows the CF conventions.

It can be created with the path to the GRIB file:

ds = GRIBDataset(example_file);
source
GRIBDatasets.IndexedDimensionType
IndexedDimension <: AbstractDim

Dimension created from reading the index values with the keys in the COORDINATE_VARIABLES_KEYS constant.

source
GRIBDatasets.MessageDimensionType
MessageDimension <: AbstractDim

One dimension found in the data part of the GRIB message. Typically, this is lon and lat dimensions.

source
GRIBDatasets.MessageIndexType
MessageIndex

Stored information about a GRIB message. The keys can be accessed with getindex. The message offset and length are stored as property of the struct.

source
GRIBDatasets.MessageIndexMethod
MessageIndex(message::GRIB.Message; index_keys = ALL_KEYS)

Read a GRIB message and store the requested index_keys in memory as a MessageIndex.

f = GribFile(example_file) 
message = first(f)
mind = GDS.MessageIndex(message)
destroy(f)
mind["name"]

# output
"Geopotential"
source
GRIBDatasets.OtherGridType
OtherGrid <: Horizontal

Represent non-regular grid types, where the typical messages data is a 1-D vector.

source
GRIBDatasets.RegularGridType
RegularGrid <: Horizontal

Represent regular grid types (typically regularll and regulargg). The typical messages data is a 2-D matrix.

source
GRIBDatasets.VariableType
Variable <: AbstractArray

Variable of a dataset ds. It can be a layer or a dimension. In case of a layer, the values are lazily loaded when it's sliced.

source
Base.lengthMethod
length(index::FileIndex)

The number of messages in the index.

source
GRIBDatasets.build_valid_timeMethod
julia> GDS.build_valid_time([10, 10], [10, 10])
(("time", "step"), [36010 36010; 36010 36010])
julia> GDS.build_valid_time([10], [10])
((), 36010)
source
GRIBDatasets.filter_messagesMethod
filter_messages(index::FileIndex{T}, args...; kwargs...)

Filter the messages in the index and return a new updated index. The filtering keys must be expressed as keyword arguments pair.

index = FileIndex(example_file)

filtered = GRIBDatasets.filter_messages(index, shortName = "z", number = 1)
length(filtered)

# output
8
source
GRIBDatasets.from_grib_stepFunction
from_grib_step(message::GRIB.Message, step_key::String="endStep", step_unit_key::String="stepUnits")

Returns the step_key value in hours.

source
GRIBDatasets.get_values_from_filteredMethod
get_values_from_filtered(index, key, tocheck)

For each index values in key, give the values in tocheck related with it.

index = FileIndex(example_file)

GDS.get_values_from_filtered(index, "cfVarName", "level")

# output
Dict{SubString{String}, Vector{Any}} with 2 entries:
  "t" => [500, 850]
  "z" => [500, 850]
source
GRIBDatasets.getoneMethod
getone(index::FileIndex, key::AbstractString)

Check if only one value exists in the index at the specified ´key´ and return the value.

source
GRIBDatasets.messages_indicesMethod
message_indices(index::FileIndex, mind::MessageIndex, dims::Dimensions)

Find at which indices in dims correspond each GRIB message in index.

source
GRIBDatasets.read_messageMethod
read_message(message::GRIB.Message, key::String)

Read a specific key from a GRIB.jl message. Attempts to convert the raw value associated with that key using the COMPUTED_KEYS mapping to from_grib_* functions.

source