From 24c673da9ab8a744a743714894db9606377f4bde Mon Sep 17 00:00:00 2001 From: Ray Bell Date: Sun, 17 Mar 2024 22:10:42 -0400 Subject: [PATCH 1/4] DOC: wind examples --- src/metpy/calc/basic.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/metpy/calc/basic.py b/src/metpy/calc/basic.py index 0e164e1b040..eb5cd783506 100644 --- a/src/metpy/calc/basic.py +++ b/src/metpy/calc/basic.py @@ -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')) + 14.142135623730951 + """ return np.hypot(u, v) @@ -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')) + array(225.) + """ wdir = units.Quantity(90., 'deg') - np.arctan2(-v, -u) origshape = wdir.shape @@ -141,7 +155,8 @@ 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) - (, ) + (7.071067811865474 , + 7.071067811865477 ) .. versionchanged:: 1.0 Renamed ``wdir`` parameter to ``wind_direction`` From a835e549235abe9aa8d8e946d713a41fe919bcaa Mon Sep 17 00:00:00 2001 From: Ray Bell Date: Sun, 17 Mar 2024 22:15:05 -0400 Subject: [PATCH 2/4] DOC: example to angle_to_direction --- src/metpy/calc/tools.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/metpy/calc/tools.py b/src/metpy/calc/tools.py index c34453c8f30..8b1732ff2ad 100644 --- a/src/metpy/calc/tools.py +++ b/src/metpy/calc/tools.py @@ -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 From 3afdb71d1c128d2c332a279bd5e51d433321f56f Mon Sep 17 00:00:00 2001 From: Ray Bell Date: Mon, 18 Mar 2024 14:47:46 -0400 Subject: [PATCH 3/4] Update basic.py --- src/metpy/calc/basic.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/metpy/calc/basic.py b/src/metpy/calc/basic.py index eb5cd783506..a290e3df12e 100644 --- a/src/metpy/calc/basic.py +++ b/src/metpy/calc/basic.py @@ -57,7 +57,7 @@ def wind_speed(u, v): >>> from metpy.calc import wind_speed >>> from metpy.units import units >>> wind_speed(10. * units('m/s'), 10. * units('m/s')) - 14.142135623730951 + """ return np.hypot(u, v) @@ -100,7 +100,7 @@ def wind_direction(u, v, convention='from'): >>> from metpy.calc import wind_direction >>> from metpy.units import units >>> wind_direction(10. * units('m/s'), 10. * units('m/s')) - array(225.) + """ wdir = units.Quantity(90., 'deg') - np.arctan2(-v, -u) @@ -155,8 +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) - (7.071067811865474 , - 7.071067811865477 ) + (, ) .. versionchanged:: 1.0 Renamed ``wdir`` parameter to ``wind_direction`` From bc663aa6f4296bb7045d240d74b39fb7f3183958 Mon Sep 17 00:00:00 2001 From: Ray Bell Date: Mon, 18 Mar 2024 14:48:58 -0400 Subject: [PATCH 4/4] Update tools.py --- src/metpy/calc/tools.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/metpy/calc/tools.py b/src/metpy/calc/tools.py index 8b1732ff2ad..12640a65617 100644 --- a/src/metpy/calc/tools.py +++ b/src/metpy/calc/tools.py @@ -1830,7 +1830,7 @@ def angle_to_direction(input_angle, full=False, level=3): >>> from metpy.calc import angle_to_direction >>> from metpy.units import units >>> angle_to_direction(225. * units.deg) - "SW" + 'SW' """ try: # strip units temporarily