Skip to content

Commit

Permalink
change NaN replacement
Browse files Browse the repository at this point in the history
  • Loading branch information
juliasloan25 committed Jun 25, 2024
1 parent 4faf23b commit caf579d
Showing 1 changed file with 15 additions and 19 deletions.
34 changes: 15 additions & 19 deletions src/FluxCalculator.jl
Original file line number Diff line number Diff line change
Expand Up @@ -359,25 +359,21 @@ function get_surface_fluxes!(inputs, surface_params::SF.Parameters.SurfaceFluxes
# moisture
F_turb_moisture = SF.evaporation(surface_params, inputs, outputs.Ch)

if !isnan(F_turb_ρτxz) && !isnan(F_turb_ρτyz) && !isnan(F_shf) && !isnan(F_lhf) && !isnan(F_turb_moisture)
return (;
F_turb_ρτxz = F_turb_ρτxz,
F_turb_ρτyz = F_turb_ρτyz,
F_shf = F_shf,
F_lhf = F_lhf,
F_turb_moisture = F_turb_moisture,
)
else
return (;
F_turb_ρτxz = zero(F_turb_ρτxz),
F_turb_ρτyz = zero(F_turb_ρτyz),
F_shf = zero(F_shf),
F_lhf = zero(F_lhf),
F_turb_moisture = zero(F_turb_moisture),
)
end


# At locations where this surface model is not evaluated, we get `NaN` for
# surface fluxes. In that case, we replace the values with 0.
@. F_turb_ρτxz = ifelse(isnan(F_turb_ρτxz), zero(F_turb_ρτxz), F_turb_ρτxz)
@. F_turb_ρτyz = ifelse(isnan(F_turb_ρτyz), zero(F_turb_ρτyz), F_turb_ρτyz)
@. F_shf = ifelse(isnan(F_shf), zero(F_shf), F_shf)
@. F_lhf = ifelse(isnan(F_lhf), zero(F_lhf), F_lhf)
@. F_turb_moisture = ifelse(isnan(F_turb_moisture), zero(F_turb_moisture), F_turb_moisture)

return (;
F_turb_ρτxz = F_turb_ρτxz,
F_turb_ρτyz = F_turb_ρτyz,
F_shf = F_shf,
F_lhf = F_lhf,
F_turb_moisture = F_turb_moisture,
)
end

"""
Expand Down

0 comments on commit caf579d

Please sign in to comment.