You can convert the wind vector components u
and v
into a wind speed (magnitude) and a wind direction (angle) using these formulas:
speed = math.sqrt(u*u + v*v)
direction = (270 - math.atan2(v, u) * 180 / math.pi) % 360
speed = math.sqrt(u*u + v*v)
U Component (u): Zonal (west → east).
V Component (v): Meridional (south → north).
Rotate the atan2
result to meteorological convention and wrap 0‑359°.
direction = (270 - math.atan2(v, u) * 180 / math.pi) % 360
curl -X POST 'https://gribstream.com/api/v2/hrrr/history' \
-H "Content-Type: application/json" \
-H "Authorization: $(curl https://gribstream.com/auth/demo)" \
-d '{
"fromTime": "2024-09-10T00:00:00Z",
"untilTime": "2024-09-10T10:00:00Z",
"minHorizon": 1,
"maxHorizon": 50,
"coordinates": [{ "lat": 40.7306, "lon": -73.9352, "name": "New York City" }],
"variables": [
{ "name": "UGRD", "level": "1000 mb", "alias": "uwind" },
{ "name": "VGRD", "level": "1000 mb", "alias": "vwind" }
],
"expressions": [
{ "expression": "func.Hypot(uwind, vwind)", "alias": "wind_magnitude" },
{ "expression": "int(270 - func.Atan2(vwind, uwind) * 180 / 3.14159) % 360", "alias": "wind_direction" }
]
}'
Result:
forecasted_at,forecasted_time,lat,lon,name,wind,uwind,wind_magnitude,wind_direction,vwind
2024-09-09T23:00:00Z,2024-09-10T00:00:00Z,40.731,-73.935,New York City,3.2632,6.1795,7.3362,237,3.9539
2024-09-10T03:00:00Z,2024-09-10T04:00:00Z,40.731,-73.935,New York City,2.2788,6.4841,6.9633,248,2.5385
2024-09-10T00:00:00Z,2024-09-10T01:00:00Z,40.731,-73.935,New York City,2.8097,8.0572,8.5765,249,2.9389
2024-09-10T02:00:00Z,2024-09-10T03:00:00Z,40.731,-73.935,New York City,2.4618,7.1213,7.3375,256,1.7680
2024-09-10T07:00:00Z,2024-09-10T08:00:00Z,40.731,-73.935,New York City,2.6267,6.5438,6.5864,263,0.7486
2024-09-10T05:00:00Z,2024-09-10T06:00:00Z,40.731,-73.935,New York City,2.3317,6.8368,6.8375,269,0.1001
2024-09-10T06:00:00Z,2024-09-10T07:00:00Z,40.731,-73.935,New York City,2.3682,7.3567,7.5201,258,1.5594
2024-09-10T04:00:00Z,2024-09-10T05:00:00Z,40.731,-73.935,New York City,2.6711,6.4087,7.1157,244,3.0921
2024-09-10T01:00:00Z,2024-09-10T02:00:00Z,40.731,-73.935,New York City,3.0152,8.1815,8.3435,258,1.6363
2024-09-10T08:00:00Z,2024-09-10T09:00:00Z,40.731,-73.935,New York City,2.1275,5.9424,5.9822,276,-0.6889
Use the Magnus‑Tetens approximation. Convert temperature from Kelvin to Celsius and apply the formula.
# T = temperature (K), RH = relative humidity (%)
T_C = T - 273.15
a = 17.27
b = 237.7
gamma = (a * T_C) / (b + T_C) + math.log(RH / 100)
dew_point_C = (b * gamma) / (a - gamma)
Compute dew point directly in the API response:
curl -X POST 'https://gribstream.com/api/v2/gfs/history' \
-H "Content-Type: application/json" \
-H "Authorization: $(curl https://gribstream.com/auth/demo)" \
-d '{
"fromTime": "2024-12-01T00:00:00Z",
"untilTime": "2024-12-01T06:00:00Z",
"minHorizon": 0,
"maxHorizon": 12,
"coordinates": [{ "lat": 47.6, "lon": -122.33, "name": "Seattle" }],
"variables": [
{ "name": "TMP", "level": "2 m above ground", "alias": "tempK" },
{ "name": "RH", "level": "2 m above ground", "alias": "rh" }
],
"expressions": [
{ "expression": "tempK - 273.15", "alias": "tempC" },
{ "expression": "(17.27 * tempC) / (237.7 + tempC) + func.Log(rh / 100)", "alias": "gamma" },
{ "expression": "(237.7 * gamma) / (17.27 - gamma)", "alias": "dew_point_C" },
{ "expression": "dew_point_C + 273.15", "alias": "dew_point_K" }
]
}'
Result:
forecasted_at,forecasted_time,lat,lon,name,rh,tempC,gamma,dew_point_C,dew_point_K,tempK
2024-12-01T00:00:00Z,2024-12-01T02:00:00Z,47.600,-122.330,Seattle,75.4000,4.9410,0.0693,0.9579,274.1079,278.0910
2024-12-01T00:00:00Z,2024-12-01T00:00:00Z,47.600,-122.330,Seattle,69.7000,5.7435,0.0465,0.6415,273.7915,278.8935
2024-12-01T00:00:00Z,2024-12-01T04:00:00Z,47.600,-122.330,Seattle,80.0000,4.4245,0.0924,1.2792,274.4292,277.5745
2024-12-01T00:00:00Z,2024-12-01T03:00:00Z,47.600,-122.330,Seattle,77.9000,4.6903,0.0844,1.1678,274.3178,277.8403
2024-12-01T00:00:00Z,2024-12-01T01:00:00Z,47.600,-122.330,Seattle,73.6000,5.0681,0.0540,0.7457,273.8957,278.2181
2024-12-01T00:00:00Z,2024-12-01T05:00:00Z,47.600,-122.330,Seattle,82.3000,4.0860,0.0971,1.3433,274.4933,277.2360