diff --git a/R/helper.R b/R/helper.R index a4849c8347c637e21236d8b3f7feb6609ba61408..b0c7e4d047dcb6d26f39dd53c5143f7cb51649a7 100644 --- a/R/helper.R +++ b/R/helper.R @@ -19,7 +19,9 @@ add_kill_op <- function(project_path){ i <- grep("hvkl", mgt_sch)[1] kill_line <- str_replace(mgt_sch[i], "hvkl", "kill") %>% str_replace(c("forest_cut|grain1|grain|grass_bag|grass_mulch|hay_cut_high|hay_cut_low|orchard|peanuts| - silage|stover_high|stover_los|stover_med|tuber|vegetables"), "null") + silage|stover_high|stover_los|stover_med|tuber|vegetables"), "null") %>% + str_replace_all("[:digit:]", "0") %>% + str_replace("0.00000", "0.00001") ## Kill operation at 0.00001 HU, same day as harvest. mgt_sch[i] <- str_replace(mgt_sch[i], "hvkl", "harv") mgt_sch <- insert_line_at(mgt_sch, kill_line, insert_after=i) l <- l+1 diff --git a/R/plot_mgt_harv.R b/R/plot_mgt_harv.R index b70941c1a50e56dceb0270955ca490873b47eea3..c5d6db7ffca527ba8656f56a6e4ad771397d4e8c 100644 --- a/R/plot_mgt_harv.R +++ b/R/plot_mgt_harv.R @@ -29,6 +29,17 @@ plot_variable_at_harvkill <- function(sim_verify, variable, years = 1900:2100) { ungroup() %>% filter(n == 2, operation == 'HARVEST') + ##Just in case dates of harvest and kill differ a bit + if(dim(tbl_harv)[1] == 0){ + tbl_harv <- sim_verify$mgt_out %>% + filter(year %in% years) %>% + filter(operation %in% c('HARVEST', 'KILL')) %>% + group_by(hru,year, mon) %>% + mutate(n = n()) %>% + ungroup() %>% + filter(n == 2, operation == 'HARVEST') + } + if(variable == 'phu') { tbl_harv <- tbl_harv %>% select(op_typ, phuplant) %>%