Hello,
For 2d wind speed, I found we can caluculate the wind speed from vapor_utils import.
How can I calculate the speed from 3-dimensional wind component for wind speed visualization?
Hi, I’m not sure I understand the question.
Calculating 3D wind speeds should be the same procedure as for 2D. You just need to define your output variable on the correct 3D grid, then feed your python script the correct 3D variables.
Or, are you trying to color a 2D renderer such as wind Barbs, according to a 3D wind speed? This is a use case I haven’t seen before, but it’s interesting. I can help either way.
Thanks,
Scott
Dear Scott,
Thank you very much for your reply.
I am trying to plot wind profile using wind barbs (U,V,W) . I would like to plot the wind barb colored by magnitude of (U,V,W) (i.e what I mean wind speed) . I tried to get magnitued of (U,V,W) at Phython variables by using followind script:
from vapor_utils import *
wind = Mag (U,V,W)
But it failed. I got the following error.
Failed to read variable “wind” at time step (0), and
refinement level (-1) and level-of-detail (-1)
Failed to read region from variable/timestep/level/lod (wind, 0, -1, -1)
PyRun_String() : Traceback (most recent call last):
File “/tmp/.mount_VAPOR-DFkLhj/lib/python3.9/site-packages/scipy/init.py”, line 154, in
from scipy._lib._ccallback import LowLevelCallable
File “/tmp/.mount_VAPOR-DFkLhj/lib/python3.9/site-packages/scipy/_lib/_ccallback.py”, line 1, in
from . import _ccallback_c
File “_ccallback_c.pyx”, line 210, in init scipy._lib._ccallback_c
File “/tmp/.mount_VAPOR-DFkLhj/lib/python3.9/ctypes/init.py”, line 8, in
from _ctypes import Union, Structure, Array
ModuleNotFoundError: No module named ‘_ctypes’
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File “”, line 2, in
File “/tmp/.mount_VAPOR-DFkLhj/share/python/vapor_utils.py”, line 143, in Mag
tmp = StaggeredToUnstaggeredGrid(argv[i], axis)
File “/tmp/.mount_VAPOR-DFkLhj/share/python/vapor_utils.py”, line 78, in StaggeredToUnstaggeredGrid
aprime[k,::,::] = _StaggeredToUnstaggeredGrid2D(a[k,::,::],axis-1)
File “/tmp/.mount_VAPOR-DFkLhj/share/python/vapor_utils.py”, line 20, in _StaggeredToUnstaggeredGrid2D
from scipy.interpolate import RectBivariateSpline
File “/tmp/.mount_VAPOR-DFkLhj/lib/python3.9/site-packages/scipy/init.py”, line 159, in
raise ImportError(msg) from e
ImportError: The scipy
install you are using seems to be broken, (extension modules cannot be imported), please try reinstalling.
Vapor 3.9.3.ae4c8d61d
OS: Linux 5.4.0-149-generic #166-Ubuntu SMP Tue Apr 18 16:51:45 UTC 2023
Distro:
Please, could you tell me where I should check? Thank you very much in advance for your time.
Hi Khin,
This is a known issue and we’re workong on a fix.
Are you using WRF outputs on a staggered grid? If not, you might be able to calculate the wind speed magnitude with the following:
import math
wind = sqrt(U*U, V*V, W*W)
Hi Scott,
Thank you very much for your reply. Yes, I am using WRF output on a staggered grid.
Do you have access to a MacOS or Windows computer in the meantime? It will work on those platforms.
Hi Scott,
Thank you again for your reply.
I tried it on Windows system. But I still have an error relating to the incompatible stagger variable size.
Failed to read variable “wind” at time step (0), and
refinement level (-1) and level-of-detail (-1)
Failed to read region from variable/timestep/level/lod (wind, 0, -1, -1)
PyRun_String() : Traceback (most recent call last):
File “”, line 2, in
ValueError: operands could not be broadcast together with shapes (48,330,331) (48,331,330)
Vapor 3.10.1.
OS: Windows 6.2 (9200)
Are there any unstagger functions in vapour like we have " wrf_user_unstagger" in wrf_ncl?
Yes, you are correct. Those functions are in vapor_utils:
from vapor_utils import *
uU=StaggeredToUnstaggeredGrid(U,2)
uV=StaggeredToUnstaggeredGrid(V,1)
uW=StaggeredToUnstaggeredGrid(W,0)
speed=Mag(uU,uV,uW)
Dear Scott,
Thank you again for your time and reply.
Now, I get wind speed magnitude from 3d wind components.
Have a good day.
Best regards,
Khin