-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.py
More file actions
94 lines (81 loc) · 3.24 KB
/
run.py
File metadata and controls
94 lines (81 loc) · 3.24 KB
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import pandas as pd
import numpy as np
import argparse
import torch
import torch.nn as nn
import torch.nn.functional as F
from Util.draw import draw_h
from Util.tool import en_preprocess, unnoramlization, get_now_data
from validpreModel import ValidConfig, ValidScoreConfig, test, test_score
parser = argparse.ArgumentParser()
parser.add_argument('--year',
type=int,
default=2021,
help='year')
parser.add_argument('--month',
type=int,
default=1,
help='month')
parser.add_argument('--day',
type=int,
default=27,
help='day')
parser.add_argument('--hour',
type=int,
default=8,
choices=[i for i in range(24)],
help='hour in 24')
parser.add_argument('--immediate',
action='store_true',
default=True,
help='get immediate results or not')
parser.add_argument('--nightmode',
action='store_true',
default=False,
help='Whether to play all day')
args = parser.parse_args()
def run_immediate(config, score_config):
# get all places score to 20(default)/24(if night mode) this day
for place in config.place_name:
print("-------------------- place :", place, "--------------------")
weather_data = get_now_data(args.year, args.month, args.day, args.hour, place,config.window)
valid_data = weather_data[config.attributes_list].values.astype(np.float)
valid_data = en_preprocess(valid_data)
valid_outputs = test(config, valid_data)
score_outputs= []
for wea in valid_outputs:
score_outputs.append(test_score(score_config, wea))
# print("valid_inputs_after :\n", valid_outputs)
valid_outputs = np.array(valid_outputs)
valid_outputs[:, 2] *= 10
valid_outputs = unnoramlization(valid_outputs, 0, 70)
score_outputs = np.array(score_outputs)
print("actual_valid_outputs :\n", valid_outputs)
print("actual_score_outputs :\n", score_outputs.squeeze(1))
def run_days():
pass
if __name__ == '__main__':
if args.immediate:
print("-------------------- immediately --------------------")
attributes = ['temperature', 'humidity', 'windspeed', 'score']
print(attributes)
# set training config
config = ValidConfig("weather", "weather_LSTM_00180")
config.attributes_list = attributes
config.attributes_num = len(attributes) - 1
score_config = ValidScoreConfig("score", "score_00100")
score_config.attributes_list = attributes
score_config.attributes_num = len(attributes) - 1
# 9-20
if args.nightmode:
config.future_pred = 24 - args.hour
run_immediate(config, score_config)
elif args.nightmode == False and args.hour > 20:
print("今天太晚了!改日再玩吧")
# run_days()
else:
config.future_pred = 20 - max(args.hour, 9)
run_immediate(config, score_config)
else:
print("not immediately")
run_days()