Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doc: wind examples #3441

Merged
merged 4 commits into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/metpy/calc/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ def wind_speed(u, v):
--------
wind_components

Examples
--------
>>> from metpy.calc import wind_speed
>>> from metpy.units import units
>>> wind_speed(10. * units('m/s'), 10. * units('m/s'))
<Quantity(14.1421356, 'meter / second')>

"""
return np.hypot(u, v)

Expand Down Expand Up @@ -88,6 +95,13 @@ def wind_direction(u, v, convention='from'):
In the case of calm winds (where `u` and `v` are zero), this function returns a direction
of 0.

Examples
--------
>>> from metpy.calc import wind_direction
>>> from metpy.units import units
>>> wind_direction(10. * units('m/s'), 10. * units('m/s'))
<Quantity(225.0, 'degree')>

"""
wdir = units.Quantity(90., 'deg') - np.arctan2(-v, -u)
origshape = wdir.shape
Expand Down Expand Up @@ -141,7 +155,7 @@ def wind_components(speed, wind_direction):
>>> from metpy.calc import wind_components
>>> from metpy.units import units
>>> wind_components(10. * units('m/s'), 225. * units.deg)
(<Quantity(7.07106781, 'meter / second')>, <Quantity(7.07106781, 'meter / second')>)
(<Quantity(7.07106781, 'meter / second')>, <Quantity(7.07106781, 'meter / second')>)

.. versionchanged:: 1.0
Renamed ``wdir`` parameter to ``wind_direction``
Expand Down
7 changes: 7 additions & 0 deletions src/metpy/calc/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -1825,6 +1825,13 @@ def angle_to_direction(input_angle, full=False, level=3):
direction
The directional text

Examples
--------
>>> from metpy.calc import angle_to_direction
>>> from metpy.units import units
>>> angle_to_direction(225. * units.deg)
'SW'

"""
try: # strip units temporarily
origin_units = input_angle.units
Expand Down