OpenPIV / openpiv-python

OpenPIV is an open source Particle Image Velocimetry analysis software written in Python and Cython
http://www.openpiv.net
GNU General Public License v3.0
229 stars 141 forks source link

Streamplot issue #294

Closed chi86 closed 1 year ago

chi86 commented 1 year ago

Hi, when I try to run the command strm = ax.streamplot(x,y,u,v, color=u, linewidth=2, cmap='autumn')given in: https://gist.github.com/alexlib/77d4eef714f75989572debff53157722

I get following error:

  File "OpenPIV.py", line 435, in <module>
    strm=ax.streamplot(x,y,u,v, color=u, linewidth=2, cmap='autumn')
  File "/usr/lib/python3.10/site-packages/matplotlib/__init__.py", line 1423, in inner
    return func(ax, *map(sanitize_sequence, args), **kwargs)
  File "/usr/lib/python3.10/site-packages/matplotlib/streamplot.py", line 91, in streamplot
    grid = Grid(x, y)
  File "/usr/lib/python3.10/site-packages/matplotlib/streamplot.py", line 346, in __init__
    raise ValueError("'y' must be strictly increasing")
ValueError: 'y' must be strictly increasing

This used to work the last time I ran it a year ago.....

I use the following:

Any help is very much appreciated. Thanks!

alexlib commented 1 year ago

See the updated version.

https://gist.github.com/alexlib/f6855a1d9b53b6b7cd5e9571cc9b826f

chi86 commented 1 year ago

Thank you very much! This works fine, but this mirrors the display.

alexlib commented 1 year ago

could you please play with the x,y,u,v and see how best to feed it into streamplot?

is the second version better, the one that uses pivpy?

chi86 commented 1 year ago

I found a workaround. Following the steps:

  1. Before performing the PIV I mirror the frames frame_a=frame_a[::-1,:]
  2. After the PIV and the get_coordinates I mirror y (y=-(y-y.max())) and fix the sign of v0 (v0=-v0)

I have same issue with the pivpy version.

Thanks for the help!

alexlib commented 1 year ago

If possible, share your notebook so things are clear to others you can fork or suggest on gist https://gist.github.com/alexlib/f6855a1d9b53b6b7cd5e9571cc9b826f

alexlib commented 1 year ago

here's a fix for pivpy - I need to use the original x,y,u,v and not transformed

https://gist.github.com/alexlib/3baa2abecd769f9eac30a57a3bbeb675

chi86 commented 1 year ago

Here the link to the gist: https://gist.github.com/chi86/53ba84bf9f5a8626f84c08ef2a905c69

alexlib commented 1 year ago

Here the link to the gist: https://gist.github.com/chi86/53ba84bf9f5a8626f84c08ef2a905c69

I see, but the results are only "visually" correct, not really. You see - the original image has an origin top left and the result you present is bottom left - so the direction of rotation is maybe visually correct, but the values are not. We had quite a long discussion of this issue and decided that we present stuff on image to comply with the visual info - for instance if we play two images, what direction we see? clockwise from A to B frame. But if we consider u,v according to x,y located at 0,0 and we consider vertical upwards as positive v, then the actual result is negative v on the right side and positive v on the left side of the vortex.

alexlib commented 1 year ago

I think we will close this issue as resolved