File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -127,7 +127,7 @@ RHESSysPreprocess = function(template,
127127 asprules = asprules )
128128
129129 readin = world_gen_out [[1 ]]
130- asp_list = world_gen_out [[2 ]]
130+ asp_rules = world_gen_out [[2 ]]
131131
132132 # ---------- Run CreateFlownet ----------
133133 cat(" Begin CreateFlownet.R" )
@@ -145,7 +145,7 @@ RHESSysPreprocess = function(template,
145145 readin = readin ,
146146 type = type ,
147147 typepars = typepars ,
148- asp_list = asp_list ,
148+ asp_rules = asp_rules ,
149149 streams = streams ,
150150 overwrite = overwrite ,
151151 roads = roads ,
Original file line number Diff line number Diff line change @@ -154,6 +154,11 @@ world_gen = function(template,
154154 } # end loop through n_basestations
155155
156156 # -------------------- Process Template + Maps --------------------
157+ # mode for aggregating by mode
158+ mode_fun = function (x ) {
159+ ux <- unique(x )
160+ ux [which.max(tabulate(match(x , ux )))]
161+ }
157162 # Build list based on operations called for by template
158163 statevars = vector(" list" ,length(template_clean ))
159164
@@ -206,14 +211,7 @@ world_gen = function(template,
206211 statevars [[i ]][[s ]] = aggregate(maptmp , by = level_agg , FUN = " mean" )
207212 } else if (template_clean [[i ]][2 ] == " mode" ) { # mode
208213 maptmp = as.vector(t(map_df [template_clean [[i ]][2 + s - s2 ]]))
209- statevars [[i ]][[s ]] = aggregate(
210- maptmp ,
211- by = level_agg ,
212- FUN = function (x ) {
213- ux <- unique(x )
214- ux [which.max(tabulate(match(x , ux )))]
215- }
216- )
214+ statevars [[i ]][[s ]] = aggregate( maptmp , by = level_agg , FUN = mode_fun )
217215 } else if (template_clean [[i ]][2 ] == " eqn" ) { # only for horizons old version -- use normal mean in future
218216 maptmp = as.vector(t(map_df [template_clean [[i ]][5 ]]))
219217 statevars [[i ]][[s ]] = aggregate(maptmp , by = level_agg , FUN = " mean" )
You can’t perform that action at this time.
0 commit comments