Skip to content

Magnitude of a Vector #3698

@sgdecker

Description

@sgdecker

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 use norm for this have failed.

My request is either:

  1. Determine that np.linalg.norm actually isn't equivalent to GEMPAK's MAG function, or
  2. 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,
  3. Implement an actual mpcalc magnitude function (of which the wind_speed function becomes a special case that adds the requisite unit check)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: DocsAffects documentationType: EnhancementEnhancement to existing functionality

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions