I have wind direction data coming from a weather vane, and the data is represented in 0 to 359 degrees.
I want to convert this into text format (compass rose) with 16 di
Wanted to use @eudoxos but needed to pull all the parts together:
def deg_to_compass(d):
return ["N", "NNE", "NE", "ENE", "E", "ESE", "SE", "SSE",
"S", "SSW", "SW", "WSW", "W", "WNW", "NW", "NNW"] [math.floor(((d+(360/16)/2)%360)/(360/16))]
Borrrowed @Hristo markow to check the results:
for i in range(0,360):
print (i,deg_to_compass(i) == wind_deg_to_str2(i))