Files
old-parkingkoncept/parkingkonceptvenv/lib/python3.7/site-packages/matplotlib/__pycache__/streamplot.cpython-37.pyc

221 lines
18 KiB
Plaintext
Raw Normal View History

2019-11-17 12:44:16 +01:00
B
U<>]<5D>V<00> @s<>dZddlZddlZddlmZddlmZddl m
Z ddl m ZddlmZdgZd d d<03>ZGd
d <0B>d e<13>ZGd d <0A>d e<13>ZGdd<0F>de<13>ZGdd<11>de<13>ZGdd<13>de<18>ZGdd<15>de<18>Zdd<17>Zdd<19>Zdd<1B>Zdd<1D>Zdd<1F>ZdS)!z,
Streamline plotting for 2D vector fields.
<EFBFBD>N<>
streamplot<EFBFBD><00>-|>皙<><E79A99><EFBFBD><EFBFBD><EFBFBD>?<3F>@<40>bothc5 Cszt||<02>}t|<05>}t||<13>}|dkr,tjj}| dkr:|j} |dkrL|j<07><08>}|dkr^t j
d}i}t | d|
d<04>}|dkr<>d|}t |<17><01>|dkr<>|d}t |tj<0F>}|r<>|j|jkr<>t d <09><01>g}tj<11>|<07>}n||d
<||d
<t |tj<0F><02>r|j|jk<03>rt d <0B><01>g|d <n||d <||d <||d <||d <|j|jk<03>sJ|j|jk<03>rRt d<0E><01>tj<11>|<03>}tj<11>|<04>}t|||| ||<11>}g}|dk<08>r<>xXt|j<10>D]J\}}|||fdk<02>r<>|<14>||<1D>\}}|||<1F>} | dk <09>r<>|<1B>| <20><00>q<>Wn<>tj|td<10><02><19>}!xl|!D]d\}"}#|j|"k<01>r(|j|jk<01>rPnn$|j|#k<01>rN|j|jk<01>s<>nt d<11>|"|#<23><02><01><01>q<>W|!dd<01>df|j8<|!dd<01>df|j8<x@|!D]8\}"}#|<14>|"|#<23>\}}|||<1F>} | dk <09>r<>|<1B>| <20><00>q<>W|<18>r&| dk<08>rt <20>!|<07>"<22>|<07>#<23><00>} |dk<08>rt$<24>%t j
d<00>}n
t$<24>%|<08>}g}$g}%<25>x<>|D<00>]<5D>} t<0E>&| d<00>}&t<0E>&| d<00>}'|j't<0E>&| <20><01>\}(})|(|j7}(|)|j7})t<0E>(|(|)g<02><01>)ddd<15>}*|$<24>*t<0E>+|*dd<14>|*dd<01>g<02><01>t<0E>,t<0E>-t<0E>.|(<28>t<0E>.|)<29><01><02>}+t<0E>/|+|+dd<00>},|(|,|)|,f}-t<0E>0|(|,|,d<00><00>t<0E>0|)|,|,d<00><00>f}.t |tj<0F><02>rft1||&|'<27>dd<14>}/|d <00>*|/<2F>|/|,|d <|<18>r<>t1||&|'<27>dd<14>}0|<19>|0<>|| |0|,<00><01>|d
<t2j3|-|.fd| i|<16><02>}1|<00>4|1<>|%<25>|1<><00>q6Wt5j6|$fd| i|<15><02>}2|j|j|jg|2j7j8dd<01><|j|j|jg|2j7j9dd<01><|<18>rN|2<>:tj<11>+|<19><01>|2<>;|<08>|2<><| <09>|<00>=|2<>|<00>><3E>t j?<3F>@|%<25>}3tA|2|3<>}4|4S)a<>
Draw streamlines of a vector flow.
Parameters
----------
x, y : 1D arrays
An evenly spaced grid.
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 stream lines. 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 : matplotlib color code, 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 : `~matplotlib.colors.Colormap`
Colormap used to plot streamlines and arrows. This is only used if
*color* is an array.
norm : `~matplotlib.colors.Normalize`
Normalize object used to scale luminance data to 0, 1. If ``None``,
stretch (min, max) to (0, 1). This is only used if *color* is an array.
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 : Nx2 array
Coordinates of starting points for the streamlines in data coordinates
(the same coordinates as the *x* and *y* arrays).
zorder : int
The zorder of the stream lines and arrows.
Artists with lower zorder values are drawn first.
maxlength : float
Maximum length of streamline in axes coordinates.
integration_direction : {'forward', 'backward', 'both'}
Integrate the streamline in forward, backward or both directions.
default is ``'both'``.
Returns
-------
stream_container : StreamplotSet
Container object with attributes
- ``lines``: `.LineCollection` of streamlines
- ``arrows``: `.PatchCollection` containing `.FancyArrowPatch`
objects representing the 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.
Nzlines.linewidth<74>
)<02>
arrowstyleZmutation_scale)r<00>forward<72>backwardzTIntegration direction '%s' not recognised. Expected 'both', 'forward' or 'backward'.rg@z7If 'color' is given, must have the shape of 'Grid(x,y)'<27>colorz;If 'linewidth' is given, must have the shape of 'Grid(x,y)'<27> linewidth<74>zorderz('u' and 'v' must be of shape 'Grid(x,y)'r)Zdtypez2Starting point ({}, {}) outside of data boundariesrz
image.cmap<61><70><EFBFBD><EFBFBD><EFBFBD><EFBFBD><00> transform)B<>Grid<69>
StreamMask<EFBFBD> DomainMap<61>mlinesZLine2DrZ transDataZ
_get_linesZget_next_color<6F>
matplotlibZrcParams<6D>dict<63>
ValueError<EFBFBD>
isinstance<EFBFBD>np<6E>ndarray<61>shape<70>maZmasked_invalid<69>get_integrator<6F>_gen_starting_points<74> mask2grid<69>appendZ
asanyarray<EFBFBD>float<61>copy<70>x_origin<69>width<74>y_origin<69>height<68>format<61> data2grid<69>mcolorsZ Normalize<7A>min<69>max<61>cmZget_cmap<61>array<61> grid2dataZ transposeZreshape<70>extendZhstackZcumsum<75>hypot<6F>diffZ searchsortedZmean<61>
interpgrid<EFBFBD>patchesZFancyArrowPatchZ add_patch<63> mcollectionsZLineCollectionZ sticky_edges<65>x<>yZ set_arrayZset_cmapZset_normZadd_collectionZautoscale_view<65> collectionsZPatchCollection<6F> StreamplotSet)5Zaxesr6r7<00>u<>v<>densityr r ZcmapZnormZ arrowsizer <00> minlengthrrZ start_points<74> maxlength<74>integration_direction<6F>grid<69>mask<73>dmapZline_kwZarrow_kwZerrstrZuse_multicolor_linesZ line_colors<72> integrateZ trajectories<65>xm<78>ym<79>xg<78>yg<79>tZsp2<70>xsZysZ streamlines<65>arrowsZtgxZtgyZtx<74>tyZpoints<74>s<>nZ
arrow_tailZ
arrow_headZ line_widthsZ color_values<65>p<>lc<6C>acZstream_container<65>rQ<00>=/tmp/pip-install-i8dhxrtk/matplotlib/matplotlib/streamplot.pyrs<>C



  
   


