weech / GRIB.jl

GRIB Interface for Julia
Apache License 2.0
22 stars 2 forks source link

error retrieving values from era-20c #12

Closed zahachtah closed 3 years ago

zahachtah commented 3 years ago

If you have an idea how I would do this I'd appreciate it:

I have downloaded a dataset of 50 daily global t2m values. I can access the file just fine.

f = GribFile(filename)

works and

each m=Message(f) retrieves a new day's data.

m["longitudes"] gives me an array of longitudes data (length=88838)

however

m["values"] gives me:

ERROR: DimensionMismatch("new dimensions (2147483647, 256) must be consistent with array size 88838") Stacktrace: [1] (::Base.var"#throw_dmrsa#213")(::Tuple{Int64,Int64}, ::Int64) at ./reshapedarray.jl:41 [2] reshape at ./reshapedarray.jl:45 [inlined] [3] reshape at ./reshapedarray.jl:116 [inlined] [4] getindex(::Message, ::String) at /Users/jonnorberg/.julia/packages/GRIB/wj6Fn/src/message.jl:219

Would you know what I am doing wrong here?

Many thanks, Jon

zahachtah commented 3 years ago

when I change (just a hack) line 219 of messages.jl to

return vals #reshape(vals, ni, nj)

I get the data with length 88838

weech commented 3 years ago

Hi, Could you share the values of the "Ni" and "Nj" keys for this message? And also the value of the "gridDefinitionDescription" if it exists? I'm guessing the data you have has a variable number of rows per column, and I need to change line 212 to read if key == "values" && handle["Ni"] != (2^31 - 1) && handle["Nj"] != (2^31 - 1).

zahachtah commented 3 years ago

julia> msg["gridDefinitionDescription"] "Gaussian Latitude/Longitude Grid"

julia> msg["Nj"] 256

julia> msg["Ni"] 2147483647

julia> msg["totalLength"] 178296

Its a reduced gausian grid, but the number of values should be the same for each message iteration (iterates days)

weech commented 3 years ago

Are you using the latest version, 0.3.0? This appears to be a duplicate of #10, and the issue should have been fixed in that release.

zahachtah commented 3 years ago

right. I had installed CfGrib.jl to test some day before and it downgrades Grib to 0.2.

sorry to take your time on this. works now