-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathos_sim_extract.rb
167 lines (164 loc) · 5.39 KB
/
os_sim_extract.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
166
167
require 'json'
class OS_sim_extract
# Name of file you want to add template fields to:
in_json_file = "./simulations_20180628.json"
# Name of file you want this script to produce:
out_json_file = in_json_file[0, (in_json_file.length - 5)] + "_outtest2.json"
output_array = []
tbl_index = 0
output_array2 = []
trackindex = 0
build_test = Array.new(16, 0)
weather_locs = ["nothing", "no_building", 100000]
#Z output_array.push(weather_locs)
file = File.read(in_json_file)
data_tables = JSON.parse(file)
data_tables.each do |data_table|
building_type = nil
template_version = nil
area_scale_factor = nil
epw_file = nil
outdoor_air = false
data_table["measures"].each do |measure|
if measure["name"] == "btap_create_necb_prototype_building_scale"
building_type = measure["arguments"]["building_type"]
area_scale_factor = measure["arguments"]["area_scale_factor"]
epw_file = measure["arguments"]["epw_file"]
end
end
flag = 0
output_array.each_with_index do |weather_loc, index|
if weather_loc[0] == epw_file
weather_locs = [epw_file, building_type, area_scale_factor]
output_array[index].push(weather_locs)
output_array[index][2] += 1
flag = 1
end
end
unless flag == 1
weather_locs = [epw_file, "", 1]
output_array.push(weather_locs)
weather_locs = [epw_file, building_type, area_scale_factor]
output_array[tbl_index].push(weather_locs)
tbl_index += 1
end
case building_type
when 'SecondarySchool'
if build_test[0] == 0
output_array2 << data_table
build_test[0] = 1
end
when 'PrimarySchool'
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
# if trackindex <= 160
# output_array2 << data_table
# trackindex += 1
# end
=begin
data_table["measures"].each do |measure|
if measure["name"] == "btap_create_necb_prototype_building_scale"
building_type = measure["arguments"]["building_type"]
template_version = measure["arguments"]["template"]
area_scale_factor = measure["arguments"]["area_scale_factor"]
epw_file = measure["arguments"]["epw_file"]
elsif measure["display_name"] == "BTAPIdealAirLoadsOptionsEplus"
outdoor_air = true
end
end
extract_hash = {
:conditioned_floor_area => data_table["building"]["conditioned_floor_area_m2"],
:exterior_area => data_table["building"]["exterior_area_m2"],
:volume => data_table["building"]["volume"],
:hdd => data_table["geography"]["hdd"],
:cdd => data_table["geography"]["cdd"],
:heating_gj => data_table["end_uses"]["heating_gj"],
:cooling_gj => data_table["end_uses"]["cooling_gj"],
:ep_conditioned_floor_area_m2 => data_table["code_metrics"]["ep_conditioned_floor_area_m2"],
:os_conditioned_floor_area_m2 => data_table["code_metrics"]["os_conditioned_floor_area_m2"],
:building_tedi_gj_per_m2 => data_table["code_metrics"]["building_tedi_gj_per_m2"],
:building_medi_gj_per_m2 => data_table["code_metrics"]["building_medi_gj_per_m2"],
:building_type => building_type,
:template_version => template_version,
:epw_file => epw_file,
:area_scale_factor => area_scale_factor,
:outdoor_air => outdoor_air
}
=end
# output_array << extract_hash
end
File.open(out_json_file,"w") {|each_file| each_file.write(JSON.pretty_generate(output_array2))}
end