&$






$, 




 
c@seZdZdd<02>ZdS)r9cKs||_||_dS)N)<02>linesrJ)<04>selfrSrJ<00>kwargsrQrQrR<00>__init__<5F>szStreamplotSet.__init__N)<04>__name__<5F>
__module__<EFBFBD> __qualname__rVrQrQrQrRr9<00>sr9c@sXeZdZdZdd<03>Zdd<05>Zdd<07>Zdd <09>Zd
d <0B>Zd d <0A>Z dd<0F>Z
dd<11>Z dd<13>Z dS)raMap 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`.
cCsd||_||_|jd|j|_|jd|j|_d|j|_d|j|_d|j|_ d|j
|_ dS)Nrg<00>?) r@rA<00>nx<6E> x_grid2mask<73>ny<6E> y_grid2mask<73> x_mask2grid<69> y_mask2grid<69>dx<64> x_data2grid<69>dy<64> y_data2grid)rTr@rArQrQrRrVs   zDomainMap.__init__cCs$t||jd<00>t||jd<00>fS)z;Return nearest space in mask-coords from given grid-coords.g<00>?)<03>intr[r])rT<00>xi<78>yirQrQrR<00> grid2maskszDomainMap.grid2maskcCs||j||jfS)N)r^r_)rTrDrErQrQrRr szDomainMap.mask2gridcCs||j||jfS)N)rarc)rTZxdZydrQrQrRr)szDomainMap.data2gridcCs||j||jfS)N)rarc)rTrFrGrQrQrRr/ szDomainMap.grid2datacCs"|<00>||<02>\}}|j<01>||<04>dS)N)rgrA<00>_start_trajectory)rTrFrGrDrErQrQrR<00>start_trajectory#szDomainMap.start_trajectorycCs |<00>||<02>\}}||f|j_dS)N)rgrA<00> _current_xy)rTrFrGrDrErQrQrR<00>reset_start_point'szDomainMap.reset_start_pointcCs4|j<00>||<02>st<02>|<00>||<02>\}}|j<04>||<04>dS)N)r@<00> within_grid<69>InvalidIndexErrorrgrA<00>_update_trajectory)rTrFrGrDrErQrQrR<00>update_trajectory+szDomainMap.update_trajectorycCs|j<00><01>dS)N)rA<00>_undo_trajectory)rTrQrQrR<00>undo_trajectory1szDomainMap.undo_trajectoryN) rWrXrY<00>__doc__rVrgr r)r/rirkrorqrQrQrQrRr<00>s rc@s,eZdZdZdd<03>Zedd<05><00>Zdd<07>ZdS) rz Grid of data.cCsV|jdkr n<|jdkr@|ddd<00>f}t<01>||<01>s:td<04><01>|}ntd<05><01>|jdkrTn>|jdkr<>|dd<00>df}t<01>||j<04>s<>td<06><01>|}ntd<07><01>t|<01>|_t|<02>|_|d|d|_|d|d|_ |d|_
|d|_ |d|d|_ |d|d|_ t<01>t<01>|<01>|j |jd<00><02>s*td <09><01>t<01>t<01>|<02>|j |jd<00><02>sRtd
<EFBFBD><01>dS) NrrrzThe 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 dimensionsrz!'x' values must be equally spacedz!'y' values must be equally spaced)<0F>ndimrZallcloser<00>T<>lenrZr\r`rbr$r&r%r'r2)rTr6r7Zx_rowZy_colrQrQrRrV7s8

 





  z Grid.__init__cCs |j|jfS)N)r\rZ)rTrQrQrRr^sz
