<p>Essentially I would like to know how current direction "DIR C" and wind direction "WDIR" for gribs is computed.</p>

<p>I'm trying to compute some angles from u and v vectors in grib files. My understanding from <a href="https://www.eol.ucar.edu/content/wind-direction-quick-reference" rel="nofollow noreferrer">this link</a> is that:</p>

<p>Positive U component represents wind blowing to (not from) the East (90 degrees). And positive V component is wind to (not from) the North (0 degrees). Is this correct?</p>

<p>In grib files values UGRD &amp; VGRD are stored this way. How does this apply to currents like UOGRD and VOGRD? Is the same convention used as for UGRD and VGRD?</p>

<p>For example, <em>assuming the vectors are defined the same</em> (UGRD and UOGRD) I'm calculating current headings like this from the GRIB data:</p>

<pre><code>$angle = round(atan2($u, $v) * 180 / pi());
if ($angle &lt; 0) {
    $angle = 360 + $angle;
}
</code></pre>

<p>And wind like this:</p>

<pre><code>$angle = round(atan2(-1*$u, -1*$v) * 180 / pi());
if ($angle &lt; 0) {
    $angle = 360 + $angle;
}
</code></pre>

<p>The current output looks like this (using u &amp; v values shown):</p>

<pre><code>u=1  v=1 45° NE
u=-1 v=1 315° NW
u=1 v=-1 135° SE
u=-1 v=-1 225° SW
</code></pre>

<p>And wind looks like with the vector being "from" not to:</p>

<pre><code>u=1 v=1 225° SW
u=-1 v=1 135° SE
u=1 v=-1 315° NW
u=-1 v=-1 45° NE
</code></pre>

<p>Does this look correct?</p>

<p>Note:  This atan2(y,x) function calculates the arc tangent of the two variables x and y. It is similar to calculating the arc tangent of y / x, except that the signs of both arguments are used to determine the quadrant of the result. </p>

CC BY-SA 3.0
2017-04-08T04:44:30.620Z
@gansub But my question also is about how u and v are defined for the current layers.
user6972
CC BY-SA 3.0
2017-04-11T08:44:07.317Z
I worked upon a very simple coupled ocean-atmosphere model code in a graduate course once, and don't remember there being any difference in definition.  Convinced you have the idea right for u and v in the atmosphere (u = 1, v = 1 is wind from the SW).  You can always compare current results to https://earth.nullschool.net/ which gives both wind and current animations.
JeopardyTempest
<meteorology><wind><weather-forecasting><ocean-currents>
Do U & V vectors differ depending on GRIB layers (wind vs current)?
user6972
# Do U & V vectors differ depending on GRIB layers (wind vs current)?

(Asked by: username_0 on 2017-04-07)

Essentially I would like to know how current direction "DIR C" and wind direction "WDIR" for gribs is computed.
I'm trying to compute some angles from u and v vectors in grib files. My understanding from this link is that:
Positive U component represents wind blowing to (not from) the East (90 degrees). And positive V component is wind to (not from) the North (0 degrees). Is this correct?
In grib files values UGRD & VGRD are stored this way. How does this apply to currents like UOGRD and VOGRD? Is the same convention used as for UGRD and VGRD?
For example, assuming the vectors are defined the same (UGRD and UOGRD) I'm calculating current headings like this from the GRIB data:
$angle = round(atan2($u, $v) * 180 / pi());
if ($angle < 0) {
    $angle = 360 + $angle;
}

And wind like this:
$angle = round(atan2(-1*$u, -1*$v) * 180 / pi());
if ($angle < 0) {
    $angle = 360 + $angle;
}

The current output looks like this (using u & v values shown):
u=1  v=1 45° NE
u=-1 v=1 315° NW
u=1 v=-1 135° SE
u=-1 v=-1 225° SW

And wind looks like with the vector being "from" not to:
u=1 v=1 225° SW
u=-1 v=1 135° SE
u=1 v=-1 315° NW
u=-1 v=-1 45° NE

Does this look correct?
Note:  This atan2(y,x) function calculates the arc tangent of the two variables x and y. It is similar to calculating the arc tangent of y / x, except that the signs of both arguments are used to determine the quadrant of the result.

**Tags:** meteorology, wind, weather-forecasting, ocean-currents

> **Comments:**
> **username_0**: @gansub But my question also is about how u and v are defined for the current layers.  
> **username_1**: I worked upon a very simple coupled ocean-atmosphere model code in a graduate course once, and don't remember there being any difference in definition.  Convinced you have the idea right for u and v in the atmosphere (u = 1, v = 1 is wind from the SW).  You can always compare current results to https://earth.nullschool.net/ which gives both wind and current animations.  

---

## 0 answers

