KGRKJGETMRETU895U-589TY5MIGM5JGB5SDFESFREWTGR54TY
Server : Apache
System : Linux server112.speedpacket.com 3.10.0-962.3.2.lve1.5.36.el7.x86_64 #1 SMP Mon May 18 02:16:06 EDT 2020 x86_64
User : equistyl ( 1341)
PHP Version : 8.1.30
Disable Function : NONE
Directory :  /lib64/python2.7/site-packages/matplotlib/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib64/python2.7/site-packages/matplotlib/streamplot.pyc
�
r`]c
@ sLdZddlmZddlZddlZddljZddlj	Z
ddljZ
ddljZdgZdddddddddd�	Zd	efd
��YZdefd��YZd
efd��YZdefd��YZdefd��YZdefd��YZd�Zd�Zd�Zd�Zd�ZdS(s,
Streamline plotting for 2D vector fields.

i����(tdivisionNt
streamplotis-|>g�������?c-C s�t||�}t|�}t||�}|
dkrB|j}
n|dkrc|jjj�}n|dkrtj	d}ni}t
d|dd|
�}t|tj
�}|r�|j|jks�t�g}n||d<||d<t|tj
�r"|j|jkst�g|d<n||d<||d<|j|jksNt�|j|jksft�tjtj|��r�tjj|dtj|��}ntjtj|��r�tjj|dtj|��}nt||||�}g}xyt|j�D]h\}}|||fdkr	|j||�\}}|||�}|dk	rq|j|�qqq	q	W|r�|	dkr�tj|j�|j��}	n|dkr�tjtj	d	�}q�tj|�}ng}g}x|D]}tj|d�}tj|d
�}tj|d�|j|j} tj|d
�|j |j!}!tj"| |!g�j#dd
d�}"|j$tj%|"d |"d
g��tj&tj'tj(| �dtj(|!�d��}#tj)|#|#dd
�}$| |$|!|$f}%tj*| |$|$d!�tj*|!|$|$d!�f}&t|tj
�r�t+|||�d }'|dj$|'�|'|$|d<n|r�t+|||�d }(|j$|(�||	|(|$��|d<nt,j-|%|&d|
|�})|j.|)�|j|)�q�Wt/j0|d|
|�}*|rZ|*j1tj2|��|*j3|�|*j4|	�n|j5|*�|j6|j�|j�f|j�|j�ff�|j7dt8�tj9j:|�}+t;|*|+�},|,S(s'Draws streamlines of a vector flow.

    *x*, *y* : 1d arrays
        an *evenly spaced* grid.
    *u*, *v* : 2d arrays
        x and y-velocities. Number of rows should match length of y, and
        the number of columns should match x.
    *density* : float or 2-tuple
        Controls the closeness of streamlines. When `density = 1`, the domain
        is divided into a 25x25 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 [density_x, density_y].
    *linewidth* : numeric or 2d array
        vary linewidth when given a 2d array with the same shape as velocities.
    *color* : matplotlib color code, or 2d array
        Streamline color. When given an array with the same shape as
        velocities, *color* values are converted to colors using *cmap*.
    *cmap* : :class:`~matplotlib.colors.Colormap`
        Colormap used to plot streamlines and arrows. Only necessary when using
        an array input for *color*.
    *norm* : :class:`~matplotlib.colors.Normalize`
        Normalize object used to scale luminance data to 0, 1. If None, stretch
        (min, max) to (0, 1). Only necessary when *color* is an array.
    *arrowsize* : float
        Factor scale arrow size.
    *arrowstyle* : str
        Arrow style specification.
        See :class:`~matplotlib.patches.FancyArrowPatch`.
    *minlength* : float
        Minimum length of streamline in axes coordinates.

    Returns:

        *stream_container* : StreamplotSet
            Container object with attributes
                lines: `matplotlib.collections.LineCollection` of streamlines
                arrows: collection of `matplotlib.patches.FancyArrowPatch`
                        objects representing arrows half-way along stream
                        lines.
            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.

    slines.linewidtht
arrowstyletmutation_scalei
tcolort	linewidthtmaskis
image.cmapii����ig@t	transformttightN(<tGridt
StreamMaskt	DomainMaptNonet	transDatat
_get_linestcolor_cycletnextt
matplotlibtrcParamstdictt
isinstancetnptndarraytshapetAssertionErrortanytisnantmatarraytget_integratort_gen_starting_pointst	mask2gridtappendtmcolorst	normalizetmintmaxtcmtget_cmaptdxtx_origintdyty_origint	transposetreshapetextendthstacktcumsumtsqrttdifftsearchsortedtmeant
interpgridtpatchestFancyArrowPatcht	add_patchtmcollectionstLineCollectiont	set_arraytasarraytset_cmaptset_normtadd_collectiontupdate_datalimtautoscale_viewtTruetcollectionstPatchCollectiont
StreamplotSet(-taxestxtytutvtdensityRRtcmaptnormt	arrowsizeRt	minlengthRtgridRtdmaptline_kwtarrow_kwtuse_multicolor_linestline_colorst	integratettrajectoriestxmtymtxgtygtttstreamlinestarrowsttgxttgyttxttytpointststnt
arrow_tailt
arrow_headtline_widthstcolor_valuestptlctactstream_container((s;/usr/lib64/python2.7/site-packages/matplotlib/streamplot.pyRs�/	




$$!
!!$$64
		
	

7RDcB seZd�ZRS(cK s||_||_dS(N(tlinesR](tselfRmR]tkwargs((s;/usr/lib64/python2.7/site-packages/matplotlib/streamplot.pyt__init__�s	(t__name__t
__module__Rp(((s;/usr/lib64/python2.7/site-packages/matplotlib/streamplot.pyRD�sRcB sVeZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
RS(	sMap 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`.
    cC s�||_||_t|jd�|j|_t|jd�|j|_d|j|_d|j|_|j|j	|_
