Skip to content

handle climatology bounds #37

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/cfvariable.jl
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ end
function boundsParentVar(ds,varname)
for vn in varnames(ds)
v = variable(ds,vn)
bounds = get(attribs(v),"bounds","")
bounds = _get_bounds_varname(attribs(v))
if bounds === varname
return vn
end
Expand Down
12 changes: 9 additions & 3 deletions src/dataset.jl
Original file line number Diff line number Diff line change
Expand Up @@ -281,15 +281,21 @@ function initboundsmap!(ds)
empty!(ds._boundsmap)
for vname in keys(ds)
v = variable(ds,vname)
bounds = get(v.attrib,"bounds",nothing)

bounds = _get_bounds_varname(attribs(v))
# see https://github.com/Alexander-Barth/NCDatasets.jl/issues/265
if bounds isa String
if !isempty(bounds)
ds._boundsmap[bounds] = vname
end
end
end

function _get_bounds_varname(attribs)
# First try to get "bounds" variable
get(attribs, "bounds") do
# Then try "climatology_bounds", and fall back to an empty string
get(attribs, "climatology", "")
end
end

"""
write(dest::AbstractDataset, src::AbstractDataset; include = keys(src), exclude = [])
Expand Down
Loading