Grid.shapecCs,|dko*||jdko*|dko*||jdkS)z.Return True if point is a valid index of grid.rr)rZr\)rTrerfrQrQrRrlbszGrid.within_gridN)rWrXrYrrrV<00>propertyrrlrQrQrQrRr5s' rc@s8eZdZdZdd<03>Zdd<05>Zdd<07>Zdd <09>Zd
d <0B>Zd S) raIMask 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.
cCs<>y"dt<00>|d<02><00>t<03>\|_|_Wntk
r>td<03><01>YnX|jdksT|jdkr\td<05><01>t<00>|j|jf<02>|_|jj |_ d|_
dS)N<>rz,'density' must be a scalar or be of length 2rz'density' must be positive) rZ broadcast_to<74>astyperdrZr\r<00>zeros<6F>_maskrrj)rTr<rQrQrRrVrs"
zStreamMask.__init__cGs |jj|<01>S)N)rz<00> __getitem__)rT<00>argsrQrQrRr{~szStreamMask.__getitem__cCsg|_|<00>||<02>dS)z%Start recording streamline trajectoryN)<02>_trajrn)rTrDrErQrQrRrh<00>szStreamMask._start_trajectorycCs"x|jD]}|j<01>|d<01>qWdS)z#Remove current trajectory from maskrN)r}rz<00> __setitem__)rTrHrQrQrRrp<00>s zStreamMask._undo_trajectorycCsP|j||fkrL|||fdkrH|j<01>||f<02>d|j||f<||f|_nt<04>dS)z<>Update current trajectory position in mask.
If the new position has already been filled, raise `InvalidIndexError`.
rrN)rjr}r!rzrm)rTrDrErQrQrRrn<00>s  zStreamMask._update_trajectoryN) rWrXrYrrrVr{rhrprnrQrQrQrRris  rc@s eZdZdS)rmN)rWrXrYrQrQrQrRrm<00>srmc@s eZdZdS)<02>TerminateTrajectoryN)rWrXrYrQrQrQrRr<00>src sv<00><01><00><07><08>\<02><07><08><07>jj}<06><08>jj}tj<05>|d|d<00><01><06><06><07>fdd<03><08><02>fdd<05><08><00><00><01><02><03><04>fdd<07>}|S)NrcsJt<00>||<01>}|dkrt<01><00>d|}t<00>||<01>}t<00>||<01>}||||fS)Nrg<00>?)r3r)rerfZds_dtZdt_ds<64>ui<75>vi)<03>speedr:r;rQrR<00> forward_time<6D>s   z$get_integrator.<locals>.forward_timecs<00>||<01>\}}| | fS)NrQ)rerfZdxiZdyi)r<>rQrR<00> backward_time<6D>sz%get_integrator.<locals>.backward_timecsdgg}}}y<10><01>||<01>Wntk
r4dSX<00>dkr<>t||<01><01><00><04>\}}}||7}||ddd<04>7}||ddd<04>7}<04>dkr<><72><01>||<01>t||<01><01><02><04>\}}}t|<03>dkr<>|dd<02>}|dd<02>}||7}||7}||7}|<02>kr<>||fS<00><01><05>dSdS)a<>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`.
gN)rr r)rr
rr)rirm<00>_integrate_rk12rkrurq)<08>x0<78>y0<79>stotalZx_trajZy_trajrL<00>xt<78>yt)r<>rBr<>r?r>r=rQrRrC<00>s.     z!get_integrator.<locals>.integrate)r)r@rZr\rr<00>sqrt) r:r;rBr=r>r?Zu_axZv_axrCrQ) r<>rBr<>r?r>r=r<>r:r;rRr<00>s   'rcCs<>d}td|jjd|jjd<03>}|}d}|} |}
g} g} <0C>x~|j<04>| |
<EFBFBD><02>r<>| <0B>| <09>| <0C>|
<EFBFBD>y0|| |
<EFBFBD>\} }|| || |
||<00>\}}WnFtk
r<EFBFBD>t| | ||<03>\}} } ||7}PYnt k
r<EFBFBD>PYnX|| }||}|d| |}|d||}|jj
\}}t <0B> ||||||<00>}||k<00>r<>| |7} |
|7}
y|<02> | |
<EFBFBD>Wntk
<EFBFBD>rrPYnX|||k<04>r<>P||7}|dk<02>r<>|}q<t|d|||d<00>}q<W|| | fS)aA2nd-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<EFBFBD>h?g<00>?g<><67><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>?rg<00>?g333333<33>?)r+rArZr\r@rlr!<00>
IndexError<EFBFBD> _euler_steprrrr1rorm)r<>r<>rB<00>fr>ZmaxerrorZmaxds<64>dsr<73>rerf<00>xf_traj<61>yf_trajZk1xZk1yZk2xZk2yZdx1Zdy1Zdx2Zdy2rZr\<00>errorrQrQrRr<><00>sR

  

r<>c Cs<>|jj\}}|d}|d}|||<07>\}} |dkr:tj}
n$|dkrN|| }
n|d||}
| dkrntj} n$| dkr<>|| } n|d|| } t|
| <0B>} |<00>||| <00>|<01>|| | <00>| ||fS)zBSimple Euler integration step that extends streamline to boundary.rrr)r@rr<00>infr+r!) r<>r<>rBr<>r\rZrerfZcx<63>cyZdsxZdsyr<79>rQrQrRr<>>s$   
r<>cCs@t<00>|<00>\}}t|tj<03>r\|<01>t<05>}|<02>t<05>}t<00>|dd|d<00>}t<00>|dd|d<00>}nDt|<01>}t|<02>}||dkr~|}n|d}||dkr<>|}n|d}|||f} |||f}
|||f} |||f} ||} ||}| d| |
| }| d| | | }|d|||}t|tj<03><02>s<tj<07>|<11><01>r<t <09>|S)z0Fast 2D, linear interpolation on an integer gridrr)
rrrrrxrdZcliprZ is_maskedr)<12>arerfZNyZNxr6r7ZxnZynZa00Za01Za10Za11r<31>r<>Za0Za1ZairQrQrRr3Ys6 

      r3c cs<>|\}}d}d}|d}|d}d\}}d} x<>t||<00>D]<5D>}
||fV| dkrn|d7}||kr<>|d8}d} q:| dkr<>|d7}||kr<>|d8}d} q:| dkr<>|d8}||kr<>|d7}d} q:| dkr:|d8}||kr:|d7}d} q:WdS) aYield 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.
rr)rr<00>rightZup<75>leftZdownN)<01>range) rr\rZZxfirstZyfirstZxlastZylastr6r7<00> direction<6F>irQrQrRr<00>s:
r) rNNNNrrrNNNrr) rrZnumpyrrZ matplotlib.cmr-Zmatplotlib.colors<72>colorsr*Zmatplotlib.collectionsr8r5Zmatplotlib.linesrSrZmatplotlib.patchesr4<00>__all__r<00>objectr9rrr<00> Exceptionrmrrr<>r<>r3rrQrQrQrR<00><module>s0     
W
?40AY(