Skip to content

Commit

Permalink
stormu, stormv -> u_storm, v_storm
Browse files Browse the repository at this point in the history
  • Loading branch information
dopplershift committed Jan 13, 2020
1 parent 0e9a1f9 commit a0c3791
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
14 changes: 7 additions & 7 deletions src/metpy/calc/indices.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ def significant_tornado(sbcape, surface_based_lcl_height, storm_helicity_1km, sh
@exporter.export
@preprocess_xarray
@check_units('[pressure]', '[speed]', '[speed]', '[length]', '[speed]', '[speed]')
def critical_angle(pressure, u, v, height, stormu, stormv):
def critical_angle(pressure, u, v, height, u_storm, v_storm):
r"""Calculate the critical angle.
The critical angle is the angle between the 10m storm-relative inflow vector
Expand All @@ -344,9 +344,9 @@ def critical_angle(pressure, u, v, height, stormu, stormv):
V-component of sounding winds.
height : `pint.Quantity`
Heights from sounding.
stormu : `pint.Quantity`
u_storm : `pint.Quantity`
U-component of storm motion.
stormv : `pint.Quantity`
v_storm : `pint.Quantity`
V-component of storm motion.
Returns
Expand All @@ -358,8 +358,8 @@ def critical_angle(pressure, u, v, height, stormu, stormv):
# Convert everything to m/s
u = u.to('m/s')
v = v.to('m/s')
stormu = stormu.to('m/s')
stormv = stormv.to('m/s')
u_storm = u_storm.to('m/s')
v_storm = v_storm.to('m/s')

sort_inds = np.argsort(pressure[::-1])
pressure = pressure[sort_inds]
Expand All @@ -371,8 +371,8 @@ def critical_angle(pressure, u, v, height, stormu, stormv):
shr5 = bulk_shear(pressure, u, v, height=height, depth=500 * units('meter'))

# Make everything relative to the sfc wind orientation
umn = stormu - u[0]
vmn = stormv - v[0]
umn = u_storm - u[0]
vmn = v_storm - v[0]

vshr = np.asarray([shr5[0].magnitude, shr5[1].magnitude])
vsm = np.asarray([umn.magnitude, vmn.magnitude])
Expand Down
6 changes: 3 additions & 3 deletions tests/calc/test_indices.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def test_critical_angle():
data = get_upper_air_data(datetime(2016, 5, 22, 0), 'DDC')
ca = critical_angle(data['pressure'], data['u_wind'],
data['v_wind'], data['height'],
stormu=0 * units('m/s'), stormv=0 * units('m/s'))
u_storm=0 * units('m/s'), v_storm=0 * units('m/s'))
truth = [140.0626637513269] * units('degrees')
assert_almost_equal(ca, truth, 8)

Expand All @@ -187,10 +187,10 @@ def test_critical_angle_units():
# Set storm motion in m/s
ca_ms = critical_angle(data['pressure'], data['u_wind'],
data['v_wind'], data['height'],
stormu=10 * units('m/s'), stormv=10 * units('m/s'))
u_storm=10 * units('m/s'), v_storm=10 * units('m/s'))
# Set same storm motion in kt and m/s
ca_kt_ms = critical_angle(data['pressure'], data['u_wind'],
data['v_wind'], data['height'],
stormu=10 * units('m/s'), stormv=19.4384449244 * units('kt'))
u_storm=10 * units('m/s'), v_storm=19.4384449244 * units('kt'))
# Make sure the resulting critical angles are equal
assert_almost_equal(ca_ms, ca_kt_ms, 8)

0 comments on commit a0c3791

Please sign in to comment.