def test_simulation_make_movie_no_base():
    """Test to see that trying to create movies with no img_base raises
    RuntimeError"""
    sim = BioSim(island_map="OO\nOO", ini_pop=[], seed=1)
    sim.simulate(5, 1)
    with pytest.raises(RuntimeError):
        sim.make_movie()
def test_simulation_make_movie_gif(figfile_root):
    """Test to see that movie can be made with gif format"""
    sim = BioSim(island_map="OO\nOO",
                 ini_pop=[],
                 seed=1,
                 img_base=figfile_root)
    sim.simulate(5, 1)
    sim.make_movie(movie_fmt="gif")
    assert os.path.isfile(figfile_root + ".gif")
def test_simulation_make_movie_mp4(figfile_root):
    """Test to see that movie can be made with mp4 format"""
    # Kommentar: Går greit å feile med tox
    sim = BioSim(island_map="OO\nOO",
                 ini_pop=[],
                 seed=1,
                 img_base=figfile_root)
    sim.simulate(5, 1)
    sim.make_movie()
    assert os.path.isfile(figfile_root + ".mp4")
    def test_make_movie(self):
        sim = BioSim(img_base=r'test_sim')
        sim.simulate(10)
        sim.make_movie()
        assert os.path.isfile(r'test_sim.mp4')

        with pytest.raises(RuntimeError):
            sim = BioSim()
            sim.simulate(10)
            sim.make_movie()

        with pytest.raises(ValueError):
            sim = BioSim(img_base=r'test_sim', movie_fmt='gif')
            sim.simulate(10)
            sim.make_movie()

        # The error comes in simulate from the images and not the make_movie
        with pytest.raises(OSError):
            sim = BioSim(img_base='sjuke \ngreier')
            sim.simulate(10)
            sim.make_movie()
Exemple #5
0
# -*- coding: utf-8 -*-
"""
"""

__author__ = "Jon-Mikkel Korsvik & Petter Bøe Hørtvedt"
__email__ = "[email protected] & [email protected]"

from biosim.simulation import BioSim

default_population = [{
    "loc": (1, 1),
    "pop": [{
        "species": "Herbivore",
        "age": 5,
        "weight": 20
    } for _ in range(150)],
}, {
    "loc": (1, 1),
    "pop": [{
        "species": "Carnivore",
        "age": 5,
        "weight": 20
    } for _ in range(40)],
}]
sim = BioSim(island_map='OOOOOO\nOJJJJO\nOJJJJO\nOJJJJO\nOJJJJO\nOOOOOO',
             ini_pop=default_population,
             img_base='even_island',
             ymax_animals=3000)
sim.simulate(100)
sim.make_movie()
Exemple #6
0
        "loc": (9, 9),
        "pop": [{
            "species": "Carnivore",
            "age": 5,
            "weight": 20
        } for _ in range(40)],
    }]

    sim = BioSim(island_map=geogr,
                 ini_pop=ini_herbs,
                 seed=123456,
                 img_base="..\data\dv")

    sim.set_animal_parameters("Herbivore", {"zeta": 3.2, "xi": 1.8})
    sim.set_animal_parameters(
        "Carnivore",
        {
            "a_half": 70,
            "phi_age": 0.5,
            "omega": 0.3,
            "F": 65,
            "DeltaPhiMax": 9.0,
        },
    )
    sim.set_landscape_parameters("J", {"f_max": 700})
    sim.simulate(num_years=20, vis_years=1, img_years=1)
    sim.add_population(population=ini_carns)
    sim.simulate(num_years=20, vis_years=1, img_years=1)
    sim.make_movie()
    sim.make_movie("gif")
from biosim.simulation import BioSim
import numpy as np

np.random.seed(1)

ini_herbs = [
    {'loc': (2, 2), 'pop': [{'species': 'Herbivore', 'age': 5, 'weight': 50} for _ in range(50)]}]

kart = """\
            WWW
            WLW
            WWW"""


b = BioSim(seed=123,
           ini_pop=ini_herbs,
           island_map=kart,
           img_base='eirik/film',
           img_fmt='png',
           movie_format='mp4')

b.simulate(num_years=10, img_years=5)
b.make_movie()
Exemple #8
0
            "age": 5,
            "weight": 20
        } for _ in range(40)],
    }]

    sim = BioSim(island_map=geogr,
                 ini_pop=ini_herbs,
                 seed=123456,
                 img_base="../src/biosim/images/simulation/sim")

    sim.set_animal_parameters("Herbivore", {"zeta": 3.2, "xi": 1.8})
    sim.set_animal_parameters(
        "Carnivore",
        {
            "a_half": 70,
            "phi_age": 0.5,
            "omega": 0.3,
            "F": 65,
            "DeltaPhiMax": 9.0,
        },
    )
    sim.set_landscape_parameters("J", {"f_max": 700})

    sim.simulate(num_years=100, vis_years=1, img_years=1)

    sim.add_population(population=ini_carns)
    sim.simulate(num_years=100, vis_years=1, img_years=1)

    sim.make_movie("mp4")

    input("Press ENTER")
            "Herbivore": 100,
            "Carnivore": 50
        },
    )

    sim.set_animal_parameters("Herbivore", {
        "mu": 1,
        "omega": 0,
        "gamma": 0,
        "a_half": 1000
    })
    sim.set_animal_parameters("Carnivore", {
        "mu": 1,
        "omega": 0,
        "gamma": 0,
        "F": 0,
        "a_half": 1000
    })

    sim.set_landscape_parameters("J", {"f_max": 700})
    sim._img_pause_time = 1
    sim.simulate(num_years=10, vis_years=1)
    sim.make_movie()
    sim.make_movie(movie_fmt="gif")
    # sim.add_population(population=ini_carns)
    # sim.simulate(num_years=100, vis_years=1, img_years=2000)

    # plt.savefig("check_sim.pdf")

    # input("Press ENTER")