Skip to content

Commit affeb1c

Browse files
authored
fig bug reintroduced due to poor rebase with texture norm (#1217)
1 parent 7ac4cd4 commit affeb1c

File tree

3 files changed

+19
-11
lines changed

3 files changed

+19
-11
lines changed

NEWS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ ClimaLand.jl Release Notes
33

44
main
55
-------
6+
- Fix texure norm bug (soil composition) PR[#1217](https://github.com/CliMA/ClimaLand.jl/pull/1217)
67
- ![breaking change][badge-💥breaking] Remove ModelSetup.jl and split spatial parameter functions up PR[#1211](https://github.com/CliMA/ClimaLand.jl/pull/1211)
78
- ![breaking change][badge-💥breaking] Rename all `comms_ctx` to `context` PR[#1207](https://github.com/CliMA/ClimaLand.jl/pull/1207)
89
- Output NaNs in diagnostics where the ocean is PR[#1200](https://github.com/CliMA/ClimaLand.jl/pull/1200)

experiments/benchmarks/snowy_land.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ if profiler == "flamegraph"
449449
@info "Saved allocation flame to $alloc_flame_file"
450450
end
451451
if get(ENV, "BUILDKITE_PIPELINE_SLUG", nothing) == "climaland-benchmark"
452-
PREVIOUS_BEST_TIME = 0.74
452+
PREVIOUS_BEST_TIME = 0.67
453453
if average_timing_s > PREVIOUS_BEST_TIME + std_timing_s
454454
@info "Possible performance regression, previous average time was $(PREVIOUS_BEST_TIME)"
455455
elseif average_timing_s < PREVIOUS_BEST_TIME - std_timing_s

src/standalone/Soil/spatially_varying_parameters.jl

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -163,11 +163,17 @@ function soil_vangenuchten_parameters(
163163
file_reader_kwargs = (; preprocess_func = (data) -> data > 0,),
164164
)
165165
# If the parameter mask = 0, set to physical value
166+
# (equal to the mean where we have data; the mean of α is in log space)
166167
# This function in applied in **simulation mask** aware
167168
# manner.
168-
μ = FT(0.27)
169+
# That is, we replace values in the simulation, but without data, with the mean
170+
# over the data.
171+
masked_to_value(field, mask, value) =
172+
mask == 1.0 ? field : eltype(field)(value)
173+
174+
μ = FT(0.33)
169175
vg_α .= masked_to_value.(vg_α, soil_params_mask, 10.0^μ)
170-
μ = FT(1.65)
176+
μ = FT(1.74)
171177
vg_n .= masked_to_value.(vg_n, soil_params_mask, μ)
172178

173179
vg_fields_to_hcm_field::FT, n::FT) where {FT} =
@@ -206,13 +212,13 @@ function soil_vangenuchten_parameters(
206212
regridder_kwargs = (; extrapolation_bc,),
207213
)
208214

209-
μ = FT(-6)
215+
# Set missing values to the mean. For Ksat, we use the mean in log space.
216+
μ = FT(-5.08)
210217
K_sat .= masked_to_value.(K_sat, soil_params_mask, 10.0^μ)
211218

212-
μ = FT(0.5)
213-
ν .= masked_to_value.(ν, soil_params_mask, μ)
219+
ν .= masked_to_value.(ν, soil_params_mask, 0.47)
214220

215-
θ_r .= masked_to_value.(θ_r, soil_params_mask, 0)
221+
θ_r .= masked_to_value.(θ_r, soil_params_mask, 0.09)
216222

217223
return (; ν = ν, hydrology_cm = hydrology_cm, K_sat = K_sat, θ_r = θ_r)
218224
end
@@ -291,10 +297,11 @@ function soil_composition_parameters(
291297
# we require that the sum of these be less than 1 and equal to or bigger than zero.
292298
# The input should satisfy this almost exactly, but the regridded values may not.
293299
# Values of zero are OK here, so we dont need to apply any masking
294-
texture_norm = @. min(ν_ss_gravel + ν_ss_quartz + ν_ss_om, 1)
295-
@. ν_ss_gravel = ν_ss_gravel / max(texture_norm, eps(FT))
296-
@. ν_ss_om = ν_ss_om / max(texture_norm, eps(FT))
297-
@. ν_ss_quartz = ν_ss_quartz / max(texture_norm, eps(FT))
300+
# if sum > 1, normalize by sum, else "normalize" by 1 (i.e., do not normalize)
301+
texture_norm = @. max(ν_ss_gravel + ν_ss_quartz + ν_ss_om, 1)
302+
@. ν_ss_gravel = ν_ss_gravel / texture_norm
303+
@. ν_ss_om = ν_ss_om / texture_norm
304+
@. ν_ss_quartz = ν_ss_quartz / texture_norm
298305

299306
return (;
300307
ν_ss_om = ν_ss_om,

0 commit comments

Comments
 (0)