function [U,V] = sd_to_uv(spd,dir)
%{
    Computes U and V wind components from speed and direction,
    where U is defined as positive for wind blowing S-to-N and V is
    positive for wind blowing E-to-W.  This is a right-handed convention
    and is the normal format for sonic anemometer wind components in
    all NOAA/PSD flux scripts.

    If spd/dir are in earth coordinates, U/V is true wind.
    If spd/dir are in ship coordinates, U/V is relative wind.

    dir format is the direction wind is coming FROM, 0-360 deg.

    Jan 2016, BWB
%}

U = spd .* cos((dir+180)*pi/180);
V = -spd .* sin((dir+180)*pi/180);

end