5252def phase_plane_plot (
5353 sys , pointdata = None , timedata = None , gridtype = None , gridspec = None ,
5454 plot_streamlines = True , plot_vectorfield = False , plot_equilpoints = True ,
55- plot_separatrices = True , ax = None , ** kwargs
55+ plot_separatrices = True , ax = None , suppress_warnings = False , ** kwargs
5656):
5757 """Plot phase plane diagram.
5858
@@ -88,22 +88,6 @@ def phase_plane_plot(
8888 Parameters to pass to system. For an I/O system, `params` should be
8989 a dict of parameters and values. For a callable, `params` should be
9090 dict with key 'args' and value given by a tuple (passed to callable).
91- plot_streamlines : bool or dict
92- If `True` (default) then plot streamlines based on the pointdata
93- and gridtype. If set to a dict, pass on the key-value pairs in
94- the dict as keywords to :func:`~control.phaseplot.streamlines`.
95- plot_vectorfield : bool or dict
96- If `True` (default) then plot the vector field based on the pointdata
97- and gridtype. If set to a dict, pass on the key-value pairs in
98- the dict as keywords to :func:`~control.phaseplot.vectorfield`.
99- plot_equilpoints : bool or dict
100- If `True` (default) then plot equilibrium points based in the phase
101- plot boundary. If set to a dict, pass on the key-value pairs in the
102- dict as keywords to :func:`~control.phaseplot.equilpoints`.
103- plot_separatrices : bool or dict
104- If `True` (default) then plot separatrices starting from each
105- equilibrium point. If set to a dict, pass on the key-value pairs
106- in the dict as keywords to :func:`~control.phaseplot.separatrices`.
10791 color : str
10892 Plot all elements in the given color (use `plot_<fcn>={'color': c}`
10993 to set the color in one element of the phase plot.
@@ -117,6 +101,27 @@ def phase_plane_plot(
117101 out[1] = Quiver object (vector field arrows)
118102 out[2] = list of Line2D objects (equilibrium points)
119103
104+ Other parameters
105+ ----------------
106+ plot_streamlines : bool or dict, optional
107+ If `True` (default) then plot streamlines based on the pointdata
108+ and gridtype. If set to a dict, pass on the key-value pairs in
109+ the dict as keywords to :func:`~control.phaseplot.streamlines`.
110+ plot_vectorfield : bool or dict, optional
111+ If `True` (default) then plot the vector field based on the pointdata
112+ and gridtype. If set to a dict, pass on the key-value pairs in
113+ the dict as keywords to :func:`~control.phaseplot.vectorfield`.
114+ plot_equilpoints : bool or dict, optional
115+ If `True` (default) then plot equilibrium points based in the phase
116+ plot boundary. If set to a dict, pass on the key-value pairs in the
117+ dict as keywords to :func:`~control.phaseplot.equilpoints`.
118+ plot_separatrices : bool or dict, optional
119+ If `True` (default) then plot separatrices starting from each
120+ equilibrium point. If set to a dict, pass on the key-value pairs
121+ in the dict as keywords to :func:`~control.phaseplot.separatrices`.
122+ suppress_warnings : bool, optional
123+ If set to `True`, suppress warning messages in generating trajectories.
124+
120125 """
121126 # Process arguments
122127 params = kwargs .get ('params' , None )
@@ -149,7 +154,8 @@ def _create_kwargs(global_kwargs, local_kwargs, **other_kwargs):
149154 kwargs , plot_streamlines , gridspec = gridspec , gridtype = gridtype ,
150155 ax = ax )
151156 out [0 ] += streamlines (
152- sys , pointdata , timedata , check_kwargs = False , ** kwargs_local )
157+ sys , pointdata , timedata , check_kwargs = False ,
158+ suppress_warnings = suppress_warnings , ** kwargs_local )
153159
154160 # Get rid of keyword arguments handled by streamlines
155161 for kw in ['arrows' , 'arrow_size' , 'arrow_style' , 'color' ,
@@ -203,7 +209,8 @@ def _create_kwargs(global_kwargs, local_kwargs, **other_kwargs):
203209
204210
205211def vectorfield (
206- sys , pointdata , gridspec = None , ax = None , check_kwargs = True , ** kwargs ):
212+ sys , pointdata , gridspec = None , ax = None , suppress_warnings = False ,
213+ check_kwargs = True , ** kwargs ):
207214 """Plot a vector field in the phase plane.
208215
209216 This function plots a vector field for a two-dimensional state
@@ -244,6 +251,11 @@ def vectorfield(
244251 -------
245252 out : Quiver
246253
254+ Other parameters
255+ ----------------
256+ suppress_warnings : bool, optional
257+ If set to `True`, suppress warning messages in generating trajectories.
258+
247259 """
248260 # Get system parameters
249261 params = kwargs .pop ('params' , None )
@@ -283,8 +295,8 @@ def vectorfield(
283295
284296
285297def streamlines (
286- sys , pointdata , timedata = 1 , gridspec = None , gridtype = None ,
287- dir = None , ax = None , check_kwargs = True , ** kwargs ):
298+ sys , pointdata , timedata = 1 , gridspec = None , gridtype = None , dir = None ,
299+ ax = None , check_kwargs = True , suppress_warnings = False , ** kwargs ):
288300 """Plot stream lines in the phase plane.
289301
290302 This function plots stream lines for a two-dimensional state space
@@ -328,6 +340,11 @@ def streamlines(
328340 -------
329341 out : list of Line2D objects
330342
343+ Other parameters
344+ ----------------
345+ suppress_warnings : bool, optional
346+ If set to `True`, suppress warning messages in generating trajectories.
347+
331348 """
332349 # Get system parameters
333350 params = kwargs .pop ('params' , None )
@@ -373,7 +390,8 @@ def streamlines(
373390 timepts = _make_timepts (timedata , i )
374391 traj = _create_trajectory (
375392 sys , revsys , timepts , X0 , params , dir ,
376- gridtype = gridtype , gridspec = gridspec , xlim = xlim , ylim = ylim )
393+ gridtype = gridtype , gridspec = gridspec , xlim = xlim , ylim = ylim ,
394+ suppress_warnings = suppress_warnings )
377395
378396 # Plot the trajectory (if there is one)
379397 if traj .shape [1 ] > 1 :
@@ -465,7 +483,7 @@ def equilpoints(
465483
466484def separatrices (
467485 sys , pointdata , timedata = None , gridspec = None , ax = None ,
468- check_kwargs = True , ** kwargs ):
486+ check_kwargs = True , suppress_warnings = False , ** kwargs ):
469487 """Plot separatrices in the phase plane.
470488
471489 This function plots separatrices for a two-dimensional state space
@@ -509,6 +527,11 @@ def separatrices(
509527 -------
510528 out : list of Line2D objects
511529
530+ Other parameters
531+ ----------------
532+ suppress_warnings : bool, optional
533+ If set to `True`, suppress warning messages in generating trajectories.
534+
512535 """
513536 # Get system parameters
514537 params = kwargs .pop ('params' , None )
@@ -586,13 +609,15 @@ def separatrices(
586609 if evals [j ].real < 0 :
587610 traj = _create_trajectory (
588611 sys , revsys , timepts , x0 , params , 'reverse' ,
589- gridtype = 'boxgrid' , xlim = xlim , ylim = ylim )
612+ gridtype = 'boxgrid' , xlim = xlim , ylim = ylim ,
613+ suppress_warnings = suppress_warnings )
590614 color = stable_color
591615 linestyle = '--'
592616 elif evals [j ].real > 0 :
593617 traj = _create_trajectory (
594618 sys , revsys , timepts , x0 , params , 'forward' ,
595- gridtype = 'boxgrid' , xlim = xlim , ylim = ylim )
619+ gridtype = 'boxgrid' , xlim = xlim , ylim = ylim ,
620+ suppress_warnings = suppress_warnings )
596621 color = unstable_color
597622 linestyle = '-'
598623
@@ -880,17 +905,21 @@ def _get_color(kwargs, ax=None):
880905
881906
882907def _create_trajectory (
883- sys , revsys , timepts , X0 , params , dir ,
908+ sys , revsys , timepts , X0 , params , dir , suppress_warnings = False ,
884909 gridtype = None , gridspec = None , xlim = None , ylim = None ):
885910 # Comput ethe forward trajectory
886911 if dir == 'forward' or dir == 'both' :
887912 fwdresp = input_output_response (
888- sys , timepts , X0 = X0 , params = params , ignore_error = True )
913+ sys , timepts , X0 = X0 , params = params , ignore_errors = True )
914+ if not fwdresp .success and not suppress_warnings :
915+ warnings .warn (f"{ X0 = } , { fwdresp .message } " )
889916
890917 # Compute the reverse trajectory
891918 if dir == 'reverse' or dir == 'both' :
892919 revresp = input_output_response (
893- revsys , timepts , X0 = X0 , params = params , ignore_error = True )
920+ revsys , timepts , X0 = X0 , params = params , ignore_errors = True )
921+ if not revresp .success and not suppress_warnings :
922+ warnings .warn (f"{ X0 = } , { revresp .message } " )
894923
895924 # Create the trace to plot
896925 if dir == 'forward' :
@@ -1212,6 +1241,3 @@ def _find(condition):
12121241 Private implementation of deprecated matplotlib.mlab.find
12131242 """
12141243 return np .nonzero (np .ravel (condition ))[0 ]
1215-
1216-
1217-
0 commit comments