@@ -123,6 +123,10 @@ fct_combine_sims_C_allstock <- function(.ad, .cs, .usr){
123123
124124 c_check <- fct_check_pool(.c_sub = c_sub , .c_unit = .usr $ c_unit , .c_fraction = .usr $ c_fraction )
125125 c_form <- fct_make_formula(.c_check = c_check , .c_unit = .usr $ c_unit )
126+ c_pools <- stringr :: str_remove_all(c_form , pattern = " \\ +|\\ *|\\ (|\\ )" ) | >
127+ stringr :: str_split(pattern = " " ) | >
128+ unlist() | >
129+ unique()
126130
127131 tibble(
128132 period = period ,
@@ -159,24 +163,30 @@ fct_combine_sims_C_allstock <- function(.ad, .cs, .usr){
159163
160164 if (" DG_ratio" %in% unique(sims_C_all $ c_form )) {
161165
162- # # + Get pools used for DG
166+ # # + Get elements used for DG
163167 if (.usr $ dg_pool == " ALL" ) {
164168 dg_pool <- " C_all"
165169 } else {
166170 dg_pool <- stringr :: str_split(.usr $ dg_pool , pattern = " ," ) | > purrr :: map(stringr :: str_trim ) | > unlist()
167171 }
168- dg_pool_intact <- paste0(dg_pool , " _intact" )
172+ # dg_pool_intact <- paste0(dg_pool, "_intact")
169173
170- # # + Filter DG to modify formula and recalculate
174+ # # + Filter DG_ratio elements
171175 sims_DG <- sims_C_all | >
172176 dplyr :: filter(.data $ c_form == " DG_ratio" ) | >
173177 dplyr :: mutate(
174178 lu_intact = stringr :: str_remove(.data $ lu_id , pattern = .usr $ dg_ext )
175179 )
176180
181+ # # + Filter intact elements associated with DG land uses
177182 sims_C_intact <- sims_C_all | >
178- dplyr :: filter(.data $ lu_id %in% unique(sims_DG $ lu_intact )) | >
179- dplyr :: select(" sim_no" , lu_intact = " lu_id" , !!! rlang :: syms(dg_pool ))
183+ dplyr :: filter(.data $ lu_id %in% unique(sims_DG $ lu_intact ))
184+
185+ intact_pools <- stringr :: str_subset( | >
186+ dplyr :: select(" c_form" ) | >
187+ purrr :: discard(~ all(is.na(. )))
188+ # dplyr::select("sim_no", lu_intact = "lu_id", !!!rlang::syms(dg_pool))
189+
180190
181191 names(sims_C_intact )[! (names(sims_C_intact ) %in% c(" sim_no" , " lu_intact" ))] <- dg_pool_intact
182192
0 commit comments