Skip to content

Commit

Permalink
Make is_z_1D more general
Browse files Browse the repository at this point in the history
  • Loading branch information
Sbozzolo committed Aug 29, 2024
1 parent 1329ebb commit cc66167
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/Var.jl
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,14 @@ function units(var::OutputVar)
string(get(var.attributes, "units", ""))
end

"""
has_units(var::OutputVar)
Return whether the given `var` has `units` or not.
"""
function has_units(var::OutputVar)
return haskey(var.attributes, "units")
end

# Implemented in ClimaAnalysisUnitfulExt
function _maybe_convert_to_unitful end
Expand All @@ -226,10 +234,9 @@ In this case, `dims["z"]` is essentially a map that identifies the physical alti
given point.
"""
function is_z_1D(var::OutputVar)
haskey(var.dims, "z") ||
error("Variable does not have an altitude dimension")
has_altitude(var) || error("Variable does not have an altitude dimension")

return length(size(var.dims["z"])) == 1
return length(size(altitudes(var))) == 1
end

function Base.copy(var::OutputVar)
Expand Down

0 comments on commit cc66167

Please sign in to comment.