Skip to content

Commit

Permalink
Merge pull request #2470 from architecture-building-systems/schedule-…
Browse files Browse the repository at this point in the history
…editor

Schedule reader to api
  • Loading branch information
jimenofonseca committed Nov 26, 2019
2 parents d819a09 + e62c177 commit 68e5d80
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 30 deletions.
2 changes: 1 addition & 1 deletion cea/datamanagement/schedule_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def calc_mixed_schedule(locator,
if normalizing_value == 0.0:
schedule_new_data[schedule_type] = current_schedule * 0.0
else:
schedule_new_data[schedule_type] = current_schedule / normalizing_value
schedule_new_data[schedule_type] = np.round(current_schedule/normalizing_value, 2)

# add hour and day of the week
DAY = {'DAY': ['WEEKDAY'] * 24 + ['SATURDAY'] * 24 + ['SUNDAY'] * 24}
Expand Down
44 changes: 21 additions & 23 deletions cea/glossary.csv
Original file line number Diff line number Diff line change
Expand Up @@ -280,23 +280,23 @@ SCRIPT,LOCATOR_METHOD,FILE_NAME,VARIABLE,DESCRIPTION,UNIT,VALUES,TYPE,COLOR
-,get_building_age,inputs/building-properties/age.dbf,partitions,Year of last retrofit of internal wall partitions(0 if none),[-],{0...n},int,black
-,get_building_age,inputs/building-properties/age.dbf,roof,Year of last retrofit of roof (0 if none),[-],{0...n},int,black
-,get_building_age,inputs/building-properties/age.dbf,windows,Year of last retrofit of windows (0 if none),[-],{0...n},int,black
-,get_building_occupancy,inputs/building-properties/occupancy.dbf,COOLROOM,Refrigeration rooms,m2,{0.0...1},float,red
-,get_building_occupancy,inputs/building-properties/occupancy.dbf,FOODSTORE,Food stores,m2,{0.0...1},float,orange
-,get_building_occupancy,inputs/building-properties/occupancy.dbf,GYM,Gymnasiums,m2,{0.0...1},float,yellow
-,get_building_occupancy,inputs/building-properties/occupancy.dbf,HOSPITAL,Hospitals,m2,{0.0...1},float,brown
-,get_building_occupancy,inputs/building-properties/occupancy.dbf,HOTEL,Hotels,m2,{0.0...1},float,green
-,get_building_occupancy,inputs/building-properties/occupancy.dbf,INDUSTRIAL,Light industry,m2,{0.0...1},float,blue
-,get_building_occupancy,inputs/building-properties/occupancy.dbf,LIBRARY,Libraries,m2,{0.0...1},float,grey
-,get_building_occupancy,inputs/building-properties/occupancy.dbf,MULTI_RES,Residential (multiple dwellings),m2,{0.0...1},float,purple
-,get_building_occupancy,inputs/building-properties/occupancy.dbf,COOLROOM,Refrigeration rooms,[m2],{0.0...1},float,red
-,get_building_occupancy,inputs/building-properties/occupancy.dbf,FOODSTORE,Food stores,[m2],{0.0...1},float,orange
-,get_building_occupancy,inputs/building-properties/occupancy.dbf,GYM,Gymnasiums,[m2],{0.0...1},float,yellow
-,get_building_occupancy,inputs/building-properties/occupancy.dbf,HOSPITAL,Hospitals,[m2],{0.0...1},float,brown
-,get_building_occupancy,inputs/building-properties/occupancy.dbf,HOTEL,Hotels,[m2],{0.0...1},float,green
-,get_building_occupancy,inputs/building-properties/occupancy.dbf,INDUSTRIAL,Light industry,[m2],{0.0...1},float,blue
-,get_building_occupancy,inputs/building-properties/occupancy.dbf,LIBRARY,Libraries,[m2],{0.0...1},float,grey
-,get_building_occupancy,inputs/building-properties/occupancy.dbf,MULTI_RES,Residential (multiple dwellings),[m2],{0.0...1},float,purple
-,get_building_occupancy,inputs/building-properties/occupancy.dbf,Name,Unique building ID. It must start with a letter.,[-],alphanumeric,string,black
-,get_building_occupancy,inputs/building-properties/occupancy.dbf,OFFICE,Offices,m2,{0.0...1},float,red
-,get_building_occupancy,inputs/building-properties/occupancy.dbf,PARKING,Parking,m2,{0.0...1},float,orange
-,get_building_occupancy,inputs/building-properties/occupancy.dbf,RESTAURANT,Restaurants,m2,{0.0...1},float,yellow
-,get_building_occupancy,inputs/building-properties/occupancy.dbf,RETAIL,Retail,m2,{0.0...1},float,brown
-,get_building_occupancy,inputs/building-properties/occupancy.dbf,SCHOOL,Schools,m2,{0.0...1},float,green
-,get_building_occupancy,inputs/building-properties/occupancy.dbf,SERVERROOM,Data center,m2,{0.0...1},float,blue
-,get_building_occupancy,inputs/building-properties/occupancy.dbf,SINGLE_RES,Residential (single dwellings),m2,{0.0...1},float,grey
-,get_building_occupancy,inputs/building-properties/occupancy.dbf,SWIMMING,Swimming halls,m2,{0.0...1},float,purple
-,get_building_occupancy,inputs/building-properties/occupancy.dbf,OFFICE,Offices,[m2],{0.0...1},float,red
-,get_building_occupancy,inputs/building-properties/occupancy.dbf,PARKING,Parking,[m2],{0.0...1},float,orange
-,get_building_occupancy,inputs/building-properties/occupancy.dbf,RESTAURANT,Restaurants,[m2],{0.0...1},float,yellow
-,get_building_occupancy,inputs/building-properties/occupancy.dbf,RETAIL,Retail,[m2],{0.0...1},float,brown
-,get_building_occupancy,inputs/building-properties/occupancy.dbf,SCHOOL,Schools,[m2],{0.0...1},float,green
-,get_building_occupancy,inputs/building-properties/occupancy.dbf,SERVERROOM,Data center,[m2],{0.0...1},float,blue
-,get_building_occupancy,inputs/building-properties/occupancy.dbf,SINGLE_RES,Residential (single dwellings),[m2],{0.0...1},float,grey
-,get_building_occupancy,inputs/building-properties/occupancy.dbf,SWIMMING,Swimming halls,[m2],{0.0...1},float,purple
-,get_data_benchmark,databases/sg/benchmarks/benchmark_2000w.xls:EMBODIED,CO2_target_new,Target CO2 production for newly constructed buildings,[-],{0.0...n},float,black
-,get_data_benchmark,databases/sg/benchmarks/benchmark_2000w.xls:EMBODIED,CO2_target_retrofit,Target CO2 production for retrofitted buildings,[-],{0.0...n},float,black
-,get_data_benchmark,databases/sg/benchmarks/benchmark_2000w.xls:EMBODIED,CO2_today,Present CO2 production,[-],{0.0...n},float,black
Expand Down Expand Up @@ -343,10 +343,8 @@ SCRIPT,LOCATOR_METHOD,FILE_NAME,VARIABLE,DESCRIPTION,UNIT,VALUES,TYPE,COLOR
-,get_data_benchmark,databases/sg/benchmarks/benchmark_2000w.xls:TOTAL,code,Building use. It relates to the uses stored in the input database of Zone_occupancy,[-],Those stored in Zone_occupancy,string,black
-,get_surroundings_geometry,inputs/building-geometry/surroundings.shp,Name,Unique building ID. It must start with a letter.,[-],alphanumeric,string,black
-,get_surroundings_geometry,inputs/building-geometry/surroundings.shp,floors_ag,Number of floors above ground (incl. ground floor),[-],{0...n},int,black
-,get_surroundings_geometry,inputs/building-geometry/surroundings.shp,floors_bg,"Number of floors below ground (basement, etc)",[-],{0...n},int,black
-,get_surroundings_geometry,inputs/building-geometry/surroundings.shp,geometry,TODO,TODO,TODO,TODO,black
-,get_surroundings_geometry,inputs/building-geometry/surroundings.shp,height_ag,Height above ground (incl. ground floor),[m],{0.0...n},float,black
-,get_surroundings_geometry,inputs/building-geometry/surroundings.shp,height_bg,"Height below ground (basement, etc)",[m],{0.0...n},float,black
-,get_envelope_systems,databases/ch/systems/envelope_systems.xls:CONSTRUCTION,Cm_Af,Internal heat capacity per unit of air conditioned area. Defined according to ISO 13790.,[J/Km2],{0.0...1},float,black
-,get_envelope_systems,databases/ch/systems/envelope_systems.xls:CONSTRUCTION,Description,Describes the source of the benchmark standards.,[-],[-],string,black
-,get_envelope_systems,databases/ch/systems/envelope_systems.xls:CONSTRUCTION,code,Building use. It relates to the uses stored in the input database of Zone_occupancy,[-],Those stored in Zone_occupancy,string,black
Expand Down Expand Up @@ -771,16 +769,16 @@ SCRIPT,LOCATOR_METHOD,FILE_NAME,VARIABLE,DESCRIPTION,UNIT,VALUES,TYPE,COLOR
-,get_thermal_networks,databases/ch/systems/thermal_networks.xls:PIPING CATALOG,Vdot_min_m3s,Minimum volume flow rate for the nominal diameter (DN) bin.,[m3/s],{0.0...n},float,black
-,get_weather,c:/users/assistenz/documents/github/cityenergyanalyst/cea/databases/weather/singapore.epw,EPW file variables,TODO,TODO,TODO,TODO,black
-,get_zone_geometry,inputs/building-geometry/zone.shp,Name,Unique building ID. It must start with a letter.,[-],alphanumeric,string,black
-,get_zone_geometry,inputs/building-geometry/zone.shp,floors_ag,TODO,TODO,TODO,TODO,black
-,get_zone_geometry,inputs/building-geometry/zone.shp,floors_bg,TODO,TODO,TODO,TODO,black
-,get_zone_geometry,inputs/building-geometry/zone.shp,floors_ag,Number of floors above ground (incl. ground floor),[-],{0...n},int,black
-,get_zone_geometry,inputs/building-geometry/zone.shp,floors_bg,"Number of floors below ground (basement, etc)",[-],{0...n},int,black
-,get_zone_geometry,inputs/building-geometry/zone.shp,geometry,TODO,TODO,TODO,TODO,black
-,get_zone_geometry,inputs/building-geometry/zone.shp,height_ag,Aggregated height of the walls.,[m],{0.0...n},float,black
-,get_zone_geometry,inputs/building-geometry/zone.shp,height_bg,TODO,TODO,TODO,TODO,black
data-helper,get_building_architecture,inputs/building-properties/architecture.dbf,Es,TODO,TODO,TODO,TODO,black
-,get_zone_geometry,inputs/building-geometry/zone.shp,height_bg,"Height below ground (basement, etc)",[m],{0.0...n},float,black
data-helper,get_building_architecture,inputs/building-properties/architecture.dbf,Es,Fraction of gross floor area with electrical demands.,[m2/m2],{0.0...1},float,black
data-helper,get_building_architecture,inputs/building-properties/architecture.dbf,Hs_ag,Fraction of above ground gross floor area air-conditioned.,[m2/m2],{0.0...1},float,black
data-helper,get_building_architecture,inputs/building-properties/architecture.dbf,Hs_bg,Fraction of below ground gross floor area air-conditioned.,[m2/m2],{0.0...1},float,black
data-helper,get_building_architecture,inputs/building-properties/architecture.dbf,Name,Unique building ID. It must start with a letter.,[-],alphanumeric,string,black
data-helper,get_building_architecture,inputs/building-properties/architecture.dbf,Ns,TODO,TODO,TODO,TODO,black
data-helper,get_building_architecture,inputs/building-properties/architecture.dbf,Ns,Fraction of net gross floor area.,[m2/m2],{0.0...1},float,black
data-helper,get_building_architecture,inputs/building-properties/architecture.dbf,type_cons,Type of construction. It relates to the contents of the default database of Envelope Properties: construction,[code],{T1...Tn},string,black
data-helper,get_building_architecture,inputs/building-properties/architecture.dbf,type_leak,Leakage level. It relates to the contents of the default database of Envelope Properties: leakage,[code],{T1...Tn},string,black
data-helper,get_building_architecture,inputs/building-properties/architecture.dbf,type_roof,Roof construction type (relates to values in Default Database Construction Properties),[-],{T1...Tn},string,black
Expand Down
24 changes: 20 additions & 4 deletions cea/interfaces/dashboard/api/inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import cea.inputlocator
import cea.utilities.dbf
import cea.utilities.schedule_reader
from cea.utilities.schedule_reader import read_cea_schedule, save_cea_schedule
from cea.plots.supply_system.supply_system_map import get_building_connectivity
from cea.plots.variable_naming import get_color_array
from cea.technologies.network_layout.main import layout_network, NetworkLayout
Expand Down Expand Up @@ -144,6 +144,7 @@ def put(self):
tables = form['tables']
geojsons = form['geojsons']
crs = form['crs']
schedules = form['schedules']

out = {'tables': {}, 'geojsons': {}}

Expand Down Expand Up @@ -185,6 +186,10 @@ def put(self):
if db_info['type'] == 'shp':
out['geojsons'][db] = {}

if schedules:
for building in schedules:
dict_to_schedule(locator, building, schedules[building])

return out


Expand Down Expand Up @@ -316,13 +321,24 @@ def get(self, building):

def schedule_to_dict(locator, building):
schedule_path = locator.get_building_weekly_schedules(building)
schedule_data, schedule_complementary_data = cea.utilities.schedule_reader.read_cea_schedule(schedule_path)
schedule_data, schedule_complementary_data = read_cea_schedule(schedule_path)
df = pandas.DataFrame(schedule_data).set_index(['DAY', 'HOUR'])
out = {'SCHEDULES': {schedule_type: {day: df.loc[day][schedule_type].values.tolist() for day in df.index.levels[0]}
for schedule_type in df.columns}}
out.update(schedule_complementary_data)
return out


def json_to_schedule(json):
pass
def dict_to_schedule(locator, building, schedule_dict):
schedule_path = locator.get_building_weekly_schedules(building)
schedule_data = schedule_dict['SCHEDULES']
schedule_complementary_data = {'MONTHLY_MULTIPLIER': schedule_dict['MONTHLY_MULTIPLIER'],
'METADATA': schedule_dict['METADATA']}

data = pandas.DataFrame()
for day in ['WEEKDAY', 'SATURDAY', 'SUNDAY']:
df = pandas.DataFrame({'HOUR': range(1, 25), 'DAY': [day] * 24})
for schedule_type, schedule in schedule_data.items():
df[schedule_type] = schedule[day]
data = data.append(df, ignore_index=True)
save_cea_schedule(data.to_dict('list'), schedule_complementary_data, schedule_path)
4 changes: 2 additions & 2 deletions cea/tests/test_calc_thermal_loads.config
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[test_calc_thermal_loads]
value_columns = ["E_sys_kWh", "Qcdata_sys_kWh", "Qcre_sys_kWh", "Qcs_sys_kWh", "Qhs_sys_kWh", "Qww_sys_kWh", "Tcs_sys_re_C", "Ths_sys_re_C", "Tww_sys_re_C", "Tcs_sys_sup_C", "Ths_sys_sup_C", "Tww_sys_sup_C"]
values = [397332.706, 0.0, 0.0, 54493.56, 96284.527, 19784.978, 0.0, 0.0, 26186.16, 0.0, 0.0, 171600.0]
values = [398605.066, 0.0, 0.0, 54672.056, 95673.138, 19785.29, 0.0, 0.0, 26186.16, 0.0, 0.0, 171600.0]

[test_calc_thermal_loads_other_buildings]
results = {"B01": [96284.527, 54493.56, 19784.978], "B03": [61270.984, 103288.264, 117428.537], "B02": [299345.566, 25872.039, 312647.82999999996], "B05": [127871.16, 0.0, 73559.536], "B04": [153030.22400000002, 36404.417, 17519.653000000002], "B07": [158375.001, 46013.644, 31350.313], "B06": [66140.078, 80270.72899999999, 168329.153], "B09": [136263.101, 18254.959000000003, 15161.161], "B08": [164841.764, 27644.819, 400112.534]}
results = {"B01": [95673.138, 54672.056, 19785.29], "B03": [61197.31, 103153.514, 117443.89], "B02": [299216.997, 25864.892999999996, 312687.04400000005], "B05": [127888.74399999999, 0.0, 73559.603], "B04": [153078.501, 36401.928, 17519.836], "B07": [158824.93600000002, 46099.609000000004, 31350.702], "B06": [65913.932, 83081.338, 168330.588], "B09": [136204.944, 18250.463, 15161.056], "B08": [164927.682, 27647.519999999997, 400113.04099999997]}

0 comments on commit 68e5d80

Please sign in to comment.