|
From: Richard M. <mu...@cd...> - 2012-10-22 00:50:23
|
Looks good to me (I think I'm the original author of the phase_plot function).
-richard
On 21 Oct 2012, at 11:22 , Scott C. Livingston <sli...@ca...> wrote:
> 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);
>
>
> ------------------------------------------------------------------------------
> Everyone hates slow websites. So do we.
> Make your web apps faster with AppDynamics
> Download AppDynamics Lite for free today:
> http://p.sf.net/sfu/appdyn_sfd2d_oct
> _______________________________________________
> python-control-discuss mailing list
> pyt...@li...
> https://lists.sourceforge.net/lists/listinfo/python-control-discuss
|