You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My use case is computing the magnitude of the water vapor mass flux. Of course I can just write the square root of the sum of the squares myself, but I first thought, maybe I could use wind_speed for this. However, that failed since the units are wrong. Then I looked into what the documentation says is the MetPy equivalent of GEMPAK's MAG function, and it says to use numpy.linalg.norm for this. In my case, I have 3D arrays (x,y,theta) of the i- and j-components of the mass flux, and my attempts to somehow use norm for this have failed.
My request is either:
Determine that np.linalg.norm actually isn't equivalent to GEMPAK's MAG function, or
Provide an example of how to use norm to compute the magnitude of a vector when the scalar components are 3D arrays in that box on the Conversion Guide. I suspect that, if this is possible, it involves constructing an array with such care that just doing the square root of the sum of the squares is much easier, in which case,
Implement an actual mpcalc magnitude function (of which the wind_speed function becomes a special case that adds the requisite unit check)
The text was updated successfully, but these errors were encountered:
I think norm is wrong (or at least more complicated than necessary), but numpy.hypot() should be exactly what you want. I'd be happy to merge a PR to that effect for the GEMPAK guide.
What can be better?
This is related to #537.
My use case is computing the magnitude of the water vapor mass flux. Of course I can just write the square root of the sum of the squares myself, but I first thought, maybe I could use
wind_speed
for this. However, that failed since the units are wrong. Then I looked into what the documentation says is the MetPy equivalent of GEMPAK's MAG function, and it says to use numpy.linalg.norm for this. In my case, I have 3D arrays (x,y,theta) of the i- and j-components of the mass flux, and my attempts to somehow usenorm
for this have failed.My request is either:
np.linalg.norm
actually isn't equivalent to GEMPAK's MAG function, ornorm
to compute the magnitude of a vector when the scalar components are 3D arrays in that box on the Conversion Guide. I suspect that, if this is possible, it involves constructing an array with such care that just doing the square root of the sum of the squares is much easier, in which case,magnitude
function (of which thewind_speed
function becomes a special case that adds the requisite unit check)The text was updated successfully, but these errors were encountered: