Merge remote-tracking branch 'origin/main' into main

This commit is contained in:
Pilar Monsalvete 2023-07-31 13:32:40 -04:00
commit bc94ea04c5
2 changed files with 286 additions and 99 deletions

View File

@ -157,10 +157,10 @@ paths:
required: required:
- cities - cities
properties: properties:
cities: scenarios:
type: object type: object
description: Cities list description: List of scenarios and buildings
example: { "cities": [{ "Montreal current status": ["149_part_0_zone_0", "1_part_0_zone_0"]}]} example: { "scenarios": [{ "current status": ["01002777"]}]}
tags: tags:
- Persistence retrofit results - Persistence retrofit results
summary: Retrieve the monthly energy balance results for the given persistence in the given cities summary: Retrieve the monthly energy balance results for the given persistence in the given cities
@ -179,6 +179,12 @@ paths:
format: uuid format: uuid
description: Token expected in next operation header description: Token expected in next operation header
example: '77e1c83b-7bb0-437b-bc50-a7a58e5660ac' example: '77e1c83b-7bb0-437b-bc50-a7a58e5660ac'
'400':
description: Bad Request
content:
application/json:
schema:
$ref: '#/components/schemas/bad-request'
'403': '403':
description: Unauthorized description: Unauthorized
content: content:
@ -276,6 +282,12 @@ components:
error: error:
type: string type: string
example: 'unauthorized' example: 'unauthorized'
bad-request:
type: object
properties:
error:
type: string
example: 'Bad request'
succeed: succeed:
type: object type: object
properties: properties:
@ -300,106 +312,268 @@ components:
results: results:
type: object type: object
example: { example: {
"result":"succeed", "current status":
"results":{ [
"Montreal current status":[ {
{ "insel meb": [
"insel meb":[
{ {
"monthly_cooling":{ "monthly_cooling_peak_load": [
"0":381853.821, 0,
"1":484038.818, 0,
"2":944923.8890000001, 0,
"3":1465614.62, 6584.458113320823,
"4":2816751.71, 62924.37128642762,
"5":4673754.880000001, 57887.14012015144,
"6":5804651.86, 70751.92355485224,
"7":5113784.18, 62984.101439783015,
"8":2464006.1, 48250.59450887724,
"9":1113856.5699999998, 0,
"10":588973.45, 0,
"11":384227.386 0
} ]
}, },
{ {
"yearly_cooling":{ "yearly_cooling_peak_load": [
"0":26236437.283999998 70751.92355485224
} ]
}, },
{ {
"monthly_heating":{ "monthly_heating_peak_load": [
"0":23752326.2, 262098.65318553636,
"1":20536490.2, 265821.7159266224,
"2":16533607.4, 217944.00326807727,
"3":8818033.2, 155252.5244818504,
"4":4036963.87, 109483.75948860023,
"5":915646.973, 84631.2513243329,
"6":247277.222, 71629.71397081681,
"7":393324.463, 77627.25028728181,
"8":3161278.32, 112508.45055758546,
"9":8418375.98, 143365.05468737005,
"10":13028175.8, 178295.01091663004,
"11":21456785.2 226377.81783654366
} ]
}, },
{ {
"yearly_heating":{ "yearly_heating_peak_load": [
"0":121298284.828 265821.7159266224
} ]
},
{
"monthly_cooling_demand": [
295005.341,
404348.816,
809382.8119999999,
1423909.9100000001,
3407862.3,
7343880.86,
10326290.0,
9243987.3,
3481350.34,
1266403.6900000002,
563368.2250000001,
299075.714
]
},
{
"yearly_cooling_demand": [
38864865.308000006
]
},
{
"monthly_heating_demand": [
53757554.7,
46479308.599999994,
37117226.6,
18778937.5,
7274898.4399999995,
758257.8119999999,
22337.890600000002,
94370.8496,
5050939.94,
17157021.5,
28129459.0,
48168429.7
]
},
{
"yearly_heating_demand": [
262788742.53219998
]
},
{
"monthly_lighting_electrical_demand": [
5833171.347707521,
5262061.78651678,
5833171.347707521,
5625727.964494741,
5833171.347707521,
5642801.493977274,
5816097.818224987,
5833171.347707521,
5625727.964494741,
5833171.347707521,
5642801.493977274,
5816097.818224987
]
},
{
"yearly_lighting_electrical_demand": [
68597173.07844839
]
},
{
"monthly_appliances_electrical_demand": [
1080216.9162421336,
974455.8863919963,
1080216.9162421334,
1041801.4749064334,
1080216.9162421334,
1044963.239625421,
1077055.1515231456,
1080216.9162421334,
1041801.4749064333,
1080216.9162421336,
1044963.239625421,
1077055.1515231456
]
},
{
"yearly_appliances_electrical_demand": [
12703180.199712664
]
},
{
"monthly_domestic_hot_water_heat_demand": [
456825.0843755854,
414141.3604753232,
468484.2621310478,
459801.92885964504,
473764.6342500718,
458315.9343261062,
471613.41847213014,
470564.79267605464,
461648.6669837665,
474210.31698864425,
456916.48282534967,
464726.15139262035
]
},
{
"yearly_domestic_hot_water_heat_demand": [
5531013.0337563455
]
},
{
"monthly_heating_consumption": [
63244182.00000001,
54681539.529411756,
43667325.41176471,
22092867.647058826,
8558704.047058823,
892068.014117647,
26279.87129411765,
111024.52894117647,
5942282.282352942,
20184731.17647059,
33093481.17647059,
56668740.823529415
]
},
{
"yearly_heating_consumption": [
309163226.5084706
]
},
{
"monthly_cooling_consumption": [
91332.92291021673,
125185.3919504644,
250582.91393188853,
440838.98142414866,
1055065.7275541795,
2273647.3250773996,
3196993.808049536,
2861915.5727554183,
1077817.4427244582,
392075.4458204335,
174417.40712074307,
92593.10030959752
]
},
{
"yearly_cooling_consumption": [
12032466.039628485
]
},
{
"monthly_domestic_hot_water_consumption": [
537441.2757359828,
487225.1299709685,
551157.9554482915,
540943.4457172295,
557370.157941261,
539195.2168542426,
554839.3158495649,
553605.6384424173,
543116.0788044311,
557894.4905748756,
537548.8033239408,
546736.6486972005
]
},
{
"yearly_domestic_hot_water_consumption": [
6507074.157360407
]
},
{
"monthly_distribution_systems_electrical_consumption": [
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0
]
},
{
"yearly_distribution_systems_electrical_consumption": [
0.0
]
},
{
"monthly_on_site_electrical_production": [
1877568.0052112115,
2407257.798870815,
3166036.3496084926,
2775127.9773544166,
3179310.676411243,
3229758.071462234,
3323472.052358032,
3331301.907608147,
3009020.446469887,
2133712.041565227,
1511572.9397916023,
1439817.2575820587
]
},
{
"yearly_on_site_electrical_production": [
31185356.31301905
]
} }
], ],
"building":"149_part_0_zone_0" "building": "01002777"
}, }
{ ]
"insel meb":[ }
{
"monthly_cooling":{
"0":783396.606,
"1":1044300.2899999999,
"2":1839283.69,
"3":2594479.49,
"4":4809622.07,
"5":7720497.56,
"6":9451286.13,
"7":8666059.57,
"8":4576645.510000001,
"9":2222742.19,
"10":1180251.0999999999,
"11":759023.5599999999
}
},
{
"yearly_cooling":{
"0":45647587.766
}
},
{
"monthly_heating":{
"0":33584593.800000004,
"1":28801277.3,
"2":23248582.0,
"3":12622207.0,
"4":5935129.39,
"5":1533334.23,
"6":541973.145,
"7":763742.676,
"8":4608120.61,
"9":11964252.9,
"10":18499837.9,
"11":30418062.5
}
},
{
"yearly_heating":{
"0":172521113.451
}
}
],
"building":"1_part_0_zone_0"
}
]
}
}
not-implemented-error: not-implemented-error:
type: object type: object
properties: properties:

