Skip to content

Commit 7464bc4

Browse files
committed
Fix: FillValue issue
1 parent 5324949 commit 7464bc4

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "OceanTransportMatrixBuilder"
22
uuid = "c2b4a04e-6049-4fc4-aa6a-5508a29a1e1c"
33
authors = ["Benoit Pasquier <[email protected]> and contributors"]
4-
version = "0.7.0"
4+
version = "0.7.1"
55

66
[deps]
77
Distances = "b4f34e82-e78d-54a5-968a-f98e89d6e8f7"

src/gridcellgeometry.jl

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,15 +275,22 @@ end
275275

276276
function makegridmetrics(; areacello, volcello, lon, lat, lev, lon_vertices, lat_vertices)
277277

278+
# Differences in output "missing" data is commonplace,
279+
# so we remove these here and use NaNs instead.
280+
toreplace = Set{Any}((missing, nothing, 0)) # here we also replace 0 with NaN
281+
haskey(areacello.properties, "_FillValue") && push!(toreplace, areacello.properties["_FillValue"])
282+
haskey(volcello.properties, "_FillValue") && push!(toreplace, volcello.properties["_FillValue"])
283+
replacelist = (x => NaN for x in toreplace)
284+
278285
# volume (3D)
279286
FillValue = volcello.properties["_FillValue"]
280287
v3D = volcello |> Array{Union{Missing, Float64}}
281-
v3D = replace(v3D, missing => NaN, 0 => NaN, FillValue => NaN)
288+
v3D = replace(v3D, replacelist...)
282289

283290
# area (2D)
284291
FillValue = areacello.properties["_FillValue"]
285292
area2D = areacello |> Array{Union{Missing, Float64}}
286-
area2D = replace(area2D, missing => NaN, 0 => NaN, FillValue => NaN)
293+
area2D = replace(area2D, replacelist...)
287294

288295
# depth and cell height (3D)
289296
thkcello = v3D ./ area2D

0 commit comments

Comments
 (0)