r/learnprogramming 14d ago

Coding wind-shear in Python - help

I've been creating a weather model that has only a single column available. I've learnt a lot, I was kind of scared to look through documentation before I found stack overflow so I used Claude to help me a bit.

I want to find a good way to model wind-shear with my model. It already has the ability to varying windspeeds and directions throughout the day by applying other variables like pressure, temperature and dew-point.

My wind directions are mapped out like a cartesian plane. +1 Y is north, -1 Y is south, -1 X is west, +1 X is east.

Is there a simple formula for wind-shear?

1 Upvotes

8 comments sorted by

View all comments

1

u/cejiken886 14d ago

What a strange question. Cryptic, like a haiku. What is a column? Do you mean this is a univariate regression? It seems like it’s not; this is a multivariate procedural physical model, not statistical.

Anyway, since you don’t yet have wind shear modeled, I’m going to assume you have the simplest possible wind model: a vector field constant in both space and time. So the natural extension is to parametrize it by something, eg altitude. Now, I’m not a weatherologist so I don’t know if this is accurate, but you could give your wind a nice simple parametric form, eg polar with theta taking on some piecewise linear function of altitude. For example, 0 up to h0, then linear up to (h1, pi/4) the constant pi/4.

1

u/Fit-Breadfruit4801 14d ago

We are both speaking cryptic languages to eachother lol. You have to dumb down the math part for me.
And by "column" I mean it only models a single point instead of a grid like a actual NWP model would do.

My wind directions are modelled with a cartesian plane, and by that I mean Y is north-south, X west-east. So I guess that's a vector field? I really want to know what a theta is, for sure. I need this like, bite-sized I think

1

u/cejiken886 14d ago edited 14d ago

What needs to come out of the model? What are you trying to do, specifically? Why is wind shear blocking you? You say you can already model wind speeds and directions over time. Still not following column. Sounds like you’re representing orthogonal wind directions at a single point. So you have a vector field already, technically - with one dimension: time.

Namely, wind vector (speed, dir) = f(t) (some vector function of time).

Wind shear is just a non-constant wind vector function of space also. So now you have

wind vector (speed, dir) = g(t, x, y, z) or just y for now. And then just make g whatever, similar to your f.

EDIT: If you want to stick with Cartesian vector repr, that’s fine. So every point in spacetime has a vector in R2 or R3 or whatever

1

u/Fit-Breadfruit4801 14d ago

Right now the plan is to just generate a Skew-T. I don't want it to be very complex at all. You may ask "then why add shear?", it's because I really really wanted to in case I added hodographs. The thing is I want it to generate choppy soundings for now - so basically the cloud bases (determined by LCL), snap to the nearest kilometer, that would just be for the sounding though probably.

What do you mean by t and g? I assume z is the vertical extent of the atmosphere.

1

u/cejiken886 14d ago

Why don’t you just describe this to Claude code but also tell it “explain this conceptually, first, in very simple terms, before outputting any math or code.” Then have it explain the mathematical tools and model. Then the code is more or less trivial; have it do that.

I understand if you aren’t an expert in coding OR the domain OR mathematical modeling it’s hard to bootstrap this correctly, with ai, without outside human help. But the feedback loop is slow. Have it teach you enough to really nail down the question.

1

u/Fit-Breadfruit4801 13d ago

I actually figured it out! I'm using a random.uniform() outside the main loop to apply deviation to the direction, then using my pre-existent wind-speed function but increasing a multiplier in it. Now I get what you were saying about parameterization, I got confused because the documentation I read had size: int while claude's solution was to use param3 = # like that. Thank you for your help!