I'm building a simplified weather model that represents one geographic point rather than a full grid. It already changes wind speed and direction over time using variables such as pressure, temperature, and dew point. Wind direction is represented on a Cartesian plane: positive X is east, negative X is west, positive Y is north, and negative Y is south. I'd like to add wind shear, meaning wind speed or direction changing with altitude. Is there a simple formula or beginner-friendly approach for doing this in Python?
3 Answers
Yes. For a beginner-friendly model, define wind at the ground and add a smooth height-based change. For example, keep the speed constant while increasing the direction by a small amount per kilometer, or let both speed and direction change linearly between two altitude levels. That will create a simple synthetic wind profile. It won’t be physically accurate everywhere, but it is a reasonable way to test your code before adding more realistic atmospheric equations or observations.
Wind shear is not one extra value you apply to a single wind vector. It describes how the wind vector changes with height, so your column needs several altitude levels, such as 0 m, 100 m, 500 m, and 1,000 m. Give each level its own speed and direction, then compare neighboring levels. A simple shear estimate is the change in wind divided by the change in height: shear = (wind_at_height_2 - wind_at_height_1) / (height_2 - height_1).
You can convert each wind into X and Y components. If speed is `s` and direction angle is `theta`, use `x = s * cos(theta)` and `y = s * sin(theta)`. Then calculate the components at two heights and divide their differences by the height difference: `shear_x = (x2 - x1) / (z2 - z1)` and `shear_y = (y2 - y1) / (z2 - z1)`. The total shear magnitude is `sqrt(shear_x**2 + shear_y**2)`. Here, `theta` is simply the angle of the wind on your X/Y plane. Make sure your Python trigonometric functions use radians, and define clearly whether your angle is measured from east or north.
So I could start with a simple rule where direction gradually rotates with height, then later replace it with real atmospheric data?

That helps—by a column I mean one location with different levels above it, not a grid. So the height levels would be where the wind changes?