View File

@ -24,17 +24,30 @@ class RetrofitResults(Resource, Config):
token = {'token': _session['token']} token = {'token': _session['token']}
application_id = session(session_id)['application_id'] application_id = session(session_id)['application_id']
user_id = session(session_id)['user_id'] user_id = session(session_id)['user_id']
payload = request.get_json() payload = request.get_json()
if 'scenarios' not in payload:
return Response(json.dumps({'error': 'Bad request'}), status=400, headers=token)
# retrieve the buildings info
buildings = []
buildings_info = []
for scenario in payload['scenarios']:
key = next(iter(scenario))
for name in scenario[key]:
if name not in buildings:
buildings.append(name)
for building in buildings:
buildings_info.append(self.database.building_info(building, user_id, application_id, scenario))
print(buildings_info)
results = self.database.results(user_id, application_id, payload) results = self.database.results(user_id, application_id, payload)
if results == {}: if results == {}:
# no data found for the given parameters # no data found for the given parameters
return Response(json.dumps({'result': 'succeed', 'results': results}), status=200, headers=token) return Response(json.dumps({'result': 'succeed', 'results': results}), status=200, headers=token)
# deserialize the response to return pure json # deserialize the response to return pure json
city_name = next(iter(results)) scenario = next(iter(results))
for building_results in results[city_name]: for building_results in results[scenario]:
values = [] values = []
print(building_results)
for value in building_results['insel meb']: for value in building_results['insel meb']:
key = next(iter(value)) key = next(iter(value))
values.append({key: json.loads(str(value[key]))}) values.append({key: json.loads(str(value[key]))})