transforming to/from earth relative and grid relative for flow vectors in metpy

Viewed 155

I've tried looking through the source code, but there doesn't seem to be support for this in MetPy. For example, I have a set of wind vectors relative to the Earth coordinate system (speed, direction) which I want to transform to (u,v) relative to a grid on a Lambert Conformal projection.

1 Answers

MetPy doesn't handle the coordinate system transforms, it lets CartoPy handle that. It does support converting speed and direction to components. So you would want to do:

import cartopy.crs as ccrs
import metpy.calc as mpcalc

proj = ccrs.LambertConformal()

u_earth, v_earth = mpcalc.wind_components(speed, direction)
u_grid, v_grid = proj.transform_vectors(ccrs.PlateCarree(), lon, lat, u_earth, v_earth)

Using PlateCarree as the source projection for the components tells CartoPy that the coordinates and components are lon/lat and earth relative.

Related