Skip to content

Commit

Permalink
Update commondatamodel.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
asinghvi17 authored Oct 14, 2024
1 parent 8cf4942 commit 7d9f2e0
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/sources/commondatamodel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,14 @@ function _layermetadata(ds::AbstractDataset; layers)
map(layers.attrs) do attr
md = _metadatadict(_sourcetrait(ds), attr)
if haskey(attr, "grid_mapping")
md["grid_mapping"] = Dict(CDM.attribs(ds[attr["grid_mapping"]]))
if haskey(ds, attr["grid_mapping"])
md["grid_mapping"] = Dict(CDM.attribs(ds[attr["grid_mapping"]]))
else
global_attrs = CDM.attribs(ds)
if haskey(global_attrs, attr["grid_mapping"])
md["grid_mapping"] = global_attrs["grid_mapping"]
end
end
end
md
end
Expand Down Expand Up @@ -571,4 +578,4 @@ function _def_dim_var!(ds::AbstractDataset, dim::Dimension)
end
CDM.defVar(ds, dimname, Vector(index(dim)), (dimname,); attrib=attrib)
return nothing
end
end

0 comments on commit 7d9f2e0

Please sign in to comment.