Skip to content

Commit 9451c3f

Browse files
authored
Merge pull request #3690 from dopplershift/qvector-units
Fix q_vector units w/ default static stability
2 parents ea2fcfc + 5bebff4 commit 9451c3f

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

Diff for: examples/calculations/QVector.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@
2323
# Calculate the temperature advection of the flow
2424
tadv = mpcalc.advection(ds.temperature, ds.uwind, ds.vwind)
2525

26-
# Calculate the q-vectors
27-
u_qvect, v_qvect = mpcalc.q_vector(ds.uwind, ds.vwind, ds.temperature, 850 * units.hPa)
26+
# Calculate the q-vectors. Passing in a fixed value of static stability, but could also
27+
# use `mpcalc.static_stability()`.
28+
u_qvect, v_qvect = mpcalc.q_vector(ds.uwind, ds.vwind, ds.temperature, 850 * units.hPa,
29+
static_stability=0.02 * units('J / kg / Pa^2'))
2830

2931
# start figure and set axis
3032
fig, ax = plt.subplots(figsize=(5, 5))

Diff for: src/metpy/calc/kinematics.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -1275,7 +1275,8 @@ def inertial_advective_wind(
12751275
broadcast=('u', 'v', 'temperature', 'pressure', 'static_stability', 'parallel_scale',
12761276
'meridional_scale')
12771277
)
1278-
@check_units('[speed]', '[speed]', '[temperature]', '[pressure]', '[length]', '[length]')
1278+
@check_units('[speed]', '[speed]', '[temperature]', '[pressure]', '[length]', '[length]',
1279+
'[energy] / [mass] / [pressure]**2')
12791280
def q_vector(
12801281
u,
12811282
v,
@@ -1307,6 +1308,12 @@ def q_vector(
13071308
- 2 \nabla_p \cdot \vec{Q} -
13081309
\frac{R}{\sigma p} \beta \frac{\partial T}{\partial x}
13091310
1311+
By default, this function uses a unitless value of 1 for ``static_stability``, which
1312+
replicates the functionality of the GEMPAK ``QVEC`` function. If a value is given for
1313+
``static_stability``, it should have dimensionality of ``energy / mass / pressure^2``, and
1314+
will result in behavior that matches that of GEMPAK's ``QVCL`` function;
1315+
`static_stability` can be used to calculate this value if desired.
1316+
13101317
Parameters
13111318
----------
13121319
u : (..., M, N) `xarray.DataArray` or `pint.Quantity`

0 commit comments

Comments
 (0)