Skip to content

Commit

Permalink
add more documentation and tests on prop_female and na value changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristineStawitz-NOAA committed Feb 14, 2024
1 parent de26e55 commit 7b32501
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
4 changes: 2 additions & 2 deletions inst/include/population_dynamics/population/population.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ struct Population : public fims_model_object::FIMSObject<Type> {
fims::Vector<Type>
log_init_naa; /*!< estimated parameter: log numbers at age*/
fims::Vector<Type> log_M; /*!< estimated parameter: log Natural Mortality*/
fims::Vector<Type> proportion_female; /*!< estimated parameter: proportion female by year or age */
fims::Vector<Type> proportion_female; /*!< estimated parameter: proportion female by age */

// Transformed values
fims::Vector<Type> M; /*!< transformed parameter: Natural Mortality*/
Expand Down Expand Up @@ -74,7 +74,7 @@ struct Population : public fims_model_object::FIMSObject<Type> {
fims::Vector<Type> unfished_spawning_biomass; /*!< Derived quanity Spawning
biomass assuming unfished*/
fims::Vector<Type> proportion_mature_at_age; /*!< Derived quantity: Proportion
matura at age */
mature at age */
fims::Vector<Type> expected_numbers_at_age; /*!< Expected values: Numbers at
age (thousands?? millions??) */
fims::Vector<Type> expected_catch; /*!< Expected values: Catch*/
Expand Down
28 changes: 28 additions & 0 deletions tests/testthat/test-population-interface.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
library(testthat)
test_that("Population input settings work as expected", {
population <- new(Population)
nyears <- 10
nages <- 10
population$log_M <- rep(-1, nyears*nages)
population$estimate_M <- FALSE
population$log_init_naa <- log(rep(1, nages))
population$estimate_init_naa <- TRUE
population$nages <- nages
population$ages <- 1:nages
population$nfleets <- 2
population$nseasons <- 1
population$nyears <- nyears
population$proportion_female <- rep(0.5, nages)
population$estimate_prop_female <- FALSE

expect_equal(population$get_id(), 1)
expect_equal(population$log_M, rep(-1, nyears*nages))
expect_false(population$estimate_M)
expect_equal(population$log_init_naa, rep(0, nages))
expect_true(population$estimate_init_naa)
expect_false(population$estimate_prop_female)
expect_equal(population$proportion_female, rep(0.5, nages))

clear()

})
2 changes: 1 addition & 1 deletion vignettes/fims-demo.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ Now that we've prepared the data, let's pass it into FIMS. Each module in the FI

#### Fleet Data

Each fleet is required to have data in order to evaluate the objective function. Currently FIMS only has a fleet module that is used to set up both fleets and surveys. FIMS contains an Index module and AgeComp module to pass data objects into the fleet module. Each of these data modules require a dimension be added to indicate the dimensions of the raw data (e.g. nyears x nages matrix). Given this information, FIMS is able to correctly apply dimension folding for model output.
Each fleet is required to have data in order to evaluate the objective function. Currently FIMS only has a fleet module that is used to set up both fleets and surveys. FIMS contains an Index module and AgeComp module to pass data objects into the fleet module. Each of these data modules require a dimension be added to indicate the dimensions of the raw data (e.g. nyears x nages matrix). Any years with missing data should be specified with a value set to -999. Given this information, FIMS is able to correctly apply dimension folding for model output.

Using the `methods::show()` function, we can see that the Index module has a vector field named *index_data* and the AgeComp module has a vector field names *age_comp_data*.

Expand Down

0 comments on commit 7b32501

Please sign in to comment.