|
From: Scott C. L. <sli...@ca...> - 2012-10-21 18:22:14
|
The docstring for phase_plot() (in src/phaseplot.py) concerning the parameter "T" is
Length of time to run simulations that generate streamlines.
If a single number, the same simulation time is used for all
initial conditions. Otherwise, should be a list of length
len(X0) that gives the simulation time for each initial
condition. Default value = 50.
It appears to me that the second possibility of "list of length len(X0)" is not actually implemented. Instead, if T is an array, then it is used in the call to odeint() directly. I propose adding the claimed functionality and further, in the case that T is a list, allowing any element to be an array itself. A patch achieving this is below. Existing code that uses phase_plot() would be unaffected by this change assuming that T is never given as a list.
Index: src/phaseplot.py
===================================================================
--- src/phaseplot.py (revision 202)
+++ src/phaseplot.py (working copy)
@@ -176,6 +176,8 @@
dx = np.empty((nr, Narrows, 2))
# See if we were passed a simulation time
+ if isinstance(T, list) and len(T) != nr:
+ raise TypeError("Insufficient number of simulation times given for initial conditions.")
if (T == None):
T = 50
@@ -197,6 +199,10 @@
# Generate the streamlines for each initial condition
for i in range(nr):
+ if isinstance(T, list):
+ TSPAN = T[i]
+ if (isinstance(TSPAN, (int, float))):
+ TSPAN = np.linspace(0, TSPAN, 100);
state = odeint(odefun, X0[i], TSPAN, args=parms);
time = TSPAN
mpl.hold(True);
|