Please install Python3 including the following packages:
- numpy
- pandas
- pytest
First of all, you need a github account. Please make one and send me the name of your account.
Then you can read the following website to learn about github:
https://guides.github.com/introduction/git-handbook/
Please familiarise yourself with the basic operations, especially:
git clone
git fetch
git merge
git add
git commit
Another useful command that is important to learn is opening a pull request. You can learn more about it here:
https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request
Implement the following functions in Landscape.py
:
-
LSP.sample
: Samples a species randomly from the species list in thespecies_list
attribute. -
LSP.simulate
: Simulatest
years of local succession where the overall recruitment and mortality must equal to therecr_trajectory
andmort_trajectory
attributes, respectively. At every year, the choice of species to be recruited is a random draw from the species in the local species pool. Whilst, the choice of species to die at every year is a random draw from the species that are already established in the plot.
The function should returnM
, an x t
matrix wheren
is the number of species in the local species pool andt
is the number of years (speciefied byrecr_trajectory
andmort_trajectory
). -
GSP.initialise_LSPs
: Initialises local species pools from the list of species in the global species pool.n
is the number of local pools andk
is the number of species in each pool. Assume that the local species pool is sampled randomly from the global species pool. -
GSP.simulate
: Simulatest
years of global succession where the overall recruitment and mortality must equal to therecr_trajectory
andmort_trajectory
attributes, respectively.
The function should returnM
, an x m x t
matrix wheren
is the number of species in the local species pool,m
is the number of localities andt
is the number of years (speciefied byrecr_trajectory
andmort_trajectory
). (Hint: useLSP.simulate
)
Once the implementation is done, test your implementation with the provided test in test.py
. You are encouraged to add additional tests to make sure that your code is correct.
The test can be run using the command:
pytest test.py
Once the program is done and tested, stage a pull request on this github.
To save the n x m x t
matrix output of GSP.simulate
, run:
python main.py --outfile results/out_matrix.pkl –-params params.json