|j|j|_dS(Nig�?(
RORtfloattnxtx_grid2masktnyty_grid2masktx_mask2gridty_mask2gridtwidthtx_data2gridtheightty_data2grid(RnROR((s;/usr/lib64/python2.7/site-packages/matplotlib/streamplot.pyRp�s		cC s,t||jd�t||jd�fS(s;Return nearest space in mask-coords from given grid-coords.g�?(tintRuRw(Rntxityi((s;/usr/lib64/python2.7/site-packages/matplotlib/streamplot.pyt	grid2mask�scC s||j||jfS(N(RxRy(RnRWRX((s;/usr/lib64/python2.7/site-packages/matplotlib/streamplot.pyR�scC s||j||jfS(N(R{R}(Rntxdtyd((s;/usr/lib64/python2.7/site-packages/matplotlib/streamplot.pyt	data2grid�scC s/|j||�\}}|jj||�dS(N(R�Rt_start_trajectory(RnRYRZRWRX((s;/usr/lib64/python2.7/site-packages/matplotlib/streamplot.pytstart_trajectory�scC s.|j||�\}}||f|j_dS(N(R�Rt_current_xy(RnRYRZRWRX((s;/usr/lib64/python2.7/site-packages/matplotlib/streamplot.pytreset_start_point�scC sM|jj||�st�n|j||�\}}|jj||�dS(N(ROtwithin_gridtInvalidIndexErrorR�Rt_update_trajectory(RnRYRZRWRX((s;/usr/lib64/python2.7/site-packages/matplotlib/streamplot.pytupdate_trajectory�s	cC s|jj�dS(N(Rt_undo_trajectory(Rn((s;/usr/lib64/python2.7/site-packages/matplotlib/streamplot.pytundo_trajectory�s(RqRrt__doc__RpR�RR�R�R�R�R�(((s;/usr/lib64/python2.7/site-packages/matplotlib/streamplot.pyR�s	
						R	cB s/eZdZd�Zed��Zd�ZRS(s
Grid of data.cC sUt|j�dkr@|d}tj||�s7t�|}nt|j�dks[t�t|j�dkr�|dd�df}tj||j�s�t�|}nt|j�dks�t�t|�|_t|�|_|d|d|_|d|d|_	|d|_
|d|_|d|d|_|d|d|_
dS(Niiii����(tlenRRtallcloseRtTRtRvR'R)R(R*RzR|(RnRFRGtx_rowty_col((s;/usr/lib64/python2.7/site-packages/matplotlib/streamplot.pyRp�s$
		

cC s|j|jfS(N(RvRt(Rn((s;/usr/lib64/python2.7/site-packages/matplotlib/streamplot.pyRscC s<|dko;||jdko;|dko;||jdkS(s.Return True if point is a valid index of grid.ii(RtRv(RnRR�((s;/usr/lib64/python2.7/site-packages/matplotlib/streamplot.pyR�s(RqRrR�RptpropertyRR�(((s;/usr/lib64/python2.7/site-packages/matplotlib/streamplot.pyR	�s	R
cB s;eZdZd�Zd�Zd�Zd�Zd�ZRS(sIMask 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.
    cC s�tj|�r>|dks!t�td|�|_|_nFt|�dksVt�td|d�|_td|d�|_tj|j|jf�|_|jj	|_	d|_dS(Niiiii(RtisscalarRR~RtRvR�tzerost_maskRRR�(RnRJ((s;/usr/lib64/python2.7/site-packages/matplotlib/streamplot.pyRp'scG s|jj|�S(N(R�t__getitem__(Rntargs((s;/usr/lib64/python2.7/site-packages/matplotlib/streamplot.pyR�4scC sg|_|j||�dS(s%Start recording streamline trajectoryN(t_trajR�(RnRWRX((s;/usr/lib64/python2.7/site-packages/matplotlib/streamplot.pyR�7s	cC s+x$|jD]}|jj|d�q
WdS(s#Remove current trajectory from maskiN(R�R�t__setitem__(RnR[((s;/usr/lib64/python2.7/site-packages/matplotlib/streamplot.pyR�<scC ss|j||fkro|||fdkrf|jj||f�d|j||f<||f|_qot�ndS(s�Update current trajectory position in mask.

        If the new position has already been filled, raise `InvalidIndexError`.
        iiN(R�R�R R�R�(RnRWRX((s;/usr/lib64/python2.7/site-packages/matplotlib/streamplot.pyR�As(RqRrR�RpR�R�R�R�(((s;/usr/lib64/python2.7/site-packages/matplotlib/streamplot.pyR
s	
			R�cB seZRS((RqRr(((s;/usr/lib64/python2.7/site-packages/matplotlib/streamplot.pyR�OstTerminateTrajectorycB seZRS((RqRr(((s;/usr/lib64/python2.7/site-packages/matplotlib/streamplot.pyR�Ssc s��j���\����jj}��jj}tjj|d|d�����fd���fd������fd�}|S(Nic sjt�||�}|dkr*t��nd|}t�||�}t�||�}||||fS(Nig�?(R4R�(RR�tds_dttdt_dstuitvi(tspeedRHRI(s;/usr/lib64/python2.7/site-packages/matplotlib/streamplot.pytforward_timeds
c s!�||�\}}||fS(N((RR�tdxitdyi(R�(s;/usr/lib64/python2.7/site-packages/matplotlib/streamplot.pyt
backward_timemsc s��j||�t||���\}}}�j||�t||���\}}}||}|ddd�|d}	|ddd�|d}
|�kr�|	|
fS�j�dSdS(s�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`.
        Ni����i(R�t_integrate_rk12R�R�R(tx0ty0tsftxf_trajtyf_trajtsbtxb_trajtyb_trajtstotaltx_trajty_traj(R�RPR�RN(s;/usr/lib64/python2.7/site-packages/matplotlib/streamplot.pyRUqs


(R�RORtRvRRR0(RHRIRPRNtu_axtv_axRU((R�RPR�RNR�RHRIs;/usr/lib64/python2.7/site-packages/matplotlib/streamplot.pyRZs	cC s2d}td|jjd|jjd�}|}d}|}|}	g}
g}x�|jj||	�r$|
j|�|j|	�y>|||	�\}}
|||||	||
�\}}WnKtk
r�t|
|||�\}}
}||7}Pnt	k
r
PnX||}||
}|d||}|d|
|}|jj
\}}tj|||d|||d�}||kr�||7}|	|7}	y|j
||	�Wntk
r�PnX||dkr�Pn||7}n|dkr|}qSt|d|||d�}qSW||
|fS(sA2nd-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 both the RK4 and RK45
    solvers in most setups on my machine. I would recommend removing the
    other two to keep things simple.
    g�~j�t�h?g�?g�������?ig�?ig333333�?(R#RRtRvROR�R t
IndexErrort_euler_stepR�RRR0R�R�(R�R�RPtftmaxerrortmaxdstdsR�RR�R�R�tk1xtk1ytk2xtk2ytdx1tdy1tdx2tdy2RtRvterror((s;/usr/lib64/python2.7/site-packages/matplotlib/streamplot.pyR��sR&






+



	#c
C s	|jj\}}|d}|d}|||�\}}	|dkrStj}
n,|dkrm||}
n|d||}
|	dkr�tj}n,|	dkr�||	}n|d||	}t|
|�}|j|||�|j||	|�|||fS(sBSimple Euler integration step that extends streamline to boundary.i����ii(RORRtinfR#R (
R�R�RPR�RvRtRR�tcxtcytdsxtdsyR�((s;/usr/lib64/python2.7/site-packages/matplotlib/streamplot.pyR��s$

cC s�tj|�\}}t|tj�r�|jtj�}|jtj�}tj|dd|d�}tj|dd|d�}ndtj|�}tj|�}||dkr�|}n
|d}||dkr�|}n
|d}|||f}	|||f}
|||f}|||f}||}
||}|	d|
|
|
}|d|
||
}|d|||}t|tj�s�tjj|�r�t	�q�n|S(s0Fast 2D, linear interpolation on an integer gridiii(
RRRRtastypeR~tclipRt	is_maskedR�(taRR�tNytNxRFRGtxntynta00ta01ta10ta11txttytta0ta1tai((s;/usr/lib64/python2.7/site-packages/matplotlib/streamplot.pyR4s6 	
	


cc sN|\}}d}d}|d}|d}d\}}d}	d}
xt||�D]�}	||fV|
dkr�|d7}||krF|d8}d}
qFqU|
dkr�|d7}||krF|d8}d}
qFqU|
dkr|d8}||krF|d7}d}
qFqU|
dkrU|d8}||krF|d7}d}
qFqUqUWdS(	sYield 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.
    iitrighttuptlefttdownN(ii(txrange(RRvRttxfirsttyfirsttxlasttylastRFRGtit	direction((s;/usr/lib64/python2.7/site-packages/matplotlib/streamplot.pyR*s<









( R�t
__future__RtnumpyRRt
matplotlib.cmR%tmatplotlib.colorstcolorsR!tmatplotlib.collectionsRBR8tmatplotlib.patchesR5t__all__RRtobjectRDRR	R
t	ExceptionR�R�RR�R�R4R(((s;/usr/lib64/python2.7/site-packages/matplotlib/streamplot.pyt<module>s,		�
<)1	4	Y		(

Anon7 - 2021