Skip to content

Commit

Permalink
WIP code for vectorizing FBP
Browse files Browse the repository at this point in the history
  • Loading branch information
jordan-evens committed May 23, 2023
1 parent 22e6a5f commit 0ccb95f
Show file tree
Hide file tree
Showing 4 changed files with 1,529 additions and 1 deletion.
2 changes: 2 additions & 0 deletions R/fbp.r
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ fbp <- function(
if (!is.na(charmatch("input", search()))) {
detach(input)
}
names(input) <- toupper(names(input))
# If input is not provided, then calculate FBP with default values
if (is.null(input)) {
fullList <- fire_behaviour_prediction(input)
Expand All @@ -307,6 +308,7 @@ fbp <- function(
n <- ifelse(m * n0 >= nrow(input), n0, n0 + 1)
# Set up parallel processing, if # of cores is entered
if (cores > 1) {
# print(input)
# create and register a set of parallel R instances for foreach
cl <- parallel::makeCluster(cores)
doParallel::registerDoParallel(cl)
Expand Down
6 changes: 5 additions & 1 deletion R/fire_behaviour_prediction.r
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ fire_behaviour_prediction <- function(
warning("Attached dataset 'input' is being detached to use fbp() function.")
detach(input)
}
# print(input)
# print(input$ID)
output <- toupper(output)
# if input does not exist, then set defaults
if (is.null(input)) {
Expand Down Expand Up @@ -454,7 +456,9 @@ fire_behaviour_prediction <- function(
DF <- ifelse(ACCEL == 1, (DH + DB) / (LBt * 2), (DH + DB) / (LB * 2))
}
# Create an id field if it does not exist
ID <- ifelse(exists("ID") && !is.null(ID), ID, row.names(input))
if (!exists("ID") || is.null(ID)) {
ID <- row.names(input)
}
# if Primary is selected, wrap the primary outputs into a data frame and
# return them
if (output %in% c("PRIMARY", "P")) {
Expand Down
Loading

0 comments on commit 0ccb95f

Please sign in to comment.