From ac27b3910215b2cce7a5e8d13d5f3cd82d032c3c Mon Sep 17 00:00:00 2001 From: Ivo Sonderegger Date: Mon, 23 Oct 2023 20:10:25 +0200 Subject: [PATCH] Bugfix in calculating missing sounding wind data Resolves #79 --- src/meteoJS/Sounding.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/meteoJS/Sounding.js b/src/meteoJS/Sounding.js index cef64621..313e7db8 100644 --- a/src/meteoJS/Sounding.js +++ b/src/meteoJS/Sounding.js @@ -135,15 +135,15 @@ export class Sounding { d.v === undefined && d.wdir !== undefined && d.wspd !== undefined) { - d.u = d.wspd * Math.sin(d.wdir / 180 * Math.PI); - d.v = d.wspd * Math.cos(d.wdir / 180 * Math.PI); + d.u = -d.wspd * Math.sin(d.wdir / 180 * Math.PI); + d.v = -d.wspd * Math.cos(d.wdir / 180 * Math.PI); } else if (d.u !== undefined && d.v !== undefined && d.wdir === undefined && d.wspd === undefined) { d.wspd = Math.sqrt(Math.pow(d.u, 2) + Math.pow(d.v, 2)); - d.wdir = Math.arctan(d.u/d.v) / Math.PI * 180; + d.wdir = 270 - (Math.atan2(d.v, d.u) / Math.PI * 180); } // Humidity