Project

General

Profile

Wind direction - atan2 ?

Added by Bartosz Czernecki about 6 years ago

Hi All,

Does anybody know whether it is possible to calculate wind direction (in degrees) based on the horizontal (U) and vertical (V) wind components?
I have both variables are in one file and I tried to manipulate with the ATAN2 function, but with no success so far..

Best,
Bartek


Replies (5)

RE: Wind direction - atan2 ? - Added by Ralf Mueller about 6 years ago

hi!

atan2 is not available in the expr operators unfortunately. you can create numpy arrays from U and V and use atan2 from there

cheers
ralf

RE: Wind direction - atan2 ? - Added by Bartosz Czernecki about 6 years ago

Thanks Ralf,

This is what I thought :/
I would like to avoid python since it would require administrative privilages on a cluster machine, so I'll try to figure out whether is doable in any other way.
In the meantime I found another solution in the Joerg Wenger's slides (https://www.dkrz.de/mms/pdf/klimaforschung/cmip5/Processing_Joerg_Wegner.pdf , slide 16):

cdo mulc,57.3 -atan2 -mulc,-1 U1000.nc -mulc,-1 V1000.nc UV.nc

Unfortunetaly, after creating 2 seperate files for my variables (u10.nc and v10.nc) it still doesn't work...

cdo mulc,57.3 -atan2 -mulc, -1 u10.nc -mulc, -1 v10.nc uv.nc
Operator >1< not found!
Similar operators are:
(not found)

Any ideas what's wrong with that?

Best,
Bartek

RE: Wind direction - atan2 ? - Added by Bartosz Czernecki about 6 years ago

I've just figured out a solution with NCO:

ncap2 -v -O -s 'uv10=57.29578*(atan2(U10,V10))+180' input.nc output.nc

.. but I am still willing to get answer to the previous question ;)

Best,
Bartek

RE: Wind direction - atan2 ? - Added by Ralf Mueller about 6 years ago

Bartosz Czernecki wrote:

Thanks Ralf,

This is what I thought :/
I would like to avoid python since it would require administrative privilages on a cluster machine, so I'll try to figure out whether is doable in any other way.
In the meantime I found another solution in the Joerg Wenger's slides (https://www.dkrz.de/mms/pdf/klimaforschung/cmip5/Processing_Joerg_Wegner.pdf , slide 16):

cdo mulc,57.3 -atan2 -mulc,-1 U1000.nc -mulc,-1 V1000.nc UV.nc

Unfortunetaly, after creating 2 seperate files for my variables (u10.nc and v10.nc) it still doesn't work...

cdo mulc,57.3 -atan2 -mulc, -1 u10.nc -mulc, -1 v10.nc uv.nc
Operator >1< not found!
Similar operators are:
(not found)

there is a space between mulc, the parameter 1. try this

cdo mulc,57.3 -atan2 -mulc,-1 u10.nc -mulc,-1 v10.nc uv.nc

I think the spaces came from copy/paste from the pdf, this gives funny results sometimes ...

hth
ralf

RE: Wind direction - atan2 ? - Added by Bartosz Czernecki about 6 years ago

works like a charm!
thanks a lot! :)

best,
bartek

    (1-5/5)