Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass initial population to EpiSystem, not EpiEnv #60

Merged
merged 19 commits into from
Jun 25, 2020
Merged

Conversation

sdl1
Copy link
Member

@sdl1 sdl1 commented Jun 24, 2020

This is a pre-cursor to #54

This removes the initial_population member from the EpiEnv struct. Instead, the initial_population can be passed to an EpiSystem constructor, where it is used to initialise the abundances.

There are a few reasons for this:

  • It is conceptually cleaner and means we can easily support constructing an EpiSystem without an initial_population
  • It means that in WIP: Use AxisArray for abundances.grid #54, we don't have to make any changes to EpiEnv, instead, we just have some small changes in EpiLandscape and EpiSystem
  • Also in WIP: Use AxisArray for abundances.grid #54, it will be possible to make EpiLandscape.grid the appropriate AxisArray in the EpiSystem constructor if initial_population is not passed in. This is hard to do in the current code, because initial_population is set to a default matrix of zeros in EpiEnv, which does not match with the actual shape of the classes

So basically with this PR the workflow is

total_pop = # load population
total_pop.data[total_pop .≈ 0.0] .= NaN
# Explicitly call the shrink function, which shrinks based on the NaNs
# We could easily wrap all this in a separate function
total_pop = shrink_to_active(total_pop)
...

# Just pass in the size here, like it used to be
epienv = simplehabitatAE(298.0K, size(total_pop), area, NoControl())
...

# Pass in the total_pop here. This will also take care of modifying the active region based on the NaNs in total_pop
epi = EpiSystem(epilist, epienv, rel, total_pop, UInt16(1))

Some of the diffs are large but this is mostly just moving around code

@sdl1 sdl1 requested a review from a team June 24, 2020 11:50
Copy link

@claireh93 claireh93 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great @sdl1! Ready to merge

@claireh93 claireh93 merged commit b6b0029 into dev Jun 25, 2020
@claireh93 claireh93 deleted the sl/initial_pop branch June 25, 2020 09:36
richardreeve pushed a commit that referenced this pull request May 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants