-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Description
I have a tried to read a .grib file that has variables defined on two different latitude on longitude grid. (link to file https://we.tl/t-varf2JJHwN ) This file has sea surface temperatures on a 0.25 degree X 0.25 degree grid and Mean wave period on a 0.5 degree X 0.5 degree grid.
This causes an error in the getone function. I am able to read the file if I simply remove this error using type piracy but this results in some warnings.
Example code
using GRIBDatasets, CairoMakie
import GRIBDatasets: getone, from_grib_date_time # type piracy to test
file_path = "multi_grid_data.grib";
# see issue https://github.com/JuliaGeo/GRIBDatasets.jl/issues/25
from_grib_date_time(date::Int32, time::Int32; epoch) = from_grib_date_time(Int(date), Int(time); epoch= epoch)
# error in getone function
ds = GRIBDataset(file_path);
# change error to warning for testing
function getone(index::FileIndex, key::AbstractString)
val = GRIBDatasets.getheaders(index)[key]
if length(val) !== 1
@warn("Expected 1 value for $key, found $(val)")
end
return first(val)
end
# The hack works
ds = GRIBDataset(file_path)
# plot results to illustrate
fig= let
fig = Figure(size=(1200,600))
lat2 = 90:-0.25:-90
lon2 = 0:0.25:359.75
@assert (length(lon2), length(lat2)) == size(ds["sst"])[1:2]
ax1 = Axis(fig[1, 1], title = "SST high resolution grid")
heatmap!(ax1, 0:0.25:359.75, 90:-0.25:-90, ds["sst"][:,:,1])
lon = ds["lon"][:]
lat = ds["lat"][:]
@assert (length(lon), length(lat)) == size(ds["mwp"])[1:2]
ax2 = Axis(fig[1, 2], title = "MWP low resolution grid")
heatmap!(ax2, lon, lat, ds["mwp"][:,:,1] )
fig
endProposal
Can we allow there to be multiple lat and lon dimensions so that this case would result in.
Dimensions
lon = 720
lat = 361
lon2 = 1440
lat2 = 721
valid_time = 3
Then lon2 and lat2 should be added as variables and the dimension of "sst" should be using the second grid.
sst (1440 × 721 × 3)
Datatype: Union{Missing, Float64} (Float64)
Dimensions: lon2 × lat2 × valid_time
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
