turbulucid icon indicating copy to clipboard operation
turbulucid copied to clipboard

plot_vectors with colorField failed.

Open scramjetFoam opened this issue 1 year ago • 2 comments

Hi,

Thank you for develop this useful tools. When I run the test case, I encounter some errors that disappear if I close the sampleByPlane. I think sampleByPlane caused the array to mismatch. Is it a bug?

Regards.

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
[c:\Users\Wang\Desktop\turbulucid-master\docs\tutorial\turbulucid_tutorial.ipynb](file:///C:/Users/Wang/Desktop/turbulucid-master/docs/tutorial/turbulucid_tutorial.ipynb) Cell 37 line 1
----> [1](vscode-notebook-cell:/c%3A/Users/Wang/Desktop/turbulucid-master/docs/tutorial/turbulucid_tutorial.ipynb#X51sZmlsZQ%3D%3D?line=0) plot_vectors(case, 'UMean', colorField='magUMean', scaleX=h, scaleY=h, normalize=True, sampleByPlane=True, planeResolution=[70,150], scale=50)
      [2](vscode-notebook-cell:/c%3A/Users/Wang/Desktop/turbulucid-master/docs/tutorial/turbulucid_tutorial.ipynb#X51sZmlsZQ%3D%3D?line=1) plt.xlim([-1, 6])
      [3](vscode-notebook-cell:/c%3A/Users/Wang/Desktop/turbulucid-master/docs/tutorial/turbulucid_tutorial.ipynb#X51sZmlsZQ%3D%3D?line=2) plt.ylim([-1, 1])

File /opt/miniconda3/envs/tbl/lib/python3.8/site-packages/turbulucid-0.4-py3.8.egg/turbulucid/core/plotting.py:214, in plot_vectors(case, field, colorField, normalize, scaleX, scaleY, sampleByPlane, planeResolution, plotBoundaries, **kwargs)
    [212](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/tbl/lib/python3.8/site-packages/turbulucid-0.4-py3.8.egg/turbulucid/core/plotting.py:212) if sampleByPlane:
    [213](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/tbl/lib/python3.8/site-packages/turbulucid-0.4-py3.8.egg/turbulucid/core/plotting.py:213)     if type(colorField) == str:
--> [214](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/tbl/lib/python3.8/site-packages/turbulucid-0.4-py3.8.egg/turbulucid/core/plotting.py:214)         colorData = sampledData[colorField].reshape(planeResolution[1] + 1,
    [215](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/tbl/lib/python3.8/site-packages/turbulucid-0.4-py3.8.egg/turbulucid/core/plotting.py:215)                                                     planeResolution[0] + 1)
    [216](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/tbl/lib/python3.8/site-packages/turbulucid-0.4-py3.8.egg/turbulucid/core/plotting.py:216)         return plt.quiver(pointsX/scaleX, pointsY/scaleY, data[:, 0],
    [217](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/tbl/lib/python3.8/site-packages/turbulucid-0.4-py3.8.egg/turbulucid/core/plotting.py:217)                           data[:, 1], colorData, **kwargs)
    [218](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/tbl/lib/python3.8/site-packages/turbulucid-0.4-py3.8.egg/turbulucid/core/plotting.py:218)     else:

ValueError: cannot reshape array of size 10500 into shape (151,71)

scramjetFoam avatar Nov 19 '23 11:11 scramjetFoam

Hi, sorry that I have missed your message. I will try to look into this as soon as possible, but can't promise exactly when.

timofeymukha avatar Apr 01 '24 11:04 timofeymukha

@timofeymukha Hi I meet the same problem , it may because the reshape set: image

smallduan avatar Apr 05 '24 16:04 smallduan