Files
intellecton/venv/lib/python3.12/site-packages/matplotlib/__pycache__/streamplot.cpython-312.pyc
T

279 lines
30 KiB
Plaintext
Raw Normal View History

Ë
†RjË]ãódZddlZddlZddlmZmZmZddlm Z
ddl m Z
ddlmZdgZ ddZGdd«ZGdd «ZGd
d «ZGd d
«ZGdde«ZGdde«ZdZGdde«ZddZdZdZdZ y)z,
Streamline plotting for 2D vector fields.
éN)Ú_apiÚcmÚpatchesÚ
streamplotc ó
t||«}t|«}t||«}|tjj
}|
|j }
||jj«}|tjd}i}t| d|
z¬«}tjgd¢|¬«|dk(r|dz}t|tj «}|rG|j"|j"k7r t%d «gg}tj&j)|«}n
||d
<||d
<t|tj «r*|j"|j"k7r t%d «g|d <n
||d <||d <||d
<||d
<|j"|j"k7s|j"|j"k7r t%d«tj&j)|«}tj&j)|«}t+|||| ||«}g}|€]t-|j"«D]C\}}|||fdk(sŒ|j/||«\}}||||«} | €Œ3|j1| «ŒEn]tj2|t4¬«j7«}!|!D]t\}"}#|j8|"cxkr|j8|j:zkr2nn/|j<|#cxkr|j<|j>zkrŒbnt%d|"d|#d«|!dddfxx|j8zcc<|!dddfxx|j<zcc<|!D]€\}"}#|jA|"|#«\}}tjB|d|jDdz
«}tjB|d|jFdz
«}||||«} | €Œp|j1| «Œ‚|rI| €2tIjJ|jM«|jO««} tQjR|«}g}$g}%|D]0} | jT\}&}'|jW|&|'«\}(})|(|j8z
}(|)|j<z
})t|tj «s|rUtjX|(|)g«j[ddd«}*|$j]tj^|*dd|*ddg««n(tjX|(|)g«}*|$j1|*«tj`tjbtjd|(«tjd|)«««}+tjf|+|+ddz «},|(|,|)|,f}-tjh|(|,|,dz«tjh|)|,|,dz«f}.t|tj «r,tk||&|'«dd}/|d j]|/«|/|,|d <|r5tk||&|'«dd}0j1|0«|| |0|,««|d
<tmjn|-|.fd|
i|¤Ž}1|%j1|1«Œ3tqjr|$fd|
i|¤Ž}2|j8|j8|j:zg|2jtjvdd|j<|j<|j>zg|2jtjxdd|rP|2j{tj&j_««|2j}|«|2j| «|j|2«tqj|%«}3|%D]}1|j…|1«Œ|j‡«t‰|2|3«}4|4S)
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.
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.
Nzlines.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) gridr)ÚdtypezStarting point (z, z) outside of data boundariesééÿÿÿÿéÚ transform)EÚGridÚ
StreamMaskÚ DomainMapÚmlinesÚLine2DrÚ transDataÚ
_get_linesÚget_next_colorÚmplÚrcParamsÚdictrÚ
check_in_listÚ
isinstanceÚnpÚndarrayÚshapeÚ
ValueErrorÚ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Ú searchsortedÚmeanÚ
interpgridrÚFancyArrowPatchÚ mcollectionsÚLineCollectionÚ sticky_edgesÚyÚ set_arrayÚset_cmapÚset_normÚadd_collectionÚPatchCollectionÚ add_patchÚautoscale_viewÚ
StreamplotSet)5ÚaxesrNrOÚdensityrrÚcmapÚnormÚ arrowsizer Ú minlengthrrÚ start_pointsÚ maxlengthrÚbroken_streamlinesÚgridÚmaskÚdmapÚline_kwÚarrow_kwÚuse_multicolor_linesÚ line_colorsÚ integrateÚ trajectoriesÚxmÚymÚxgÚygÚsp2ÚxsÚysÚ streamlinesÚarrowsÚtgxÚtgyÚtxÚtyÚpointsÚ
arrow_tailÚ
arrow_headÚ line_widthsÚ color_valuesÚlcÚacÚstream_containers5 úX/home/antigravity/intellecton/venv/lib/python3.12/site-packages/matplotlib/streamplot.pyrrôR 1‹:€DÜ  €DÜ T˜4Ó €Dà
€~Ü×ðÐØ—N‘Nˆ à €}Ø×àÐÜ—L‘LÐ!2Ñ3ˆ à€Gܘz¸"¸y¹.ÔI€Hä×ÑÒ6Ø-BõDð ÒR‰ˆ ä% e¬R¯Z©ZÓÙØ ;‰;˜$Ÿ*™*Ò ð
 Ü×$ UÓ+‰à ˆÑØÑä)œRŸZ™ZÔ ?‰?˜dŸj™jÒ ð
 Òà ÑØ )ˆÑà€GˆHÑØ€HˆXÑð ‡ww$—*‘*Ò §¡¨4¯:©:Ò 5ÜÐ
×јQÓ€AÜ
×јQÓ€Aä  1 d¨I°yØ 5ó7€Ið€LØÐÜ*¨4¯:©:Ó +‰FˆBØF‰|˜qÓ ØŸ¨¨BÓ/˜b "Ð&8Ó9Ø ×Õ m‰m˜L´Ôðò 4‰FˆBØ—M‘M E¨4¯=©=¸4¿:¹:Ñ+EÕ—MM F¨4¯=©=¸4¿;¹;Ñ+FÕ Ð#3°B°4°r¸"¸ð>3ð"3ó ŠAˆqˆD T—]" Ø ŠAˆqˆD T—]" àò '‰FˆBØ—^^ Ó+‰FˆBô
˜˜Q §¡¨!¡ Ó,ˆBܘ˜Q §¡¨!¡ Ó,ˆ˜"˜bÐ"4Ó5ˆ‰}Ø×#  Ø ˆ×$ U§Y¡Y£[°%·)±)³+Ó>ˆDܘtÓà€KØ
€FØ
ó!ˆØ—3‘3‰ˆˆSà  SÓ)‰ˆˆBØ
ˆdm‰mшØ
ˆdm‰mшô §¡Ô ,Ñ0DÜ—\‘\ 2 r +×3°B¸¸1Ó=ˆFØ × Ñ œrŸy™y¨&°°"¨+°v¸a¸b°zÐ)BÓ —\‘\ 2 r (Ó+ˆ × Ñ ˜ 
I‰I”b—hhœrŸw™w r{¬B¯G©G°B«KÓ Ü O‰O˜A˜q ™u r™zÓ Ø˜‘e˜R ™U
Ü—g‘g˜b  1 q¡5˜kÓ*¬B¯G©G°B°q¸¸Q¹°KÓ,@Ð
ä §¡Ô $ Y°°SÓ9¸#¸2Ð>ˆ  × Ô 4Ø$/°¡NˆH Ü% e¨S°#Ó6°s¸Ð;ˆLØ × Ñ ˜|Ô ,Ù $¡T¨,°q©/Ó%:Ó ;ˆH ä × ˜
ñ
EØ.7ð
EØ;Cñ
Eˆà
ðC!ôF
× $Ñ $Øñ

5Ø,3ñ
5€Bà ŸM™M¨4¯=©=¸4¿:¹:Ñ+EÐF€B‡OÑ‘aÐØ ŸM™M¨4¯=©=¸4¿;¹;Ñ+FÐG€B‡OÑ‘aÐÙØ
”R—U‘U—\‘\ +Ó
Ø
Ø×јÔä × %Ñ % fÓ -€Bà
òˆØ ðð ×ÑÔÜ$ R¨ÓØ ÐócóeZdZdZy)rWcó ||_||_y©N)Úlinesru)ÚselfrŠrus r…Ú__init__zStreamplotSet.__init__ûs؈Œ
؈ r†N)Ú__name__Ú
__module__Ú __qualname__rŒ©r†r…rWrWùsór†rWcóJeZdZdZdZdZdZdZdZd dZ dZ
d d „Z d
Z y )
ra
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óP||_||_|jdz
|jdz
z |_|jdz
|jdz
z |_d|jz |_d|j
z |_d|jz |_ d|jz |_ y)Nrçð?) rcrdr7Ú x_grid2maskr8Ú y_grid2maskÚ x_mask2gridÚ y_mask2gridÚdxÚ x_data2gridÚdyÚ y_data2grid)rrcrds r…zDomainMap.__init__s؈Œ ؈Œ à ŸG™G a™K¨D¯G©G°a©KÑÔØ ŸG™G a™K¨D¯G©G°a©KÑÔà × 0Ñ 0ÑÔØ × 0Ñ 0ÑÔà §¡™<ˆÔØ §¡™<ˆÕr†cóbt||jz«t||jz«fS)z;Return nearest space in mask-coords from given grid-coords.)Úroundr”r•©rÚxiÚyis r…Ú grid2maskzDomainMap.grid2mask#s-äR˜$×+¬U°2¸×8HÑ8HÑ3HÓ-IÐIr†có>||jz||jzfSr‰)rr—)rrlrms r…r,zDomainMap.mask2grid'ó#ØD×$ b¨4×+;Ñ+;Ñ&;Ð;r†có>||jz||jzfSr‰©r™r)rÚxdÚyds r…r5zDomainMap.data2grid*r†có>||jz ||jz fSr‰)rrnros r…r?zDomainMap.grid2data-r†cóh|j||«\}}|jj|||«yr‰)rdÚ_start_trajectory©rrnrorbrlrms r…Ústart_trajectoryzDomainMap.start_trajectory0s-Ø  '‰ˆˆBØ ×# Ð,>Õ?r†cóT|j||«\}}||f|j_yr‰)rdÚ _current_xy)rrnrorlrms r…Úreset_start_pointzDomainMap.reset_start_point4s&Ø  '‰ˆˆBØ!# R ˆ ‰ Õr†có¬|jj||«st|j||«\}}|jj |||«yr‰)rcÚ within_gridÚInvalidIndexErrorr¡rdÚ_update_trajectoryr«s r…Úupdate_trajectoryzDomainMap.update_trajectory8sGØy‰y×$ R¨Ô   BÓ'‰ˆˆBØ ×$ Ð-?Õ@r†có8|jj«yr‰)rdÚ_undo_trajectory©rs r…Úundo_trajectoryzDomainMap.undo_trajectory>sØ ×$r†T)
rrÚ__doc__rŒr,r5r?r´r¸rr†r…rrs7ñò$ Jò@òAó %r†rcó,eZdZdZdZed«ZdZy)rz
Grid of data.có¦tj|«dk(rnLtj|«dk(r)|d}tj||«s td«|}n td«tj|«dk(rnatj|«dk(r>tj|«}|d}tj||«s td«|}n td«tj
|«dkDj
«s td«tj
|«dkDj
«s td «t|«|_t|«|_ |d|dz
|_
|d|dz
|_ |d|_ |d|_
|d
|dz
|_|d
|dz
|_tjtj
|«|j|jdz
z «s td «tjtj
|«|j|jdz
z «s td «y)
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 dimensionsz'x' must be strictly increasingz'y' must be strictly increasingrz!'x' values must be equally spacedz!'y' values must be equally spaced)r$ÚndimÚallcloser'r@rFÚallÚlenr7r8r˜r1r3r2r4)rrNrOÚx_rowÚytÚy_cols r…z
Grid.__init__Dä
7‰71:˜Š?Ø Ü
W‰WQZ˜1Š_ØaDˆEÜ—;‘;˜u aÔ Ð!@Ó‰AäÐ
7‰71:˜Š?Ø Ü
W‰WQ‹Z˜1Š_ܘa“ˆBØq‘EˆEÜ—;‘;˜u bÔ Ð!CÓ‰AäÐ ˜
˜Q×Ð ˜
˜Q×Ð a“&ˆŒÜa“&ˆŒàA‘$˜˜1™‘+ˆŒØA‘$˜˜1™‘+ˆŒà˜!™ˆŒ
ؘ!™ˆŒ
àrU˜Q˜q™T\ˆŒ
ؘ‘e˜a ™d‘lˆŒ ä{‰{œ2Ÿ7™7 1: t§z¡z°T·W±W¸q±[Ñ'AÔÐ {‰{œ2Ÿ7™7 1: t§{¡{°d·g±gÀ±kÑ'BÔÐ Dr†có2|j|jfSr‰)r8r7s r…r&z
Grid.shapeqsàw‰w˜ŸÐÐr†cózd|cxkxr|jdz
kncxrd|cxkxr|jdz
kScS)z9Return whether (*xi*, *yi*) is a valid index of the grid.rr)r7r8s r…zGrid.within_gridus9ð%˜$Ÿ'™' A™+Ô@¨!¨rÖ*@°T·W±W¸q±[Ñ*@Ð@Ñ*@Ð@r†N)rrÚpropertyr&rr†r…rrBs&Ùò+BðZñ óð óAr†rcó2eZdZdZdZdZddZdZddZy) raN
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ó¨ dtj|d«zjt«\|_|_|jdks|j
dkr t
d«tj|j
|jf«|_|jj|_ d|_
y#t $r}t
d«|d}~wwxYw)rz,'density' must be a scalar or be of length 2rz'density' must be positive) r$Ú broadcast_toÚastypeÚintr7r8r'ÚzerosÚ_maskr&)rr[Úerrs r…zStreamMask.__init__†ð +Ø "¤R§_¡_°W¸aÓ%@Ñ @×Ó ˆDŒGT”Wð 7‰7QŠ;˜$Ÿ'™' Aš+ÜÐ —X‘X˜tŸw™w¨¯©ÐŒ
Ø—ZZ×%ˆŒ
àˆÕøôòð"Ø'*ð
+ûð +ús9B7Â7 Cà C à Ccó |j|Sr‰))rÚargss r…Ú __getitem__zStreamMask.__getitem__“sØz‰z˜$ÑÐr†có8g|_|j|||«y)z%Start recording streamline trajectoryN)Ú_trajr³©rrlrmrbs r…zStreamMask._start_trajectorysàˆŒ
Ø ×Ñ  BÐ(:Õ;r†cóD|jD]}d|j|<Œy)z#Remove current trajectory from maskrN))rrps r…zStreamMask._undo_trajectorys"àò ˆA؈DJ‰JqŠMñ r†có¼|j||fk7rK|||fdk(r8|jj||f«d|j||f<||f|_y|rtyy)
Update current trajectory position in mask.
If the new position has already been filled, raise `InvalidIndexError`.
rrN)r-s r…zStreamMask._update_trajectory skð × Ñ   B˜ B˜F‰|˜ Ø
×! 2 r +Ø%&
˜2˜r˜"Ø$&¨ 8Õ áð (r†Nr¹) rrrr†r…rr|s ñò  ò ó
ô
r†rcó eZdZy)rrrr†r…²óØr†có eZdZy)ÚTerminateTrajectoryNrÙrr†r…r†có2‡ ‡
j«\ŠŠjjdz
z }jjdz
z }tj
j
|dz|dzz«Š ˆˆ ˆˆfdŠ
ˆ
fdŠ dˆ ˆˆ
ˆˆˆfd„ }|S)NrrcóÒjj||«stt||«}|dk(r
t «d|z }t||«}t‰ ||«}||z||zfS)Nrr“)rcÚ OutOfBoundsrI)
r Úds_dtÚdt_dsÚuiÚvireÚspeedrYrZs
€€€€r…Ú forward_timez%_get_integrator.<locals>.forward_timeÇssø€Øy‰y×$ R¨ÔРܘ5 " )ˆØ AŠ:Ü U
ˆÜ
˜˜2˜
"ˆÜ
˜˜2˜
"ˆØE‰z˜2 ™:Ð%r†có(||«\}}| | fSr‰r)r ÚdxiÚdyirås €r…Ú
backward_timez&_get_integrator.<locals>.backward_timeÒs!ø€Ù  '‰ˆˆˆtcTˆr†códg}} j|||«
dvr#t|| |«\}}||z
}||dddz
}
dvr2‰j||«t||‰ ‰ |«\}}||z
}||ddz
}| kDr,t j
|t j d««dSj«y#t$rYywxYw) 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)r r
r)r r r)rrr)Ú_integrate_rk12r¯r$Úbroadcast_arraysÚemptyr¸)
Úx0Úy0rbÚstotalÚxy_trajr{Úxytrérerrar_s
€€€€€€r…rjz"_get_integrator.<locals>.integrateÖsø€ð˜bˆð Ø × ! " bÐ*<Ô  !Ð$8Ñ $ ¨T°=À)Ø%7ó9‰FˆAˆsà a‰Kˆ s™4˜R˜4‘yÑ ˆ Ð$7Ñ × " 2  $ ¨T°<ÀØ%7ó9‰FˆAˆ a‰Kˆ s˜1˜2 ˆ  Ü×& w´·±¸Ó0@ÓAÀ!Ñ × Ñ Ô øô' Ùð úsB9Â9 CÃC)r5rcr7r8r$r(Úsqrt) rYrZrer_rarÚu_axÚv_axrjs `````` @@@r…r*r*½s†ÿø€ð >‰>˜!˜ D€A€qð
— ‘ — ˜qÑ Ñ !€DØ — ‘ — ˜qÑ Ñ !€DÜ E‰EJ‰Jt˜qy 4¨1¡9Ñ -€E÷ ÷#ò#ðJ Ðr†có eZdZy)NrÙrr†r…þr†cóHd}td|jjz d|jjz d«}|}d} |}
|} g} |jj |
| «r| j
|
| f«nt||
| «\}
}||
||
zz| ||zz«\}}||
z}||z}|dz|
|zz}|dz||zz}|jj\}}tj||z
|dz
z ||z
|dz
z «}||kr0|
|z
}
| |z
} |j|
| |«| |z|kDr | | fS| |z
} |dk(r|}nt|d|z||z dzz«}Œ#t$r| rt| ||«\}} | |z
} Y| | fSt$rY| | fSwxYw#t$rY| | fSwxYw)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