Skip to content

barb direction (meteorological convention) #8985

Closed

Description

@gd-a

Hi there,

It seems that barb -Q+z (use U, V instead of speed, azimuth) is 180° rotated.
(the workaround is to compute the azimuth manually and just use the default mode)

Best,
Guillaume

Activity

  1. added
    bug
    on Apr 17, 2026
  2. reopened this on Apr 17, 2026
  3. gd-a commented on Apr 17, 2026

    @gd-a
    ContributorAuthor

    It's the same without +z by the way... so it's consistent

    Could it be because of the +e / +b / +c modifier?

  4. yvonnefroehlich commented on Apr 17, 2026

    @yvonnefroehlich
    Member

    It seems that barb -Q+z (use U, V instead of speed, azimuth) is 180° rotated.

    Hmm, not sure if I understand your issue correctly and my knowledge from my Bachelor times is a bit older. But as far as I know, in meteorology the direction reported as wind direction is the direction FROM which the wind is blowing. Thus, the barbs are drawn in the way that the "lines" or "triangles" are on the side from which the wind is blowing. From your webpage I get you are a geophysicist and oceanographer. If I remember it correctly, in oceanography we used the direction IN which something is flowing. Maybe this different conventions cause a confusion here?

    Could it be because of the +e / +b / +c modifier?

    I think no. If I understand the docs correctly, +jb|c|e](https://docs.generic-mapping-tools.org/dev/supplements/windbarbs/barb.html#q) can be used to adjust the part (beginning, center, end) of the barb which is used to place the barb on the map related to the given x and y coordinates.

    +jb +jc +je
    Image Image Image

    Data and code used for the plots (sorry it's PyGMT with GMT):

    import pygmt
    
    pen_barb = "0.5p,darkorange"
    fill_barb = "brown"
    
    fig = pygmt.Figure()
    pygmt.config(MAP_GRID_PEN="0.1p,gray70")
    fig.basemap(region=[-5, 5] * 2, projection="X10c", frame="g1")
    
    for barbs_data, use_word in zip(
        ["barbs_strength.txt", "barbs_direction.txt"], [1, 0]
    ):
        with pygmt.clib.Session() as session:
            session.call_module(
                'barb',
                '{} \
                -W{} \
                -G{} \
                -Q{}' \
                .format(barbs_data, pen_barb, fill_barb, "0.5c+je")
            )
        fig.text(barbs_data, offset="0c/-0.05c", justify="TC", font="5p", use_word=use_word)
    fig.show()
  5. yvonnefroehlich commented on Apr 17, 2026

    @yvonnefroehlich
    Member

    Just playing a bit more with this barb module. And I am currently confused about the (u,v) wind components.
    From the GMT docs I get u should be in the third and v in the fourth columns.:

    +z - Input (u,v) wind components instead of (azimuth,speed).

    But my resulting plot looks like this:
    Image

    As far as I know u is the component positiv to east (x direction) and v the component positiv to north (y direction). So looking at my plot, u and v are flipped, and the third column is plotted as v and the fourth column is plotted as u.

    Related data and code:

    import pygmt
    
    pen_barb = "1p,darkorange"
    fill_barb = "brown"
    
    fig = pygmt.Figure()
    pygmt.config(MAP_GRID_PEN="0.1p,gray70")
    fig.basemap(
        region=[-4, 4, -1, 1], projection="X8c/2c", frame=["g1", "x+lu", "y+Lv"]
    )
    
    with pygmt.clib.Session() as session:
        session.call_module(
            'barb',
            '{} \
            -W{} \
            -G{} \
            -Q{}' \
            .format("barbs_velocity.txt", pen_barb, fill_barb, "+z")
        )
    
    fig.text(
        text=["(u,v)", "(1,2)", "(2,1)", "(1,1)", "(-1,-2)", "(-2,-1)", "(-1,-1)"],
        x=[-3, -2, -1, 0, 1, 2, 3],
        y=[0, 0, 0, 0, 0, 0, 0],
        offset="0c/-0.75c",
        font="5p,1",
    )
    
    fig.show()
    
  6. joa-quim commented on Apr 20, 2026

    @joa-quim
    Member

    Dear @masahigaki

    I would like to call your attention to this discussion and ask if you could help enlightening these raised doubts.

    Best regards

  7. masahigaki commented on Apr 26, 2026

    @masahigaki
    Contributor

    Dear @yvonnefroehlich, @joa-quim
    Thank you for informing me of the issue and sorry for my delayed response.
    As yvonnefroehlich mentioned, u and v seem flipped.

    In psbarb.c, the azimuth is computed as

    d = d_atan2d (in[ex2+2*S.read_size], in[ex1+2*S.read_size]);
    as well as

    gmt/src/psxy.c

    Line 2203 in ce1f5a1

    d = d_atan2d (in[ex2+S.read_size], in[ex1+S.read_size]); /* Compute direction */
    for vector plots, but it is for the direction (counterclockwise from east) not for the azimuth (clockwise from north). I think it should be fixed as follows:

    --- a/src/windbarbs/psbarb.c
    +++ b/src/windbarbs/psbarb.c
    @@ -543,3 +543,3 @@ EXTERN_MSC int GMT_psbarb (void *V_API, int mode, void *args) {
                            if (Ctrl->Q.B.status & PSL_VEC_COMPONENTS)      /* Read dx, dy in user units */
    -                               d = d_atan2d (in[ex2+2*S.read_size], in[ex1+2*S.read_size]);
    +                               d = d_atan2d (-in[ex1+2*S.read_size], -in[ex2+2*S.read_size]);
                            else
  8. joa-quim commented on Apr 27, 2026

    @joa-quim
    Member

    Dear @masahigaki
    Thanks you for looking into this and proposing a fix. @yvonnefroehlich want to do the PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions