Skip to content
Snippets Groups Projects
Commit 085be7fa authored by Svajunas Plunge's avatar Svajunas Plunge
Browse files

Merge branch 'main' of https://git.ufz.de/schuerz/swatdoctr

parents c2481184 7cc4a1a5
No related branches found
No related tags found
No related merge requests found
Package: SWATdoctR
Type: Package
Title: Finding the right diagnoses and treatments for SWAT+ models
Version: 0.1.17
Version: 0.1.18
Author: c(person("Christoph", "Schürz",
email = "christoph.schuerz@ufz.de",
role = c("aut", "cre")),
......
......@@ -349,12 +349,11 @@ prepare_stress <- function(mgt_out, years) {
stress <- bind_rows(stress_mono, stress_rota) %>%
set_names(c('crop', 'water', 'aeration',
'temperature', 'nitrogen', 'phosphorus')) %>%
'temperature', 'phosphorus', 'nitrogen')) %>%
pivot_longer(., cols = - crop, names_to = 'stress', values_to = 'var') %>%
mutate(., stress = factor(stress,
levels = c('water', 'aeration', 'temperature',
'nitrogen', 'phosphorus')))
'phosphorus', 'nitrogen')))
return(stress)
}
......
......@@ -10,11 +10,11 @@
#' @return Rewrites the input files hru-data.hru, landuse.lum, management.sch,
#' and plant.ini with shorter labels.
#'
#' @importFrom dplyr distinct left_join group_by group_split mutate select %>%
#' @importFrom dplyr bind_rows distinct left_join group_by group_split mutate select %>%
#' @importFrom purrr list_c list_rbind map map_lgl map2 map2_df
#' @importFrom readr read_lines write_lines
#' @importFrom stringr str_detect str_remove str_remove_all str_replace
#' @importFrom tibble tibble
#' @importFrom tibble tibble add_row
#'
#' @export
#'
......@@ -60,12 +60,18 @@ update_landuse_labels <- function(project_path) {
mgt_lbl <- lu_lbl %>%
mutate(schedule = str_replace(lu_mgt, 'lum', 'mgt'),
schedule_upd = str_replace(lu_mgt_upd, 'lum', 'mgt')) %>%
select(schedule, schedule_upd)
select(schedule, schedule_upd) %>%
add_row(schedule = 'null', schedule_upd = 'null')
pcm_lbl <- lu_lbl %>%
mutate(plnt_com = str_replace(lu_mgt, 'lum', 'comm'),
plnt_com_upd = str_replace(lu_mgt_upd, 'lum', 'com')) %>%
select(plnt_com, plnt_com_upd)
select(plnt_com, plnt_com_upd) %>%
add_row(plnt_com = 'null', plnt_com_upd = 'null')
# Added to account for both variants 'comm' and 'com'
pcm_lbl <- mutate(pcm_lbl, plnt_com = str_replace(plnt_com, 'comm', 'com')) %>%
bind_rows(pcm_lbl)
hru_data <- hru_data %>%
left_join(., lu_lbl, by = 'lu_mgt') %>%
......@@ -77,14 +83,16 @@ update_landuse_labels <- function(project_path) {
c('%8d', '%-16s', rep('%16s', 8)),
paste0(project_path, '/hru-data.hru'))
landuse_lum <- landuse_lum %>%
left_join(., lu_lbl, by = c('name' = 'lu_mgt')) %>%
mutate(name = lu_mgt_upd) %>%
select(-lu_mgt_upd) %>%
mutate(plnt_com = str_replace(name, 'lum', 'com'),
mgt = str_replace(name, 'lum', 'mgt'))
left_join(., pcm_lbl, by = 'plnt_com') %>%
mutate(plnt_com = plnt_com_upd) %>%
select(-plnt_com_upd) %>%
left_join(., mgt_lbl, by = c('mgt' = 'schedule')) %>%
mutate(mgt = schedule_upd) %>%
select(-schedule_upd)
write_tbl_file(landuse_lum,
landuse_lum_head,
......
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