usage() sys.exit() elif option in ("-a", "--prey-birth"): prey_birth = float(argument) elif option in ("-b", "--prey-death"): prey_death = float(argument) elif option in ("-c", "--predator-death"): predator_death = float(argument) elif option in ("-d", "--predator-birth"): predator_birth = float(argument) elif option in ("-f", "--num-predators"): num_predators = float(argument) elif option in ("-r", "--num-prey"): num_prey = float(argument) elif option in ("-t", "--time"): time = float(argument) elif option in ("-n", "--time-steps"): time_steps = float(argument) predator_config = {} predator_config[BIRTH] = predator_birth predator_config[DEATH] = predator_death predator_config[POPULATION] = num_predators prey_config = {} prey_config[BIRTH] = prey_birth prey_config[DEATH] = prey_death prey_config[POPULATION] = num_prey results = simulate(prey_config, predator_config, time, time_steps) plot(results)
import sys import numpy as np from lotkavolterra import plot def usage(): '''Print usage information.''' print "Usage: python plot_lv.py DATA_FILE" print "View the results of a simulation of the evolution of a population of predators and prey using the Lotka-Volterra equations." print "This program inputs a CSV file with the time, prey population and predator population at each time-step" if len(sys.argv) < 2: usage() sys.exit() else: data_file = sys.argv[1] data = np.loadtxt(data_file, delimiter=",") plot(data)