-
Notifications
You must be signed in to change notification settings - Fork 1
/
demo_fetch.py
70 lines (61 loc) · 2.52 KB
/
demo_fetch.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
import sys
from avaml.aggregatedata.__init__ import ForecastDataset, DatasetMissingLabel, \
NoBulletinWithinRangeError, NoDataFoundError
from datetime import date, timedelta
days = 2
regobs_types = [
"Faretegn",
"Tester",
"Skredaktivitet",
"Skredhendelse",
"Snødekke",
"Skredproblem",
"Skredfarevurdering"
]
expected_errors = (NoBulletinWithinRangeError, DatasetMissingLabel, NoDataFoundError)
tag_label = sys.argv[1] if len(sys.argv) > 1 else ""
tag_nolabel = tag_label + "-nolabel"
today = date.today() + timedelta(days=1)
#today = date.fromisoformat("2020-03-11")
getData = lambda regobs, days_, with_varsom: ForecastDataset\
.date(regobs_types=regobs, date=today, days=days_, use_label=use_label)\
.label(days=days_, with_varsom=with_varsom)\
.to_csv(tag=tag)
for use_label, label_str, tag in [(False, "without labels", tag_nolabel), (True, "with labels", tag_label)]:
print(f"Saving dataset for {today.isoformat()}, 0 days, {label_str}.")
try:
getData([], 0, False)
except expected_errors:
print(f"Found no data for {today.isoformat()}, 0 days, {label_str}.")
break
print(f"Saving dataset for {today.isoformat()}, 1 days, without varsom, {label_str}.")
try:
getData([], 1, False)
except expected_errors:
print(f"Found no data for {today.isoformat()}, 1 days, without varsom, {label_str}.")
break
print(f"Saving dataset for {today.isoformat()}, 1 days, with varsom, {label_str}.")
try:
getData([], 1, True)
except expected_errors:
print(f"Found no data for {today.isoformat()}, 1 days, with varsom, {label_str}.")
except_varsom = True
except_days = False
except_varsom = False
for days in [2, 3, 5, 7, 10, 14]:
if except_days:
break
for varsom, varsom_str in [(False, "without varsom"), (True, "with varsom")]:
if except_varsom and varsom:
continue
try:
for regobs, regobs_str in [([], "without regobs"), (regobs_types, "with regobs")]:
print(f"Saving dataset for {today.isoformat()}, {days} days, {varsom_str}, {regobs_str}, {label_str}.")
getData(regobs, days, varsom)
except expected_errors:
print(f"Found no data for {today.isoformat()}, {days} days, {varsom_str}, {regobs_str}, {label_str}.")
if varsom:
except_varsom = True
else:
except_days = True
break