Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 15 additions & 35 deletions R/create_default_parameters.R
Original file line number Diff line number Diff line change
Expand Up @@ -357,13 +357,8 @@ create_default_selectivity <- function(
) {
# Input checks
form <- rlang::arg_match(form)
# NOTE: All new forms of selectivity must be placed in the vector of default
# arguments for `form` and their methods but be placed below in the call to
# `switch`
default <- switch(form,
"Logistic" = create_default_Logistic(),
"DoubleLogistic" = create_default_DoubleLogistic()
) |>
# Dynamically call the appropriate create_default_* function
default <- do.call(get(paste("create", "default", form, sep = "_")), list()) |>
dplyr::mutate(
module_name = "Selectivity"
)
Expand Down Expand Up @@ -451,13 +446,9 @@ create_default_fleet <- function(unnested_configurations,
dplyr::arrange(dplyr::desc(type)) |>
dplyr::pull(uncertainty)

index_distribution_default <- switch(index_distribution,
"Dnorm" = create_default_DnormDistribution(
value = index_uncertainty,
input_type = "data",
data = data
),
"Dlnorm" = create_default_DlnormDistribution(
index_distribution_default <- do.call(
get(paste0("create_default_", index_distribution, "Distribution")),
list(
value = index_uncertainty,
input_type = "data",
data = data
Expand Down Expand Up @@ -509,13 +500,9 @@ create_default_fleet <- function(unnested_configurations,
dplyr::arrange(dplyr::desc(type)) |>
dplyr::pull(uncertainty)

landings_distribution_default <- switch(landings_distribution,
"Dnorm" = create_default_DnormDistribution(
value = landings_uncertainty,
input_type = "data",
data = data
),
"Dlnorm" = create_default_DlnormDistribution(
landings_distribution_default <- do.call(
get(paste0("create_default_", landings_distribution, "Distribution")),
list(
value = landings_uncertainty,
input_type = "data",
data = data
Expand Down Expand Up @@ -582,12 +569,8 @@ create_default_maturity <- function(
))
}

# NOTE: All new forms of maturity must be placed in the vector of default
# arguments for `form` and their methods but be placed below in the call to
# `switch`
default <- switch(form,
"Logistic" = create_default_Logistic()
) |>
# Dynamically call the appropriate create_default_* function
default <- do.call(get(paste("create", "default", form, sep = "_")), list()) |>
# We don't have an option to input maturity data into FIMS, so the maturity
# parameters aren't really estimable. The parameters should be constant for now.
# See more details from https://github.com/orgs/NOAA-FIMS/discussions/944.
Expand Down Expand Up @@ -820,19 +803,16 @@ create_default_recruitment <- function(
))
}
# Create default parameters based on the recruitment form
# NOTE: All new forms of recruitment must be placed in the vector of default
# arguments for `form` and their methods but be placed below in the call to
# `switch`
form_default <- switch(form,
"BevertonHolt" = create_default_BevertonHoltRecruitment(data)
)
# Dynamically call the appropriate create_default_* function
form_default <- do.call(get(paste0("create_default_", form, "Recruitment")), list(data = data))

distribution_input <- unnested_configurations |>
dplyr::filter(module_name == "Recruitment")

if (!is.null(distribution_input[["distribution"]])) {
distribution_default <- switch(distribution_input[["distribution"]],
"Dnorm" = create_default_DnormDistribution(
distribution_default <- do.call(
get(paste0("create_default_", distribution_input[["distribution"]], "Distribution")),
list(
data = data,
input_type = "process"
)
Expand Down