Skip to content

Commit

Permalink
better error
Browse files Browse the repository at this point in the history
  • Loading branch information
tcarion committed Nov 17, 2023
1 parent 7d2db26 commit 3544a76
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/variables.jl
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,13 @@ function Variable(ds::GRIBDataset, key)
layer_index = filter_messages(ds.index, cfVarName = key)

levels = [mind["typeOfLevel"] for mind in layer_index.messages]

if length(unique(levels)) !== 1
unique_levels = unique(levels)
if length(unique_levels) !== 1
examples = ["GRIBDataset(\"$(path(ds))\", filter_by_values=Dict(\"typeOfLevel\" => \"$(level)\"))\n" for level in unique_levels]
error("""
The variable `$key` is defined on multiple types of vertical levels. This is not supported by GRIBDatasets.
To overcome this issue, you can try to filter the GRIB file on some specific level. Example:
ds = GRIBDataset("$(path(ds))", filter_by_values=Dict("typeOfLevel" => "$(levels[1])"))
To overcome this issue, you can try to filter the GRIB file on some specific level. In your case, try to re-open the dataset with one of:
$(join(examples))
""")
end

Expand Down

0 comments on commit 3544a76

Please sign in to comment.