Skip to content

Commit

Permalink
fix masking
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander-Barth committed Feb 2, 2024
1 parent 99eb860 commit 599ee26
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/data.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,17 @@ function load_gridded_nc(fname::AbstractString,varname::AbstractString; minfrac
#time = nomissing(ds["time"][1:100])
#data = nomissing(ds[varname][:,:,1:100],NaN)

if "mask" in ds
if haskey(ds,"mask")
mask = nomissing(ds["mask"][:,:]) .== 1;
else
@info("compute mask from $varname: each sea point should have at least " *
"$minfrac for valid data through time")

missingfraction = mean(isnan.(data),dims=3)
println("range of fraction of missing data: ",extrema(missingfraction))
mask = missingfraction .> minfrac
mask = missingfraction .<= 1 - minfrac

println("mask: sea points ",sum(.!mask)," land points ",sum(mask))
println("mask: sea points ",sum(mask)," land points ",sum(.!mask))
end

close(ds)
Expand Down

0 comments on commit 599ee26

Please sign in to comment.