From 74f9b35e10b2f25e58b44b76e49cd24aa8073528 Mon Sep 17 00:00:00 2001 From: Rafael Schouten Date: Mon, 7 Jul 2025 11:26:11 +1000 Subject: [PATCH] handle climatology bounds --- src/cfvariable.jl | 2 +- src/dataset.jl | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/cfvariable.jl b/src/cfvariable.jl index 7e30d1b..b0f0823 100644 --- a/src/cfvariable.jl +++ b/src/cfvariable.jl @@ -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 diff --git a/src/dataset.jl b/src/dataset.jl index 91b4b9c..9ba9c1b 100644 --- a/src/dataset.jl +++ b/src/dataset.jl @@ -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 = [])