Closed helge22a closed 1 year ago
This is probably a separate PR, but if for some reason you feel like doing some refactoring, a more robust alternative to the way model2netcdf works might be to use named lists. Right now it relies a lot on indexing by position which is easy to screw up by accident when adding or removing variables.
For example, instead of this ...
out <- list()
out[[1]] <- sipnet.output$npp * conversion_factor # NPP
out[[2]] <- sipnet.output$snow * 10 # SWE
...
nc_var[[1]] <- PEcAn.utils::to_ncvar("NPP", dims)
nc_var[[2]] <- PEcAn.utils::to_ncvar("SWE", dims)
...
... do this ...
out <- list(
"NPP" = sipnet.output$npp * conversion_factor,
"SWE" = sipnet.output$snow * 10,
...
)
nc_var <- list(
"SWE" = PEcAn.utils::to_ncvar("SWE", dims),
"NPP" = PEcAn.utils::to_ncvar("NPP", dims),
...
)
#order doesn't matter anymore, because you can sort them by name if you need the two lists to be in the same order
nc_var[names(out)]
Description
Track water states in params$restart so that new model runs do not use default param values.
Motivation and Context
Using default param values for water states adds cyclic behavior in the model output that is not present in the data. This should help work being done by @mdietze @serbinsh @DongchenZ @Qianyuxuan
Review Time Estimate
Types of changes
Checklist: