dakk / libweatherrouting

A sailing weather routing library
https://dakk.github.io/libweatherrouting
GNU General Public License v3.0
24 stars 9 forks source link

Should getWindAt return twd in radians or degrees? And potential related problems with concurrency. #12

Open kingkong-cmd opened 1 month ago

kingkong-cmd commented 1 month ago

Hi,

I've been playing around with this a bit, but got a bit confused about the getWindAt() function. It says in "docs" that twd should be in radians, but then I see this code where you use math.radians(twd) on the twd returned from getWindAt(). math.radians() converts degrees to radians, no?

Secondly, even if i change getWindAt to return twd in degrees, the twd in the Isopoint in the results are really small (like e-37) which makes me think there might be something wrong with the concurrency where it recursively does math.radians(twd) until it becomes really small in the end.

Any chance you are willing to take a look?

LINE  247 in routing.py
try:
    (twd, tws) = self.grib.getWindAt(t, p.pos[0], p.pos[1])
except Exception as e:
    raise RoutingNoWindException() from e

for twa in range(-180, 180, 5):
    twa = math.radians(twa)
    twd = math.radians(twd)
    brg = utils.reduce360(twd + twa)
dakk commented 1 month ago

GetWindAt should returns degrees, I fixed it.

Regarding the second problem, can you please code a minimal example reproducing the issue?

kingkong-cmd commented 1 month ago

Not sure what code to show, since it was basically just following the example in docs. But maybe it was not the concurrency, but instead my incorrect use of (lon, lat) that messed up the twds. If its working for you its probably just a me-problem.

dakk commented 1 month ago

I wasn't saying I'm not having the problem (I didn't tried the example in the docs); but if you provide me the code you are running I can verify if it happen in my env, and if so I'm able to fix and verify it.

kingkong-cmd commented 1 month ago

Ok, I will try to reproduce and get back to you. PS. I didn't mean literally following the example, since I used my own getwindat, and a self made track when this happened.

dakk commented 1 month ago

Oki thanks; anyway, try to reduce your code to the minimum needed to reproduce the issue (y)