JuliaGeo / GRIBDatasets.jl

A high level interface to GRIB encoded files.
MIT License
12 stars 5 forks source link

error opening ECMWF grib file #17

Closed gaelforget closed 7 months ago

gaelforget commented 8 months ago

Is there a fix for this is the error I get?

ds = GRIBDataset("./output.grib")
ERROR: MethodError: no method matching length(::GRIBDatasets.MessageDimension{GRIBDatasets.Other})

Closest candidates are:
  length(::Union{Base.KeySet, Base.ValueIterator})
   @ Base abstractdict.jl:58
  length(::Union{LinearAlgebra.Adjoint{T, S}, LinearAlgebra.Transpose{T, S}} where {T, S})
   @ LinearAlgebra /Applications/Julia-1.9.app/Contents/Resources/julia/share/julia/stdlib/v1.9/LinearAlgebra/src/adjtrans.jl:295
  length(::Union{SparseArrays.FixedSparseVector{Tv, Ti}, SparseArrays.SparseVector{Tv, Ti}} where {Tv, Ti})
   @ SparseArrays /Applications/Julia-1.9.app/Contents/Resources/julia/share/julia/stdlib/v1.9/SparseArrays/src/sparsevector.jl:95
  ...

Stacktrace:
  [1] _similar_shape(itr::GRIBDatasets.MessageDimension{GRIBDatasets.Other}, #unused#::Base.HasLength)
    @ Base ./array.jl:658
  [2] _collect(cont::UnitRange{Int64}, itr::GRIBDatasets.MessageDimension{GRIBDatasets.Other}, #unused#::Base.HasEltype, isz::Base.HasLength)
    @ Base ./array.jl:713
  [3] collect(itr::GRIBDatasets.MessageDimension{GRIBDatasets.Other})
    @ Base ./array.jl:707
  [4] _totuple(::Type{Tuple}, ::GRIBDatasets.MessageDimension{GRIBDatasets.Other})
    @ Base ./tuple.jl:401
  [5] Tuple(itr::GRIBDatasets.MessageDimension{GRIBDatasets.Other})
    @ Base ./tuple.jl:369
  [6] _horizdim(index::FileIndex{Float64}, #unused#::Type{GRIBDatasets.NoCoords})
    @ GRIBDatasets ~/.julia/packages/GRIBDatasets/Ia2Sr/src/dimensions.jl:152
  [7] _alldims(index::FileIndex{Float64})
    @ GRIBDatasets ~/.julia/packages/GRIBDatasets/Ia2Sr/src/dimensions.jl:92
  [8] GRIBDataset(index::FileIndex{Float64})
    @ GRIBDatasets ~/.julia/packages/GRIBDatasets/Ia2Sr/src/dataset.jl:76
  [9] GRIBDataset(filepath::String; filter_by_values::Dict{Any, Any})
    @ GRIBDatasets ~/.julia/packages/GRIBDatasets/Ia2Sr/src/dataset.jl:79
 [10] GRIBDataset(filepath::String)
    @ GRIBDatasets ~/.julia/packages/GRIBDatasets/Ia2Sr/src/dataset.jl:79
 [11] top-level scope
    @ REPL[10]:1

on data set obtained via this request (python) :

import cdsapi

c = cdsapi.Client()

c.retrieve("reanalysis-era5-complete", {
    "class": "ea",
    "date": "1992-01-01/to/1992-01-31",
    "expver": "1",
    "levtype": "sfc",
    "param": "167.128",
    "stream": "oper",
    "time": "00:00:00/01:00:00/02:00:00/03:00:00/04:00:00/05:00:00/06:00:00/07:00:00/08:00:00/09:00:00/10:00:00/11:00:00/12:00:00/13:00:00/14:00:00/15:00:00/16:00:00/17:00:00/18:00:00/19:00:00/20:00:00/21:00:00/22:00:00/23:00:00",
    "format": "grib",
    "type": "an"
}, "output.grib")
tcarion commented 7 months ago

Thank you for reporting this issue! This should be fixed on v0.3.0