forked from kendrik-wah/cs3237_weather_nowcasting
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo.py
72 lines (48 loc) · 1.62 KB
/
demo.py
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
69
70
71
from wr_rain_pred import *
from lstm import*
import gc
from datetime import datetime
from dateutil import tz
import os
def getTime():
from_zone = tz.gettz('UTC')
to_zone = tz.gettz('Asia/Singapore')
utc = datetime.utcnow()
# Change timezone from UTC to Singapore time
utc = utc.replace(tzinfo=from_zone)
# Convert time zone
sg_time = utc.astimezone(to_zone)
year = '2020'
month = '11'
day = str(sg_time.strftime("%d"))
hour = int(sg_time.strftime("%H"))+1
minute = int(sg_time.strftime("%M"))
second = '0000'
if len(str(hour)) == 1:
hour = '0' + str(hour)
if len(str(minute)) == 1:
minute = '0' + str(minute)
time_now = year + "/" + month + "/" + day + "\t" + str(hour) + ":" + str(minute) + ":" + second
return time_now
def main():
try:
is_rain_LSTM, pr_rain_LSTM = LSTM_get_rain_prediction()
gc.collect()
is_rain_CNN, pr_rain_CNN = CNN_get_rain_prediction(lead_time=4)
gc.collect()
print("\n\n\n\n")
print("Predicted Time:", getTime())
if is_rain_LSTM:
print("LSTM -- Prediction: Rain with probability {}".format(pr_rain_LSTM))
else:
print("LSTM -- Prediction: No rain with probability {}".format(1 - pr_rain_LSTM))
if is_rain_CNN:
print("CNN -- Prediction: Rain with probability {}".format(pr_rain_CNN))
else:
print("CNN -- Prediction: No rain with probability {}".format(1-pr_rain_CNN))
print("\n\n\n\n")
except:
print("ERROR")
time.sleep(2)
if __name__ == '__main__':
main()