-
Notifications
You must be signed in to change notification settings - Fork 10
/
model-th0rnleaf.js
68 lines (64 loc) · 2.97 KB
/
model-th0rnleaf.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// NOTE: this model comes from /u/th0rnleaf
// https://old.reddit.com/r/TheSilphRoad/comments/aks0k7/weather_gone_germany/ef7jnwu/
// https://docs.google.com/spreadsheets/d/1v51qbI1egh6eBTk-NTaRy3Qlx2Y2v9kDYqmvHlmntJE/edit#gid=0
const weatherMap = ({
sunny: { dominant: 'clear', superficial: {}, windyable: true },
clear: { dominant: 'clear', superficial: {}, windyable: true },
mostlysunny: { dominant: 'clear', superficial: {}, windyable: true },
mostlyclear: { dominant: 'clear', superficial: {}, windyable: true },
partlysunny: { dominant: 'partlycloudy', superficial: {}, windyable: true },
partlysunnywshowers: { dominant: 'partlycloudy', superficial: { rain: true } },
partlysunnywtstorms: { dominant: 'partlycloudy', superficial: { rain: true } },
partlysunnywflurries: { dominant: 'partlycloudy', superficial: { snow: true } },
partlycloudy: { dominant: 'partlycloudy', superficial: {}, windyable: true },
partlycloudywshowers: { dominant: 'partlycloudy', superficial: { rain: true } },
partlycloudywtstorms: { dominant: 'partlycloudy', superficial: {}, windyable: true },
intermittentclouds: { dominant: 'partlycloudy', superficial: {}, windyable: true },
mostlycloudy: { dominant: 'cloudy', superficial: {}, windyable: true },
mostlycloudywshowers: { dominant: 'cloudy', superficial: { rain: true } },
mostlycloudywtstorms: { dominant: 'cloudy', superficial: { rain: true } },
mostlycloudywflurries: { dominant: 'cloudy', superficial: { snow: true } },
cloudy: { dominant: 'cloudy', superficial: {}, windyable: true },
hazysunshine: { dominant: 'cloudy', superficial: {}, windyable: true },
hazymoonlight: { dominant: 'cloudy', superficial: {}, windyable: true },
dreary: { dominant: 'cloudy', superficial: {}, windyable: true },
showers: { dominant: 'rain', superficial: {} },
rain: { dominant: 'rain', superficial: {} },
tstorms: { dominant: 'rain', superficial: {} },
thunderstorms: { dominant: 'rain', superficial: {} },
freezingrain: { dominant: 'rain', superficial: {} },
fog: { dominant: 'fog', superficial: {} },
rainandsnow: { dominant: 'snow', superficial: {} },
flurries: { dominant: 'snow', superficial: {} },
snow: { dominant: 'snow', superficial: {} },
windy: { dominant: 'windy', superficial: {}, windyable: true },
ice: { dominant: 'clear', superficial: {}, windyable: true },
})
const thresholds = {
dominant: {
wind: 24,
gust: 35,
},
superficial: {
// rain: 50,
// snow: 50,
wind: 16,
},
}
const aw2pogo = ({
label,
wind,
gust,
}) => {
const weather = weatherMap[label] ?? { dominant: 'unknown', superficial: {}, windyable: false }
const windy = wind >= thresholds.dominant.wind || gust >= thresholds.dominant.gust
const dominant = weather.windyable && windy ? 'windy' : weather.dominant
return {
dominant,
superficial: {
...weather.superficial,
windy: dominant !== 'windy' && (!weather.windyable && (windy || wind) >= thresholds.superficial.wind)
},
}
}
module.exports = aw2pogo