Unidata / MetPy

MetPy is a collection of tools in Python for reading, visualizing and performing calculations with weather data.
https://unidata.github.io/MetPy/
BSD 3-Clause "New" or "Revised" License
1.25k stars 416 forks source link

BUG: wind direction calculation doesn't round-trip #178

Closed deeplycloudy closed 8 years ago

deeplycloudy commented 8 years ago

Given the simple test below it looks like the conversion of wind speed and direction to u, v components and then back again adds a 180° offset to the wind direction. Assuming this is not the desired behavior, I will work up a patch.

In [1]: from metpy.calc import get_wind_components, get_wind_dir, get_wind_speed
In [2]: from metpy.units import units
In [3]: wspd = 15*units.meters/units.seconds
In [4]: wdir = 160*units.degrees
In [5]: u, v = get_wind_components(wspd, wdir)
In [6]: get_wind_dir(u,v)
Out[6]: Quantity(340.0, 'degree')
In [7]: get_wind_speed(u,v)
Out[7]: Quantity(15.0, 'meter / second')
In [8]: import metpy
In [9]: metpy.__version__
Out[9]: u'0.3.1'
deeplycloudy commented 8 years ago

While test_dir passes, I think the test itself has a sign error; if the convention for wind direction is specified as that from which the wind is blowing, then u, v = (4,0) is wind blowing from west to east, which should be 270. The test says it should be 90. So the test must be adjusted as well.

dopplershift commented 8 years ago

Fixed by #179.