Internals
GRIBDatasets.COMPUTED_KEYS
GRIBDatasets.GRIB_STEP_UNITS_TO_SECONDS
GRIBDatasets.ArtificialDimension
GRIBDatasets.DiskValues
GRIBDatasets.DiskValues
GRIBDatasets.FileIndex
GRIBDatasets.FileIndex
GRIBDatasets.GRIBDataset
GRIBDatasets.IndexedDimension
GRIBDatasets.MessageDimension
GRIBDatasets.MessageIndex
GRIBDatasets.MessageIndex
GRIBDatasets.NonRegularGrid
GRIBDatasets.OtherGrid
GRIBDatasets.RegularGrid
GRIBDatasets.Variable
Base.length
GRIBDatasets._add_headers!
GRIBDatasets.additional_coordinates_varnames
GRIBDatasets.build_valid_time
GRIBDatasets.build_valid_time
GRIBDatasets.build_valid_time
GRIBDatasets.build_valid_time
GRIBDatasets.build_valid_time
GRIBDatasets.filter_messages
GRIBDatasets.from_grib_date_time
GRIBDatasets.from_grib_month
GRIBDatasets.from_grib_step
GRIBDatasets.get_values_from_filtered
GRIBDatasets.getone
GRIBDatasets.messages_indices
GRIBDatasets.read_message
GRIBDatasets.COMPUTED_KEYS
— ConstantDictionary 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
GRIBDatasets.GRIB_STEP_UNITS_TO_SECONDS
— Constantconst GRIB_STEP_UNITS_TO_SECONDS
Array used to convert the grib step units to seconds. Taken from eccodes stepUnits.table
.
GRIBDatasets.ArtificialDimension
— TypeArtificialDimension <: 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.
GRIBDatasets.DiskValues
— TypeDiskValues{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
GRIBDatasets.DiskValues
— MethodDiskValues(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
.
GRIBDatasets.FileIndex
— TypeStore 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.
GRIBDatasets.FileIndex
— MethodFileIndex(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
.
GRIBDatasets.GRIBDataset
— TypeGRIBDataset{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);
GRIBDatasets.IndexedDimension
— TypeIndexedDimension <: AbstractDim
Dimension created from reading the index values with the keys in the COORDINATE_VARIABLES_KEYS
constant.
GRIBDatasets.MessageDimension
— TypeMessageDimension <: AbstractDim
One dimension found in the data part of the GRIB message. Typically, this is lon
and lat
dimensions.
GRIBDatasets.MessageIndex
— TypeMessageIndex
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.
GRIBDatasets.MessageIndex
— MethodMessageIndex(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"
GRIBDatasets.NonRegularGrid
— TypeNonRegularGrid <: Horizontal
Represent non-regular grid types. The typical messages data is a 2-D matrix.
GRIBDatasets.OtherGrid
— TypeOtherGrid <: Horizontal
Represent non-regular grid types, where the typical messages data is a 1-D vector.
GRIBDatasets.RegularGrid
— TypeRegularGrid <: Horizontal
Represent regular grid types (typically regularll and regulargg). The typical messages data is a 2-D matrix.
GRIBDatasets.Variable
— TypeVariable <: 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.
Base.length
— Methodlength(index::FileIndex)
The number of messages in the index.
GRIBDatasets._add_headers!
— MethodPush the values of the message
headers if they don't exist in the dictionnary d
GRIBDatasets.additional_coordinates_varnames
— Methodadditional_coordinates_varnames(dims::Dimensions)
In case of irregular grids, eccodes might provide the longitude and latitude. If so, this will then be stored as additionnal variables.
GRIBDatasets.build_valid_time
— FunctionReturns a pair of (dims, data)
based on the type of input
GRIBDatasets.build_valid_time
— Methodjulia> GDS.build_valid_time(10, 10)
((), 36010)
GRIBDatasets.build_valid_time
— Methodjulia> GDS.build_valid_time(1, [10])
(("step",), [36001])
GRIBDatasets.build_valid_time
— Methodjulia> GDS.build_valid_time([10], 10)
(("time",), [36010])
GRIBDatasets.build_valid_time
— Methodjulia> GDS.build_valid_time([10, 10], [10, 10])
(("time", "step"), [36010 36010; 36010 36010])
julia> GDS.build_valid_time([10], [10])
((), 36010)
GRIBDatasets.filter_messages
— Methodfilter_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
GRIBDatasets.from_grib_date_time
— Methodfrom_grib_date_time(date::Integer, time::Integer; epoch::DateTime=DEFAULT_EPOCH)
Seconds from epoch to the given date and time.
GRIBDatasets.from_grib_month
— Functionfrom_grib_month
Returns the integer seconds from the epoch to the verifying month value in the GRIB message.
GRIBDatasets.from_grib_step
— Functionfrom_grib_step(message::GRIB.Message, step_key::String="endStep", step_unit_key::String="stepUnits")
Returns the step_key
value in hours.
GRIBDatasets.get_values_from_filtered
— Methodget_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]
GRIBDatasets.getone
— Methodgetone(index::FileIndex, key::AbstractString)
Check if only one value exists in the index
at the specified ´key´ and return the value.
GRIBDatasets.messages_indices
— Methodmessage_indices(index::FileIndex, mind::MessageIndex, dims::Dimensions)
Find at which indices in dims
correspond each GRIB message in index
.
GRIBDatasets.read_message
— Methodread_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.