-
Notifications
You must be signed in to change notification settings - Fork 446
Closed
Labels
Area: CalcPertains to calculationsPertains to calculationsType: API ChangeChanges to how existing functionality worksChanges to how existing functionality worksType: MaintenanceUpdates and clean ups (but not wrong)Updates and clean ups (but not wrong)
Description
The following code:
import numpy as np
import metpy.calc as mpcalc
from metpy.units import units
T = np.array(([1, 2, 3],
[4, 4, 4],
[1, 3, 7],
[0, 2, 6])) * units.K
u = np.array(([5, 4, 4],
[6, 6, 6],
[6, 7, 6],
[5, 5, 5])) * units.m/units.s
v = np.array(([4, 4, 4],
[3, 2, 3],
[1, 2, 3],
[0, 1, 1])) * units.m/units.s
dx = np.array(([12, 10],
[12, 10],
[10, 8],
[10, 8])) * units.m
dy = np.array(([6, 5, 5],
[5, 5, 4],
[5, 4, 4])) * units.m
np.set_printoptions(precision=4)
dTdy, dTdx = mpcalc.gradient(T, deltas=(dy, dx))
print(dTdx)
print(dTdy)
adv = mpcalc.advection(T, wind=(u, v), deltas=(dx, dy), dim_order='yx')
print(adv)accurately computes the temperature gradient and temperature advection corresponding to the sample data provided in 'yx' order.
However, notice that doing this calculation properly requires providing the deltas as (dy, dx) in the gradient call, but (dx, dy) in the advection call. I would have expected the order to be the same for both calls. In particular, since the data is in yx order, I would expect the correct call to advection would include deltas=(dy, dx), but currently that is not the case.
A second inconsistency involves the dim_order argument: The gradient function doesn't use it, but omitting it from advection results in a stern warning from MetPy. I would expect:
- No warning from MetPy when
dim_orderis omitted in theadvectioncall, and/or gradientto allow for the dim_order to be specified as well, interpreted the same way as inadvection.
Version Info
Python 3.6.5
0.8.0+32.gb19c052
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Area: CalcPertains to calculationsPertains to calculationsType: API ChangeChanges to how existing functionality worksChanges to how existing functionality worksType: MaintenanceUpdates and clean ups (but not wrong)Updates and clean ups (but not wrong)