-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathos_extract_unmet_hrs.rb
165 lines (164 loc) · 8.51 KB
/
os_extract_unmet_hrs.rb
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
require 'json'
class OS_extract_unmet_hrs
# Name of file you want to add template fields to:
in_json_file = "./simulations.json"
# Name of file you want this script to produce:
out_json_file = in_json_file[0, (in_json_file.length - 5)] + "_unmet_hrs.json"
output_array2 = []
file = File.read(in_json_file)
data_tables = JSON.parse(file)
archetype_unmet_hrs = {
SecondarySchool: {heating: {number: 0, max: 0, min: 10000, average: 0}, cooling: {number: 0, max: 0, min: 100000, average: 0}},
PrimarySchool: {heating: {number: 0, max: 0, min: 10000, average: 0}, cooling: {number: 0, max: 0, min: 100000, average: 0}},
SmallOffice: {heating: {number: 0, max: 0, min: 10000, average: 0}, cooling: {number: 0, max: 0, min: 100000, average: 0}},
MediumOffice: {heating: {number: 0, max: 0, min: 10000, average: 0}, cooling: {number: 0, max: 0, min: 100000, average: 0}},
LargeOffice: {heating: {number: 0, max: 0, min: 10000, average: 0}, cooling: {number: 0, max: 0, min: 100000, average: 0}},
SmallHotel: {heating: {number: 0, max: 0, min: 10000, average: 0}, cooling: {number: 0, max: 0, min: 100000, average: 0}},
LargeHotel: {heating: {number: 0, max: 0, min: 10000, average: 0}, cooling: {number: 0, max: 0, min: 100000, average: 0}},
Warehouse: {heating: {number: 0, max: 0, min: 10000, average: 0}, cooling: {number: 0, max: 0, min: 100000, average: 0}},
RetailStandalone: {heating: {number: 0, max: 0, min: 10000, average: 0}, cooling: {number: 0, max: 0, min: 100000, average: 0}},
RetailStripmall: {heating: {number: 0, max: 0, min: 10000, average: 0}, cooling: {number: 0, max: 0, min: 100000, average: 0}},
QuickServiceRestaurant: {heating: {number: 0, max: 0, min: 10000, average: 0}, cooling: {number: 0, max: 0, min: 100000, average: 0}},
FullServiceRestaurant: {heating: {number: 0, max: 0, min: 10000, average: 0}, cooling: {number: 0, max: 0, min: 100000, average: 0}},
MidriseApartment: {heating: {number: 0, max: 0, min: 10000, average: 0}, cooling: {number: 0, max: 0, min: 100000, average: 0}},
HighriseApartment: {heating: {number: 0, max: 0, min: 10000, average: 0}, cooling: {number: 0, max: 0, min: 100000, average: 0}},
Hospital: {heating: {number: 0, max: 0, min: 10000, average: 0}, cooling: {number: 0, max: 0, min: 100000, average: 0}},
Outpatient: {heating: {number: 0, max: 0, min: 10000, average: 0}, cooling: {number: 0, max: 0, min: 100000, average: 0}}
}
data_tables.each do |data_table|
output_array = []
building_type = ""
if data_table["unmet_hours"]["cooling"] >= 300 || data_table["unmet_hours"]["cooling"] >= 300
data_table["measures"].each do |measure|
if measure["name"] == "btap_create_necb_prototype_building"
building_type = measure["arguments"]["building_type"]
end
end
case building_type
when 'SecondarySchool'
if data_table["unmet_hours"]["cooling"] >= 300
archetype_unmet_hrs[:SecondarySchool][:cooling][:number] = archetype_unmet_hrs[:SecondarySchool][:cooling][:number].to_i + 1
if archetype_unmet_hrs[:SecondarySchool][:cooling][:max].to_f < data_table["unmet_hours"]["cooling"].to_f
archetype_unmet_hrs[:SecondarySchool][:cooling][:max] = data_table["unmet_hours"]["cooling"].to_f
end
if archetype_unmet_hrs[:SecondarySchool][:cooling][:min].to_f > data_table["unmet_hours"]["cooling"].to_f
archetype_unmet_hrs[:SecondarySchool][:cooling][:min] = data_table["unmet_hours"]["cooling"].to_f
end
archetype_unmet_hrs[:SecondarySchool][:cooling][:average] = archetype_unmet_hrs[:SecondarySchool][:cooling][:average].to_f + data_table["unmet_hours"]["cooling"].to_f
end
if data_table["unmet_hours"]["heating"] >= 300
archetype_unmet_hrs[:SecondarySchool][:heating][:number] = archetype_unmet_hrs[:SecondarySchool][:heating][:number].to_i + 1
if archetype_unmet_hrs[:SecondarySchool][:heating][:max].to_f < data_table["unmet_hours"]["heating"].to_f
archetype_unmet_hrs[:SecondarySchool][:heating][:max] = data_table["unmet_hours"]["heating"].to_f
end
if archetype_unmet_hrs[:SecondarySchool][:heating][:min].to_f > data_table["unmet_hours"]["heating"].to_f
archetype_unmet_hrs[:SecondarySchool][:heating][:min] = data_table["unmet_hours"]["heating"].to_f
end
archetype_unmet_hrs[:SecondarySchool][:heating][:average] = archetype_unmet_hrs[:SecondarySchool][:heating][:average].to_f + data_table["unmet_hours"]["heating"].to_f
end
when 'PrimarySchool'
if data_table["unmet_hours"]["cooling"] >= 300
archetype_unmet_hrs[:PrimarySchool][:cooling][:number] = archetype_unmet_hrs[:PrimarySchool][:cooling][:number].to_i + 1
if archetype_unmet_hrs[:PrimarySchool][:cooling][:max].to_f < data_table["unmet_hours"]["cooling"].to_f
archetype_unmet_hrs[:PrimarySchool][:cooling][:max] = data_table["unmet_hours"]["cooling"].to_f
end
if archetype_unmet_hrs[:PrimarySchool][:cooling][:min].to_f > data_table["unmet_hours"]["cooling"].to_f
archetype_unmet_hrs[:PrimarySchool][:cooling][:min] = data_table["unmet_hours"]["cooling"].to_f
end
archetype_unmet_hrs[:PrimarySchool][:cooling][:average] = archetype_unmet_hrs[:PrimarySchool][:cooling][:average].to_f + data_table["unmet_hours"]["cooling"].to_f
end
if data_table["unmet_hours"]["heating"] >= 300
archetype_unmet_hrs[:PrimarySchool][:heating][:number] = archetype_unmet_hrs[:PrimarySchool][:heating][:number].to_i + 1
if archetype_unmet_hrs[:PrimarySchool][:heating][:max].to_f < data_table["unmet_hours"]["heating"].to_f
archetype_unmet_hrs[:PrimarySchool][:heating][:max] = data_table["unmet_hours"]["heating"].to_f
end
if archetype_unmet_hrs[:PrimarySchool][:heating][:min].to_f > data_table["unmet_hours"]["heating"].to_f
archetype_unmet_hrs[:PrimarySchool][:heating][:min] = data_table["unmet_hours"]["heating"].to_f
end
archetype_unmet_hrs[:PrimarySchool][:heating][:average] = archetype_unmet_hrs[:PrimarySchool][:heating][:average].to_f + data_table["unmet_hours"]["heating"].to_f
end
if build_test[1] == 0
output_array2 << data_table
build_test[1] = 1
end
when 'SmallOffice'
if build_test[2] == 0
output_array2 << data_table
build_test[2] = 1
end
when 'MediumOffice'
if build_test[3] == 0
output_array2 << data_table
build_test[3] = 1
end
when 'LargeOffice'
if build_test[4] == 0
output_array2 << data_table
build_test[4] = 1
end
when 'SmallHotel'
if build_test[5] == 0
output_array2 << data_table
build_test[5] = 1
end
when 'LargeHotel'
if build_test[6] == 0
output_array2 << data_table
build_test[6] = 1
end
when 'Warehouse'
if build_test[7] == 0
output_array2 << data_table
build_test[7] = 1
end
when 'RetailStandalone'
if build_test[8] == 0
output_array2 << data_table
build_test[8] = 1
end
when 'RetailStripmall'
if build_test[9] == 0
output_array2 << data_table
build_test[9] = 1
end
when 'QuickServiceRestaurant'
if build_test[10] == 0
output_array2 << data_table
build_test[10] = 1
end
when 'FullServiceRestaurant'
if build_test[11] == 0
output_array2 << data_table
build_test[11] = 1
end
when 'MidriseApartment'
if build_test[12] == 0
output_array2 << data_table
build_test[12] = 1
end
when 'HighriseApartment'
if build_test[13] == 0
output_array2 << data_table
build_test[13] = 1
end
when 'Hospital'
if build_test[14] == 0
output_array2 << data_table
build_test[14] = 1
end
when 'Outpatient'
if build_test[15] == 0
output_array2 << data_table
build_test[15] = 1
end
end
output_array = {
building: data_table["building"],
geography: data_table["geography"],
unmet_hours: data_table["unmet_hours"]
}
output_array2 << output_array
end
end
File.open(out_json_file,"w") {|each_file| each_file.write(JSON.pretty_generate(output_array2))}
end