Skip to content
Snippets Groups Projects
Commit f3837882 authored by Rémi Lemaire-Patin's avatar Rémi Lemaire-Patin
Browse files

added layer height/depth and thickness in get_variable output

parent 6dcfbdfb
No related branches found
No related tags found
No related merge requests found
......@@ -181,6 +181,60 @@ get_variable <- function(x, varname, time_range, return.colnames = FALSE) {
}
}
# add real height dimension nveg/nair -------------------------------------
if (("nair" %in% list_dimname) &
!(varname %in% c("relative_height", "layer_thickness"))) {
df <-
df %>%
left_join(
get_variable(x, "relative_height"), by = join_by(nair)
) %>%
left_join(
get_variable(x, "layer_thickness"), by = join_by(nair)
) %>%
left_join(
get_variable(x, "veget_height_top"), by = join_by(time)
) %>%
mutate(zair = relative_height*veget_height_top,
zbot = zair-layer_thickness/2,
ztop = zair+layer_thickness/2)
}
if (("nveg" %in% list_dimname) &
!(varname %in% c("relative_height", "layer_thickness"))) {
df <-
df %>%
left_join(
get_variable(x, "relative_height"), by = join_by(nveg = nair)
) %>%
left_join(
get_variable(x, "layer_thickness"), by = join_by(nveg = nair)
) %>%
left_join(
get_variable(x, "veget_height_top"), by = join_by(time)
) %>%
mutate(zair = relative_height*veget_height_top,
zbot = zair-layer_thickness/2,
ztop = zair+layer_thickness/2)
}
if (("nsoil" %in% list_dimname) &
!(varname %in% c("z_soil", "dz_soil"))) {
df <-
df %>%
left_join(
get_variable(x, "z_soil"), by = join_by(nsoil)
) %>%
left_join(
get_variable(x, "dz_soil"), by = join_by(nsoil)
) %>%
mutate(zsoil = z_soil,
layer_thickness = dz_soil,
zbot = zsoil - layer_thickness/2,
ztop = zsoil + layer_thickness/2) %>%
select(-z_soil, - dz_soil)
}
df
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment