-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot.py
More file actions
67 lines (55 loc) · 1.98 KB
/
plot.py
File metadata and controls
67 lines (55 loc) · 1.98 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
import os
import json
import matplotlib.pyplot as plt
import numpy as np
#STAGE 1: Getting all the data
#______________________________
#get hourly data for garages and plot it
#ren, BAFC, Three Allen Center, 500 Jefferson, Jacksonville, Calhoun (faulty)
#
garage_ids = [917572, 780376, 118941, 579742, 440959, 777367]
#get hourly occupancy starting from Feb 3 2015 to Nov 30 2016
start_date = ["2015-02-03T00:00:00"]
hours_needed = [16008]
#objects to store the results
contracts = []
transients = []
peak_occupancy = []
for id in garage_ids:
for date in start_date:
for hour in hours_needed:
#print id
#creating the curl link for OCCUPANCY
url = "https://my.smarking.net/api/ds/v3/garages/"
url = url + str(id)
url = url + "/past/occupancy/from/"+date+"/"+str(hour)+"/1h?gb=User+Type"
#print url
url = 'curl "' + url+ '" -H "Authorization:Bearer vgrh8F1EuhQdVO2A1wQdCPFf38WHDHX-lXJR-2Dt"'
#print url
result = os.popen(url).read()
#print result
#parse the json file
garage_info = json.loads(result)
#objects to store the parsed result
contract = []
transient = []
for item in garage_info["value"]:
group = str(item.get("group"))
if('Contract' in group):
contract = item.get("value")
else:
transient = item.get("value")
#add the parsed result to the master list
contracts.append(contract)
transients.append(transient)
#print "contract",contract
#print "transient",transient
#plot them
#x = np.arange(0, len(contract))
#print x
#print contract
#fig = plt.figure()
#ax = plt.axes()
#ax.plot(x, contract)
#ax.plot(x, transient)
#plt.show()