-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindoor_v3.1.py
59 lines (49 loc) · 1.36 KB
/
indoor_v3.1.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
#!/usr/bin/env python
#-*- coding: 'utf-8' -*-
import json
import config
import datetime
#threshold=(8.0/24.0)*0.2+(40.0/168.0)*0.3+(80.0/336.0)*0.5
threshold = (80.0/336.0)
DIR_DATAANALYSIS=config.DIR_DATAANALYSIS
INDOOR_14_PATH=DIR_DATAANALYSIS+'device_indoor_14_temp.json'
INDOOR_1_std=DIR_DATAANALYSIS+'device_indoor_1_std.json'
d14={}
d1std = {}
feeds=[]
# key=[]
a=[]
b=[]
with open(INDOOR_14_PATH,'r') as f:
indoor14=json.load(f)
for device in indoor14['feeds']:
# d14[device['device_id']]=device['rate']
b.append(device['device_id'])
with open(INDOOR_1_std,'r') as f:
indoor1std=json.load(f)
for device in indoor1std['feeds']:
# d1std[device['device_id']]=device['rate']
a.append(device['device_id'])
feeds=set(b).difference(set(a))
# for i in key:
# if i not in d1std:
# d1std[i]=0
# if i not in d14:
# d14[i]=0
# if d14[i]>threshold or d1std[i] >= 1 :
# temp={'device_id':i}
# feeds.ap
msg = {}
msg["source"] = str("device_indoor_v2 by IIS-NRL").encode("utf-8")
msg["feeds"] = feeds
utc_datetime = datetime.datetime.utcnow()
msg["version"] = utc_datetime.strftime("%Y-%m-%dT%H:%M:%SZ")
def set_default(obj):
if isinstance(obj, set):
return list(obj)
raise TypeError
result = json.dumps(msg, default=set_default)
with open(DIR_DATAANALYSIS+'device_indoor_v2.json','w') as fout:
# json.dumps(result,fout)
fout.write(result)
print(result)