99
1010multiscale_flow = function (CF1 , asp_map , patch_map , asp_list ) {
1111
12- # nbr 121
13- # nbr patch 11955
14- # no times nbr asp ct is empty
12+ # nbr 329
13+ # nbr patch 329
14+ # nbr_asp_ct is empty
1515 # which(lapply(CF1,"[[", 9) == 15660)
1616
1717 # functions for applys
1818 apply_patches = function (CFp ) {
19+ print(asp_list )
1920 id = paste0(" rule_" , unique(asp_map [which(raw_patch_data == CFp $ PatchID )]))
20- asp_count = ncol(rulevars [[id ]]$ patch_level_vars [1 , ]) - 1 # get number of aspatial patches for current patch
21+ asp_count = ncol(asp_list [[id ]]$ patch_level_vars [1 , ]) - 1 # get number of aspatial patches for current patch
2122 asp = c(1 : asp_count )
2223 CFasp = lapply(asp , add_asp ,CFp , id )
2324 unlist(CFasp ,recursive = F )
@@ -28,7 +29,7 @@ multiscale_flow = function(CF1, asp_map, patch_map, asp_list) {
2829 CFasp $ PatchID = CFp $ PatchID * 100 + asp # aspatial patch ID is old patch ID *100 + aspatial number
2930 CFasp $ Number = CFp $ Number * 100 + asp # same modification to number
3031 CFasp $ PatchFamilyID = CFp $ PatchID # retain old patch ID as patch family ID
31- CFasp $ Area = CFp $ Area * as.numeric(rulevars [[id ]]$ patch_level_vars [rulevars [[id ]]$ patch_level_vars [, 1 ] == " pct_family_area" , asp + 1 ]) # change area
32+ CFasp $ Area = CFp $ Area * as.numeric(asp_list [[id ]]$ patch_level_vars [asp_list [[id ]]$ patch_level_vars [, 1 ] == " pct_family_area" , asp + 1 ]) # change area
3233 # this output is an actual mess but whatever
3334 nbr_out = mapply(add_nbrs , nbr = CFp $ Neighbors , gamma = CFp $ Gamma_i , slope = CFp $ Slopes , border = CFp $ Border_perimeter , SIMPLIFY = F )
3435 CFasp $ Neighbors = unlist(lapply(nbr_out , " [[" , " new_nbrs" ))
@@ -41,12 +42,12 @@ multiscale_flow = function(CF1, asp_map, patch_map, asp_list) {
4142 add_nbrs = function (nbr , gamma , slope , border ) {
4243 nbr_patch = patch_ID [numbers == nbr ] # patch ID from number
4344 nbr_id = paste0(" rule_" , unique(asp_map [which(raw_patch_data == nbr_patch )])) # get rule ID
44- nbr_asp_ct = ncol(rulevars [[nbr_id ]]$ patch_level_vars [1 , ]) - 1
45+ nbr_asp_ct = ncol(asp_list [[nbr_id ]]$ patch_level_vars [1 , ]) - 1
4546 new_slopes = rep(slope , nbr_asp_ct )
4647 new_borders = rep(border , nbr_asp_ct )
4748 new_nbrs = nbr * 100 + c(1 : nbr_asp_ct )
4849 # original gamma is multiplied by respective areas of the new patches - should sum to original
49- new_gammas = gamma * as.numeric(rulevars [[nbr_id ]]$ patch_level_vars [rulevars [[nbr_id ]]$ patch_level_vars [, 1 ] == " pct_family_area" , 1 + c(1 : nbr_asp_ct )])
50+ new_gammas = gamma * as.numeric(asp_list [[nbr_id ]]$ patch_level_vars [asp_list [[nbr_id ]]$ patch_level_vars [, 1 ] == " pct_family_area" , 1 + c(1 : nbr_asp_ct )])
5051 return (list (" new_nbrs" = new_nbrs , " new_gammas" = new_gammas , " new_slopes" = new_slopes , " new_borders" = new_borders ))
5152 }
5253
@@ -56,7 +57,7 @@ multiscale_flow = function(CF1, asp_map, patch_map, asp_list) {
5657 patch_ID = unlist(lapply(CF1 , " [[" , 9 )) # patch IDs from cf1
5758 numbers = unlist(lapply(CF1 , " [[" , 1 )) # flow list numbers
5859 raw_patch_data = patch_map
59- rulevars = asp_list # get rules - state variable overrides
60+ # rulevars = asp_list # get rules - state variable overrides
6061 CF2 = list () # empty list for new flow list
6162
6263 loop_ver = F
0 commit comments