@@ -212,7 +212,9 @@ function remakeSPAC(parametrizedSPAC::SPAC;
212
212
# dump(kwargs) # kwargs contains NamedTuples to be modified
213
213
modifiedSPAC = deepcopy (parametrizedSPAC)
214
214
for curr_change in keys (kwargs)
215
- @assert values (kwargs)[curr_change] isa NamedTuple """
215
+ @assert values (kwargs)[curr_change] isa NamedTuple ||
216
+ # expect a NamedTuple of values to ovewrite, or in the case of IC_scalar a DataFrame
217
+ (curr_change == :IC_scalar && values (kwargs)[curr_change] isa DataFrame) """
216
218
Argument $curr_change is not a NamedTuple. Append single values with comma, e.g. (beta=12,)
217
219
"""
218
220
if (curr_change == :soil_toplayer )
@@ -223,6 +225,10 @@ function remakeSPAC(parametrizedSPAC::SPAC;
223
225
modifiedSPAC = remake_params ( modifiedSPAC, values (kwargs)[curr_change])
224
226
elseif (curr_change == :root_distribution )
225
227
modifiedSPAC = remake_root_distribution (modifiedSPAC, values (kwargs)[curr_change])
228
+ elseif (curr_change == :IC_soil )
229
+ modifiedSPAC = remake_IC_soil (modifiedSPAC, values (kwargs)[curr_change])
230
+ elseif (curr_change == :IC_scalar )
231
+ modifiedSPAC = remake_IC_scalar (modifiedSPAC, values (kwargs)[curr_change])
226
232
else
227
233
error (" Unknown argument provided to remake(): $curr_change " )
228
234
end
@@ -263,7 +269,7 @@ function remake_root_distribution(spac, changesNT)
263
269
for (key, val) in zip (keys (changesNT), changesNT)
264
270
@assert key ∈ allowed_names " Unclear how to remake '$key ' provided to params."
265
271
end
266
- # create new params reusing the old no and only overwriting whats defined by changesNT
272
+ # create new root_distribution reusing the old no and only overwriting whats defined by changesNT
267
273
new_root_distribution = (;spac. pars. root_distribution... , changesNT... ) # https://stackoverflow.com/a/60883705
268
274
spac. pars = (;spac. pars... , root_distribution = new_root_distribution)
269
275
return spac
@@ -278,6 +284,27 @@ function remake_params(spac, changesNT)
278
284
spac. pars = (;spac. pars... , params = new_params)
279
285
return spac
280
286
end
287
+ function remake_IC_soil (spac, changesNT)
288
+ allowed_names = keys (spac. pars. IC_soil)
289
+ for (key, val) in zip (keys (changesNT), changesNT)
290
+ @assert key ∈ allowed_names " Unclear how to remake '$key ' provided to params."
291
+ end
292
+ # create new IC_soil reusing the old no and only overwriting whats defined by changesNT
293
+ new_IC_soil = (;spac. pars. IC_soil... , changesNT... ) # https://stackoverflow.com/a/60883705
294
+ spac. pars = (;spac. pars... , IC_soil = new_IC_soil)
295
+ return spac
296
+ end
297
+ function remake_IC_scalar (spac, newICsoil_DF)
298
+ @assert all (
299
+ names (newICsoil_DF) .==
300
+ [" u_GWAT_init_mm" , " u_INTS_init_mm" , " u_INTR_init_mm" , " u_SNOW_init_mm" , " u_CC_init_MJ_per_m2" , " u_SNOWLQ_init_mm" ]) """
301
+ Unexpected column names in remake_IC_scalar().
302
+ """
303
+ # overwrite the entire DataFrame
304
+ # create new pars with an overwritten IC_scalar
305
+ spac. pars = (;spac. pars... , IC_scalar = newICsoil_DF)
306
+ return spac
307
+ end
281
308
282
309
"""
283
310
function setup(parametrizedSPAC::SPAC;
0 commit comments