
    
3jh                     0   S r SSKrSSKrSSKJrJrJr  SSKJ	r
  SSKJr  SSKJr  S/r     SSSSS.S jjr " S	 S
5      r " S S5      r " S S5      r " S S5      r " S S\5      r " S S\5      rS r " S S\5      r   SS jrS rS rS r g)z,
Streamline plotting for 2D vector fields.

    N)_api	colorizerpatches
streamplot         ?)integration_max_step_scaleintegration_max_error_scale
num_arrowsc          	         [        X5      n[        U5      n[        UU5      nUS::  a  [        SSU 3-   5      eUS::  a  [        SSU 3-   5      eUS:  a  [        SU< 35      eUc  [        R
                  R                  nUc  U R                  nUc  U R                  R                  5       n[        R                  " US5      n0 n[        US	U
-  S
9n[        R                  " / SQUS9  US:X  a  US-  n[        U[         R"                  5      nU(       aH  UR$                  UR$                  :w  a  [        S5      e/ /n[         R&                  R)                  U5      nO
UUS'   UUS'   [        U[         R"                  5      (       a+  UR$                  UR$                  :w  a  [        S5      e/ US'   O
UUS'   UUS'   UUS'   UUS'   UR$                  UR$                  :w  d  UR$                  UR$                  :w  a  [        S5      e[         R&                  R)                  U5      n[         R&                  R)                  U5      n[+        X4UUUU5      n/ nUce  [-        UR$                  5       HJ  u  nn UU U4   S:X  d  M  UR/                  UU 5      u  n!n"U" U!U"UUU5      n#U#c  M9  UR1                  U#5        ML     GOi[         R2                  " U[4        S9R7                  5       n$U$ Hy  u  n%n&UR8                  U%s=::  a  UR8                  UR:                  -   ::  a5  O  O2UR<                  U&s=::  a  UR<                  UR>                  -   ::  a  Mg  O  [        SU% SU& S35      e   U$SS2S4==   UR8                  -  ss'   U$SS2S4==   UR<                  -  ss'   U$ H  u  n%n&URA                  U%U&5      u  n!n"[         RB                  " U!SURD                  S-
  5      n![         RB                  " U"SURF                  S-
  5      n"U" U!U"UUU5      n#U#c  Mv  UR1                  U#5        M     U(       aL  U	c3  [H        RJ                  " URM                  5       URO                  5       5      n	[P        RR                  " U5      n/ n'/ n(U GH  n#U#RT                  u  n)n*URW                  U)U*5      u  n+n,U+UR8                  -  n+U,UR<                  -  n,[        U[         R"                  5      (       d  U(       aW  [         RX                  " U+U,/5      R[                  SSS5      n-U'R]                  [         R^                  " U-SS U-SS /5      5        O)[         RX                  " U+U,/5      n-U'R1                  U-5        [         R`                  " [         Rb                  " [         Rd                  " U+5      [         Rd                  " U,5      5      5      n.[        U[         R"                  5      (       a$  [g        UU)U*5      SS n/US   R]                  U/5        U(       a!  [g        UU)U*5      SS n0WR1                  U05        [i        SUS-   5       H  n[         Rj                  " U.U.S   UUS-   -  -  5      n1U+U1   U,U1   4n2[         Rl                  " U+U1U1S-    5      [         Rl                  " U,U1U1S-    5      4n3[        U[         R"                  5      (       a  W/U1   US'   U(       a  U" U	" W0U1   5      5      US'   [n        Rp                  " U2U34SU0UD6n4U(R1                  U45        M     GM     [r        Rt                  " U'4SU0UD6n5UR8                  UR8                  UR:                  -   /U5Rv                  Rx                  SS& UR<                  UR<                  UR>                  -   /U5Rv                  Rz                  SS& U(       aP  U5R}                  [         R&                  R_                  W5      5        U5R                  U5        U5R                  U	5        U R                  U55        [r        R                  " U(5      n6U( H  n4U R                  U45        M     U R                  5         [        U5U65      n7U7$ )a  
Draw streamlines of a vector flow.

Parameters
----------
x, y : 1D/2D arrays
    Evenly spaced strictly increasing arrays to make a grid.  If 2D, all
    rows of *x* must be equal and all columns of *y* must be equal; i.e.,
    they must be as if generated by ``np.meshgrid(x_1d, y_1d)``.
u, v : 2D arrays
    *x* and *y*-velocities. The number of rows and columns must match
    the length of *y* and *x*, respectively.
density : float or (float, float)
    Controls the closeness of streamlines. When ``density = 1``, the domain
    is divided into a 30x30 grid. *density* linearly scales this grid.
    Each cell in the grid can have, at most, one traversing streamline.
    For different densities in each direction, use a tuple
    (density_x, density_y).
linewidth : float or 2D array
    The width of the streamlines. With a 2D array the line width can be
    varied across the grid. The array must have the same shape as *u*
    and *v*.
color : :mpltype:`color` or 2D array
    The streamline color. If given an array, its values are converted to
    colors using *cmap* and *norm*.  The array must have the same shape
    as *u* and *v*.
cmap, norm
    Data normalization and colormapping parameters for *color*; only used
    if *color* is an array of floats. See `~.Axes.imshow` for a detailed
    description.
arrowsize : float
    Scaling factor for the arrow size.
arrowstyle : str
    Arrow style specification.
    See `~matplotlib.patches.FancyArrowPatch`.
minlength : float
    Minimum length of streamline in axes coordinates.
start_points : (N, 2) array
    Coordinates of starting points for the streamlines in data coordinates
    (the same coordinates as the *x* and *y* arrays).
zorder : float
    The zorder of the streamlines and arrows.
    Artists with lower zorder values are drawn first.
maxlength : float
    Maximum length of streamline in axes coordinates.
integration_direction : {'forward', 'backward', 'both'}, default: 'both'
    Integrate the streamline in forward, backward or both directions.
data : indexable object, optional
    DATA_PARAMETER_PLACEHOLDER
broken_streamlines : boolean, default: True
    If False, forces streamlines to continue until they
    leave the plot domain.  If True, they may be terminated if they
    come too close to another streamline.
integration_max_step_scale : float, default: 1.0
    Multiplier on the maximum allowable step in the streamline integration routine.
    A value between zero and one results in a max integration step smaller than
    the default max step, resulting in more accurate streamlines at the cost
    of greater computation time; a value greater than one does the converse. Must be
    greater than zero.

    .. versionadded:: 3.11

integration_max_error_scale : float, default: 1.0
    Multiplier on the maximum allowable error in the streamline integration routine.
    A value between zero and one results in a tighter max integration error than
    the default max error, resulting in more accurate streamlines at the cost
    of greater computation time; a value greater than one does the converse. Must be
    greater than zero.

    .. versionadded:: 3.11

num_arrows : int
    Number of arrows per streamline. The arrows are spaced equally along the steps
    each streamline takes. Note that this can be different to being spaced equally
    along the distance of the streamline.


Returns
-------
StreamplotSet
    Container object with attributes

    - ``lines``: `.LineCollection` of streamlines

    - ``arrows``: `.PatchCollection` containing `.FancyArrowPatch`
      objects representing the arrows half-way along streamlines.

    This container will probably change in the future to allow changes
    to the colormap, alpha, etc. for both lines and arrows, but these
    changes should be backward compatible.
        z5The value of integration_max_step_scale must be > 0, zgot z6The value of integration_max_error_scale must be > 0, r   z5The value of num_arrows must be >= 0, got num_arrows=Nzlines.linewidth
   )
arrowstylemutation_scale)bothforwardbackward)integration_directionr   g       @z?If 'color' is given, it must match the shape of the (x, y) gridcolorzCIf 'linewidth' is given, it must match the shape of the (x, y) grid	linewidthzorderz3'u' and 'v' must match the shape of the (x, y) grid)dtypezStarting point (z, z) outside of data boundariesr      	transform)FGrid
StreamMask	DomainMap
ValueErrormlinesLine2Dr   	transData
_get_linesget_next_colormpl
_val_or_rcdictr   check_in_list
isinstancenpndarrayshapemamasked_invalid_get_integrator_gen_starting_points	mask2gridappend
asanyarrayfloatcopyx_originwidthy_originheight	data2gridclipnxnymcolors	Normalizeminmaxr   _ensure_cmapT	grid2data	transposereshapeextendhstackcumsumhypotdiff
interpgridrangesearchsortedmeanr   FancyArrowPatchmcollectionsLineCollectionsticky_edgesxy	set_arrayset_cmapset_normadd_collectionPatchCollection	add_patchautoscale_viewStreamplotSet)8axesrT   rU   uvdensityr   r   cmapnorm	arrowsizer   	minlengthr   r   start_points	maxlengthr   broken_streamlinesr	   r
   r   gridmaskdmapline_kwarrow_kwuse_multicolor_linesline_colors	integratetrajectoriesxmymxgygtsp2xsysstreamlinesarrowstgxtgytxtypointssline_widthscolor_valuesidx
arrow_tail
arrow_headplcacstream_containers8                                                           O/home/wildlama/miniconda3/lib/python3.13/site-packages/matplotlib/streamplot.pyr   r      s   B :DgDT4 D!S(C-./0
 	

 #c)D./01
 	

 A~Qj]STT~%% NN	}..0y*;<IGz"y.IH6-BD &R	%eRZZ8;;$**$ / 0 0d$$U+ !)RZZ((??djj( 8 9 9!( )GHHX 	ww$**4:: 5NOO
QA
QAdIy 57I L*4::6FBBF|q B/Bb"&889; = ''* 7 mmL6;;= FBMMRE4==4::+EEMMRF4==4;;+FF #3B4r" >3 "3 4 4  	AqD	T]]"	AqD	T]]"	FB^^B+FB
 Q!,BQ!,B"b"46P57A}##A&  <$$UYY[%))+>D%%d+KF33SS)B
dmm
dmm i,,0D\\2r(+33B1=Fryy&"+vabz)BCD\\2r(+Fv& IIbhhrwwr{BGGBK89i,,$YS9#2>KK ''4%eS#6s;L|, q*Q,'A//!QrUaA.>%?@CS'2c7+J''"Sq/2BGGBs37O4LMJ)RZZ00(3C(8%#$(l3.?)@$A!''JI2;I?GIAMM! (3 R 
	$	$
5(
5,3
5B MM4==4::+EFBOOa MM4==4;;+FGBOOa
RUU\\+./
D
D		%	%f	-Bq  	$R,    c                       \ rS rSrS rSrg)r]   i(  c                     Xl         X l        g N)linesr{   )selfr   r{   s      r   __init__StreamplotSet.__init__*  s    
r   )r{   r   N)__name__
__module____qualname____firstlineno__r   __static_attributes__ r   r   r]   r]   (  s    r   r]   c                   V    \ rS rSrSrS rS rS rS rS r	SS jr
S	 rSS
 jrS rSrg)r   i2  a  
Map representing different coordinate systems.

Coordinate definitions:

* axes-coordinates goes from 0 to 1 in the domain.
* data-coordinates are specified by the input x-y coordinates.
* grid-coordinates goes from 0 to N and 0 to M for an N x M grid,
  where N and M match the shape of the input data.
* mask-coordinates goes from 0 to N and 0 to M for an N x M mask,
  where N and M are user-specified to control the density of streamlines.

This class also has methods for adding trajectories to the StreamMask.
Before adding a trajectory, run `start_trajectory` to keep track of regions
crossed by a given trajectory. Later, if you decide the trajectory is bad
(e.g., if the trajectory is very short) just call `undo_trajectory`.
c                 L   Xl         X l        UR                  S-
  UR                  S-
  -  U l        UR                  S-
  UR                  S-
  -  U l        SU R                  -  U l        SU R
                  -  U l        SUR                  -  U l	        SUR                  -  U l        g )Nr   r   )ri   rj   r<   x_grid2maskr=   y_grid2maskx_mask2gridy_mask2griddxx_data2griddyy_data2grid)r   ri   rj   s      r   r   DomainMap.__init__E  s    		 GGaKDGGaK8 GGaKDGGaK8 0 00 0 00<<r   c                 ^    [        XR                  -  5      [        X R                  -  5      4$ )z;Return nearest space in mask-coords from given grid-coords.)roundr   r   r   xiyis      r   	grid2maskDomainMap.grid2maskR  s)    R***+U28H8H3H-IIIr   c                 :    XR                   -  X R                  -  4$ r   )r   r   )r   rr   rs   s      r   r1   DomainMap.mask2gridV      $$$b+;+;&;;;r   c                 :    XR                   -  X R                  -  4$ r   r   r   )r   xdyds      r   r:   DomainMap.data2gridY  r   r   c                 :    XR                   -  X R                  -  4$ r   r   )r   rt   ru   s      r   rD   DomainMap.grid2data\  r   r   c                 b    U R                  X5      u  pEU R                  R                  XEU5        g r   )r   rj   _start_trajectoryr   rt   ru   rh   rr   rs   s         r   start_trajectoryDomainMap.start_trajectory_  s'    '		##B,>?r   c                 N    U R                  X5      u  p4X44U R                  l        g r   )r   rj   _current_xy)r   rt   ru   rr   rs   s        r   reset_start_pointDomainMap.reset_start_pointc  s     '!#		r   c                     U R                   R                  X5      (       d  [        eU R                  X5      u  pEU R                  R                  XEU5        g r   )ri   within_gridInvalidIndexErrorr   rj   _update_trajectoryr   s         r   update_trajectoryDomainMap.update_trajectoryg  sB    yy$$R,,##'		$$R-?@r   c                 8    U R                   R                  5         g r   )rj   _undo_trajectoryr   s    r   undo_trajectoryDomainMap.undo_trajectorym  s    		""$r   )ri   rj   r   r   r   r   r   r   NT)r   r   r   r   __doc__r   r   r1   r:   rD   r   r   r   r   r   r   r   r   r   r   2  s7    $(J<<<@)A%r   r   c                   4    \ rS rSrSrS r\S 5       rS rSr	g)r   iq  zGrid of data.c                     [         R                  " U5      S:X  a  OS[         R                  " U5      S:X  a.  US   n[         R                  " X15      (       d  [        S5      eUnO[        S5      e[         R                  " U5      S:X  a  Oi[         R                  " U5      S:X  aD  [         R                  " U5      nUS   n[         R                  " XT5      (       d  [        S5      eUnO[        S5      e[         R
                  " U5      S:  R                  5       (       d  [        S5      e[         R
                  " U5      S:  R                  5       (       d  [        S	5      e[        U5      U l        [        U5      U l	        US   US   -
  U l
        US   US   -
  U l        US   U l        US   U l        US
   US   -
  U l        US
   US   -
  U l        [         R                  " [         R
                  " U5      U R                  U R                  S-
  -  5      (       d  [        S5      e[         R                  " [         R
                  " U5      U R                  U R                  S-
  -  5      (       d  [        S5      eg )Nr   r   r   zThe rows of 'x' must be equalz$'x' can have at maximum 2 dimensionsz The columns of 'y' must be equalz$'y' can have at maximum 2 dimensionsz'x' must be strictly increasingz'y' must be strictly increasingr   z!'x' values must be equally spacedz!'y' values must be equally spaced)r*   ndimallcloser   rE   rK   alllenr<   r=   r   r   r6   r8   r7   r9   )r   rT   rU   x_rowyty_cols         r   r   Grid.__init__s  s   771:?WWQZ1_aDE;;u(( !@AAACDD771:?WWQZ1_aBqEE;;u)) !CDDACDD
Q##%%>??
Q##%%>??a&a&A$1+A$1+!!rUQqT\
eadl{{2771:tzzTWWq['ABB@AA{{2771:t{{dggk'BCC@AA Dr   c                 2    U R                   U R                  4$ r   )r=   r<   r   s    r   r,   
Grid.shape  s    wwr   c                     SUs=:*  =(       a    U R                   S-
  :*  Os  =(       a"    SUs=:*  =(       a    U R                  S-
  :*  $ s  $ )z9Return whether (*xi*, *yi*) is a valid index of the grid.r   r   )r<   r=   r   s      r   r   Grid.within_grid  s?     B%%$''A+%@!r*@*@TWWq[*@@*@@r   )r   r   r9   r<   r=   r7   r6   r8   N)
r   r   r   r   r   r   propertyr,   r   r   r   r   r   r   r   q  s&    +BZ    Ar   r   c                   >    \ rS rSrSrS rS rS
S jrS rS
S jr	Sr
g	)r   i  a6  
Mask to keep track of discrete regions crossed by streamlines.

The resolution of this grid determines the approximate spacing between
trajectories. Streamlines are only allowed to pass through zeroed cells:
When a streamline enters a cell, that cell is set to 1, and no new
streamlines are allowed to enter.
c                     S[         R                  " US5      -  R                  [        5      u  U l        U l        U R                  S:  d  U R
                  S:  a  [        S5      e[         R                  " U R
                  U R                  45      U l        U R                  R                  U l	        S U l
        g ! [         a  n[        S5      UeS nAff = f)N   r   z,'density' must be a scalar or be of length 2r   z'density' must be positive)r*   broadcast_toastypeintr<   r=   r   zeros_maskr,   r   )r   ra   errs      r   r   StreamMask.__init__  s    	+ "R__Wa%@ @HHMDGTW 77Q;$''A+9::XXtww01
ZZ%%
  	+ ! "'*+	+s   :B; ;
CCCc                      U R                   U   $ r   )r   )r   argss     r   __getitem__StreamMask.__getitem__  s    zz$r   c                 6    / U l         U R                  XU5        g)z%Start recording streamline trajectoryN)_trajr   r   rr   rs   rh   s       r   r   StreamMask._start_trajectory  s    
(:;r   c                 H    U R                    H  nSU R                  U'   M     g)z#Remove current trajectory from maskr   N)r   r   )r   rv   s     r   r   StreamMask._undo_trajectory  s    ADJJqM r   c                     U R                   X4:w  aM  XU4   S:X  a5  U R                  R                  X!45        SU R                  X!4'   X4U l         gU(       a  [        egg)zv
Update current trajectory position in mask.

If the new position has already been filled, raise `InvalidIndexError`.
r   r   N)r   r   r2   r   r   r   s       r   r   StreamMask._update_trajectory  sa     x'F|q 

!!2(+%&

26"$&8 %++ (r   )r   r   r   r<   r=   r,   Nr   )r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r     s       <

r   r   c                       \ rS rSrSrg)r   i  r   Nr   r   r   r   r   r   r   r   r   r         r   r   c                       \ rS rSrSrg)TerminateTrajectoryi  r   Nr   r   r   r   r   r     r   r   r   c                 >  ^ ^^^^^^	^
^ TR                  T T5      u  m mT TR                  R                  S-
  -  nTTR                  R                  S-
  -  n[        R
                  R                  US-  US-  -   5      mUUU U4S jm
U
4S jm	  SU	UU
UUU4S jjnU$ )Nr   r   c                    > TR                   R                  X5      (       d  [        e[        TX5      nUS:X  a
  [	        5       eSU-  n[        TX5      n[        T	X5      nXC-  XS-  4$ )Nr   r   )ri   r   OutOfBoundsrL   r   )
r   r   ds_dtdt_dsuivirk   speedr_   r`   s
         r   forward_time%_get_integrator.<locals>.forward_time  sj    yy$$R,,5")A:%''U
2"2"z2:%%r   c                 $   > T" X5      u  p#U* U* 4$ r   r   )r   r   dxidyir   s       r   backward_time&_get_integrator.<locals>.backward_time  s    'tcTzr   c           
        > S/ pe T
R                  XU5        TS;   a!  [        XT
T	TUUU5      u  pxXW-  nXhSSS2   -  nTS;   a/  T
R                  X5        [        XT
TTUUU5      u  pxXW-  nXhSS -  nUT:  a.  [        R
                  " U[        R                  " S5      5      S   $ T
R                  5         g! [         a     gf = f)	aj  
Return x, y grid-coordinates of trajectory based on starting point.

Integrate both forward and backward in time from starting point in
grid coordinates.

Integration is terminated when a trajectory reaches a domain boundary
or when it crosses into an already occupied cell in the StreamMask. The
resulting trajectory is None if it is shorter than `minlength`.
r   N)r   r   r   )r   r   r   )r   r   r   )r   r   _integrate_rk12r   r*   broadcast_arraysemptyr   )x0y0rh   r	   r
   stotalxy_trajr   xytr  rk   r   r   rg   re   s            r   rp   "_get_integrator.<locals>.integrate  s     b	!!"*<= !$88$RT=)%7%?%@BFA KF4R4y G $77""2*$RT<%7%?%@BFA KF12wGI&&w0@A!DD  "/ ! 		s   B9 9
CCTr   r   )r:   ri   r<   r=   r*   r-   sqrt)r_   r`   rk   re   rg   r   u_axv_axrp   r  r   r   s   ``````   @@@r   r/   r/     s     >>!QDAq 		q !D		q !DEEJJtqy419,-E	& 	& OR.1( (T r   c                       \ rS rSrSrg)r   i2  r   Nr   r   r   r   r   r   2  r   r   r   c                 Z   SU-  n[        SUR                  R                  -  SUR                  R                  -  S5      n	X-  n	U	n
SnU nUn/ n  UR                  R                  X5      (       a  UR                  X45        O[        eU" X5      u  nnU" XU-  -   XU-  -   5      u  nnX-  nU
U-  nU
S-  UU-   -  nU
S-  UU-   -  nUR                  R                  u  nn[        R                  " UU-
  US-
  -  UU-
  US-
  -  5      nUU:  a-  UU-  nUU-  n UR                  XU5        X-   U:  a   X4$ X-  nUS:X  a  U	n
O[        U	SU
-  UU-  S-  -  5      n
GM  ! [         a    U(       a  [        XU5      u  pX-  n X4$ [         a     X4$ f = f! [         a     X4$ f = f)a  
2nd-order Runge-Kutta algorithm with adaptive step size.

This method is also referred to as the improved Euler's method, or Heun's
method. This method is favored over higher-order methods because:

1. To get decent looking trajectories and to sample every mask cell
   on the trajectory we need a small timestep, so a lower order
   solver doesn't hurt us unless the data is *very* high resolution.
   In fact, for cases where the user inputs
   data smaller or of similar grid size to the mask grid, the higher
   order corrections are negligible because of the very fast linear
   interpolation used in `interpgrid`.

2. For high resolution input data (i.e. beyond the mask
   resolution), we must reduce the timestep. Therefore, an adaptive
   timestep is more suited to the problem as this would be very hard
   to judge automatically otherwise.

This integrator is about 1.5 - 2x as fast as RK4 and RK45 solvers (using
similar Python implementations) in most setups.
g~jth?r   皙?r   g      ?r   g333333?)r@   rj   r<   r=   ri   r   r2   r   _euler_stepr   r,   r*   rJ   r   r   )r	  r
  rk   frg   rh   r	   r
   maxerrormaxdsdsr  r   r   xyf_trajk1xk1yk2xk2ydx1dy1dx2dy2r=   r<   errors                             r   r  r  6  s   8 22H TYY\\!2		#4c:E	'E	BF	B	BH
	yy$$R,,)!!
 yHC3h#X6HC h3h3h#)$3h#)$B#)Q/#)Q1GH 8#IB#IB&&r/AB {Y&  LF A:BUD2IE)9c(AABBc   	 *81=> = # 	: =	$ %  s+   AE# F ##F
	FF
F*)F*c                 b   UR                   R                  u  p4U S   u  pVU" XV5      u  pxUS:X  a  [        R                  n	OUS:  a  XW* -  n	OUS-
  U-
  U-  n	US:X  a  [        R                  n
OUS:  a  Xh* -  n
OUS-
  U-
  U-  n
[	        X5      nU R                  XWU-  -   XhU-  -   45        X4$ )zBSimple Euler integration step that extends streamline to boundary.r   r   r   )ri   r,   r*   infr@   r2   )r  rk   r  r=   r<   r   r   cxcydsxdsyr  s               r   r  r    s    YY__FBb\FBrYFB	Qwff	a3hAv{b 	Qwff	a3hAv{b 	SBOORr'\2R<01<r   c                    [         R                  " U 5      u  p4[        U[         R                  5      (       ag  UR	                  [
        5      nUR	                  [
        5      n[         R                  " US-   SUS-
  5      n[         R                  " US-   SUS-
  5      nO6[        U5      n[        U5      nXTS-
  :X  a  UnOUS-   nXcS-
  :X  a  UnOUS-   nXU4   n	XU4   n
XU4   nXU4   nX-
  nX&-
  nU	SU-
  -  X-  -   nUSU-
  -  X-  -   nUSU-
  -  UU-  -   n[        U[         R                  5      (       d*  [         R                  R                  U5      (       a  [        eU$ )z0Fast 2D, linear interpolation on an integer gridr   r   )
r*   r,   r)   r+   r   r   r;   r-   	is_maskedr   )ar   r   NyNxrT   rU   xnyna00a01a10a11xtr   a0a1ais                     r   rL   rL     sY    XXa[FB"bjj!!IIcNIIcNWWQUArAv&WWQUArAv&GGa=BQBa=BQB
qD'C
rE(C
E(C
F)C	B	B	B#(	"B	B#(	"B	q2vb	 Bb"**%%55??2%%Ir   c              #   F  #    U u  pSnSnUS-
  nUS-
  nSu  pxSn	[        X!-  5       Ht  n
Xx4v   U	S:X  a  US-  nXu:  a	  US-  nSn	M!  M#  U	S:X  a  US-  nX:  a	  US-  nSn	M<  M>  U	S:X  a  US-  nXs::  a	  US-  nSn	MW  MY  U	S:X  d  Ma  US-  nX::  d  Mm  US-  nSn	Mv     g7f)	a  
Yield starting points for streamlines.

Trying points on the boundary first gives higher quality streamlines.
This algorithm starts with a point on the mask corner and spirals inward.
This algorithm is inefficient, but fast compared to rest of streamplot.
r   r   )r   r   rightupleftdownN)rM   )r,   r=   r<   xfirstyfirstxlastylastrT   rU   	directionis              r   r0   r0     s      FBFFFEFEDAI27^d
FAz
 	  $FAz
"	  & FA{!"	  & FA{!#	- s   BB!	B!B!)r   NNNNr   z-|>r  NNNg      @r   Tr  )!r   numpyr*   
matplotlibr%   r   r   r   matplotlib.colorscolorsr>   matplotlib.collectionscollectionsrQ   matplotlib.linesr   r    __all__r   r]   r   r   r   	Exceptionr   r   r/   
IndexErrorr   r  r  rL   r0   r   r   r   <module>rO     s   
   / / # - ! . CG=BHL4:"&	S GJ+.1Sl <% <%~7A 7At3 3l		 		) 	CL	* 	 DH/203`F2%P%$r   