-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Streamplot ignores rightmost column and topmost row of velocity data #11452
Comments
The interpolation (in the case of streamplot) might be failing because of fewer number of grid values specified (the V component changes sign and only 3 points are used to capture this change). If I increase the number of points to 9 (adding evenly spaced values) then the result seems to be correct... import numpy as np x = np.linspace(-1, 1, 9) U = np.array([[.2, .2, .2, .2, .2, .2, .2, .2, .2], plt.streamplot(x, y, U, V) |
A streamline is defined as the integral of the crossstream velocity, so I wouldn’t be surprised that there are edge effects for a digital representation. If you need a smoother stream plot interpolate the data first. |
pharshalp, your example shows the same faulty streamplot. Per definition, tangents to streamlines are the velocity. Look at the top, second from the right. There are about 100 degrees between the tangent and the velocity. The integration is simply wrong for the top and the right. Making it larger just makes the faulty domain smaller, but it does not make it right. jklymak, if the tangent to the streamline does not line up with the velocity, the streamline is wrong. No maybe, no "would not be surprised", just wrong. To make the point stronger: the streamlines are perfect on the left and at the bottom and anywhere but the top and right side. As for the remaining suggestions: 1 cell (2x2 points) defines a unique interpolated velocity field that can be integrated on a cell by cell base, so even for a single cell. matplotlib uses only the bottom left value when using a single cell. It ignores to top and right. Proposed issue: somewhere in the code an index goes to number of cells instead of number of nodes, which is cells+1. It is a faulty loop or indexing problem on the upper limit of the horizontal and the vertical limit. FYI, Wolfram mathematica shows how to do it right, even on a single cell. |
Any finite representation will have gridscale inaccuracies compared to a formal definition. If you have a proposed algorithm that deals with those inaccuracies in a different way than the matplotlib implementation of streamline a pull request would receive due attention. |
OK, I'll look into it. Might take a while till I find the time. Still
believe it's a simple indexing issue rather than the overall algorithm.
…On Mon, Jun 18, 2018 at 7:50 AM Jody Klymak ***@***.***> wrote:
Any finite representation will have gridscale inaccuracies compared to a
formal definition. If you have a proposed algorithm that deals with those
inaccuracies in a different way than the matplotlib implementation of
streamline a pull request would receive due attention.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#11452 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/APJMlCb6QGWEPqt-_NiJLe2PozHrWqW7ks5t975QgaJpZM4Uq77n>
.
|
Link to potential fix: #11455 |
closed by #11455 |
Bug report
Bug summary
streamplot ignores the rightmost column (and topmost row) in U and V and replaces them by a copy of the second to last column (row). This yields wrong stream lines in the rightmost column and topmost row of cells. The issue is most noticeable on coarse grids. (see example plots)
Code for reproduction
Actual outcome
The first image uses just 2 cells (2 in x, 1 in y direction). The field should create an antisymmetric wave. The left cell is OK, the right one is garbage. (The example is chosen such that the top row issue doesn't show too badly). The overlaid quiver plot shows the correct velocity.
The second image uses 4 cells in x and 3 cells in y-direction for the same velocity field. Quiver shows the correct velocity as overlay. The rightmost column and top row of cells show the wrong streamlines.
For quick reference: the variables used
Expected outcome
A streamline plot consistent with velocity shown in quiver overlay.
Matplotlib version
MacOS High Sierra (10.13.5)
matplotlib-2.1.2-py36h6d6146d_0
print(matplotlib.get_backend())
):MacOSX
3.6
n/a
numpy
Python and matplotlib installed using anaconda3 package
The text was updated successfully, but these errors were encountered: