Island Module¶
The Island Class¶
-
class
src.biosim.island.Island(island_map_string, ini_pop, store_stats=False)[source]¶ Initiates the Island class: holds method for updating the map Class attribute map_params holds information of which letter relates to which class of landscape.py
Parameters: - island_map_string (multilinestring) – Multiple lines of string with characters representing cell type
- ini_pop (dict) – Key: location - Value: list of dict of species, age, and weight
-
map¶ calls method make_map, map creation from a multilinestring
Type: dict
-
herbivore_tot_data¶ Total number of herbivores indexed by year
Type: list
-
carnivore_tot_data¶ Total number of carnivore indexed by year
Type: list
-
stats¶ multiple nested dicts, stores all data on dead/ born animals.
Type: dict
Initializes instance of Island
Parameters: - island_map_string (str) – Multilinestring of map
- ini_pop (dict) – key : location - Value : list of dict
- store_stats (bool) –
-
add_population(population)[source]¶ Feeds a dictionary of population to cell by position.
Parameters: population (list) – loc: tuple pop: dict -
BaseCell.add_animals()¶
-
-
static
clean_multi_line_string(island_map_string)[source]¶ Strips and splits a multilinestring and checks for equal length of lines and specific letters at the edges: in this case ‘O’. Raises ValueError if criteria are not met.
Parameters: island_map_string (multilinestring) – Lines is row, letter is column Returns: lines – Lines of strings (cleaned) Return type: list
-
make_map(island_map_string)[source]¶ Creates a dictionary data frame that stores instances of cells by key: a tuple of (y, x)-coordinates
Also saves the length and with of the island
Parameters: island_map_string (str) – string of multiple lines Returns: map – key : tuple, value : instance of subclass of BaseCell Return type: dict
-
migrate()[source]¶ Goes through the map attribute of Island and calculates probabilities for herbivores and carnivores, with position and name of class.
calls migrate method in instance of subclass of BaseCell .. method:: BaseCell.migrate()
Notes
Adds herbivores and carnivores that has migrated to new cells
-
num_animals¶ Total number of animals on island.
Returns: num_animals Return type: int
-
num_animals_per_species¶ Number of animals per species in island, as dictionary.
Returns: num_animals_per_species Return type: dictionary
-
probability_calc(pos, animal)[source] Finds the preposition for all neighbouring cells within dx +- 1 and dy +-1. This means we have the positions North, West, South and East of the current position.
Then calculates the probability for the type of animal.
If the animal has nowhere to move, it returns None :param pos: Position of current cell :type pos: tuple :param animal: Name of the animal :type animal: str
Returns: prob_list – (Coordinate(y, x), and probabilities) Return type: list of tuples
-
ready_for_new_year()[source]¶ Resets each cell in Island.map .. method:: BaseCell.grow
-
BaseCell.reset_calculate_propensity()¶
-
BaseAnimal.reset_has_moved()¶
-
-
year¶ Last year simulated.