diff --git a/city_model_structure/attributes/surface.py b/city_model_structure/attributes/surface.py index f41dfd61..f827c463 100644 --- a/city_model_structure/attributes/surface.py +++ b/city_model_structure/attributes/surface.py @@ -217,7 +217,6 @@ class Surface: Surface area in square meters :return: float """ - # New method to calculate area if self._area is None: alpha = 0 vec_1 = self.points[1] - self.points[0] @@ -228,9 +227,8 @@ class Surface: area = 0 print('Warning: the area of a line or point cannot be calculated. Area = 0') else: - # todo: Guilleeeee!!!! - points_2d = self.rotate_surface_to_horizontal(self) - polygon_2d = pn.Polygon(np.array(points_2d)) + points_2d = np.array(self.rotate_surface_to_horizontal()) + polygon_2d = pn.Polygon(points_2d) area = 0 for i in range(0, len(polygon_2d.points)-1): point = polygon_2d.points[i] @@ -242,20 +240,19 @@ class Surface: self._area = abs(area) return self._area - @staticmethod - def rotate_surface_to_horizontal(surface): + def rotate_surface_to_horizontal(self): z_vector = [0, 0, 1] - normal_vector = surface.normal + normal_vector = self.normal points_2d = [] x = normal_vector[0] y = normal_vector[1] if x == 0 and y == 0: # Already horizontal - for point in surface.points: + for point in self.points: points_2d.append([point[0], point[1], 0]) else: - alpha = surface.angle_between_vectors(normal_vector, z_vector) + alpha = self.angle_between_vectors(normal_vector, z_vector) rotation_line = np.cross(normal_vector, z_vector) third_axis = np.cross(normal_vector, rotation_line) w_1 = rotation_line / np.linalg.norm(rotation_line) @@ -271,7 +268,7 @@ class Surface: if rotation_base_matrix is None: print('Error processing rotation base matrix') else: - for point in surface.points: + for point in self.points: new_point = np.matmul(rotation_base_matrix, point) points_2d.append(new_point) return points_2d diff --git a/data/physics/ca_archetypes_reduced.xml b/data/physics/ca_archetypes_reduced.xml new file mode 100644 index 00000000..3c0ba43f --- /dev/null +++ b/data/physics/ca_archetypes_reduced.xml @@ -0,0 +1,171 @@ + + + + + + + + 0.11 + 1 + + + + + + + 3.05 + 1 + 130 + 0.15 + 0.15 + 3.57 + 0 + + + + + + + 0.11 + 2 + + + + + + + 3.05 + 1 + 130 + 0.15 + 0.15 + 3.57 + 0 + + + + + + + 0.11 + 2 + + + + + + + 3.05 + 1 + 130 + 0.15 + 0.15 + 4.55 + 0 + + + + + + + 0.11 + 2 + + + + + + + 3.05 + 1 + 130 + 0.15 + 0.15 + 4.55 + 0 + + + + + + + 0.11 + 2 + + + + + + + 3.05 + 1 + 130 + 0.15 + 0.15 + 4.55 + 0 + + + + + + + 0.11 + 2 + + + + + + + 3.05 + 1 + 130 + 0.15 + 0.15 + 4.55 + 0 + + + + + + + 0.11 + 2 + + + + + + + 3.05 + 1 + 130 + 0.15 + 0.15 + 4.55 + 0 + + + + + + + 0.11 + 2 + + + + + + + 3.05 + 1 + 130 + 0.15 + 0.15 + 4.55 + 0 + + diff --git a/data/physics/ca_construction_reduced.xml b/data/physics/ca_construction_reduced.xml new file mode 100644 index 00000000..ade5660d --- /dev/null +++ b/data/physics/ca_construction_reduced.xml @@ -0,0 +1,154 @@ + + + + + 0.46 OR 0.5 + 0 + 0.555 + + + 0.52 OR 0.5 + 0 + 2.702 + + + + + + #ceiling under attic + + 0.115 + 0.8 OR 0.2 + + + 0.157 + 0.8 OR 0.2 + + + 0.185 + 0.8 OR 0.2 + + + 0.199 + 0.8 OR 0.2 + + + 0.245 + 0.8 OR 0.2 + + + 0.225 + 0.8 OR 0.2 + + + 0.259 + 0.8 OR 0.2 + + + 0.301 + 0.8 OR 0.2 + + + #wall above grade + + 0.324 + 0.8 OR 0.2 + + + 0.285 + 0.8 OR 0.2 + + + 0.355 + 0.8 OR 0.2 + + + 0.411 + 0.8 OR 0.2 + + + 0.546 + 0.8 OR 0.2 + + + 0.432 + 0.8 OR 0.2 + + + 0.579 + 0.8 OR 0.2 + + + 0.664 + 0.8 OR 0.2 + + + #wall below grade + + 0.335 + 0.8 OR 0.2 + + + 0.312 + 0.8 OR 0.2 + + + 0.408 + 0.8 OR 0.2 + + + 0.510 + 0.8 OR 0.2 + + + 0.645 + 0.8 OR 0.2 + + + 1.204 + 0.8 OR 0.2 + + + 1.449 + 0.8 OR 0.2 + + + 2.083 + 0.8 OR 0.2 + + + #slab on grade + + 0.510 + 0.8 OR 0.2 + + + 1.428 + 0.8 OR 0.2 + + + 1.428 + 0.8 OR 0.2 + + + 1.428 + 0.8 OR 0.2 + + + 1.428 + 0.8 OR 0.2 + + + 3.333 + 0.8 OR 0.2 + + + 5 + 0.8 OR 0.2 + + + 5 + 0.8 OR 0.2 + + + \ No newline at end of file diff --git a/data/usage/ca_archetypes_reduced.xml b/data/usage/ca_archetypes_reduced.xml new file mode 100644 index 00000000..e8003679 --- /dev/null +++ b/data/usage/ca_archetypes_reduced.xml @@ -0,0 +1,36 @@ + + + Building Usage Library Reduced + Library created by Rabeeh from whatever norm + + Source? + + residential + All residential buildings + + 0.03 + 365 + 12 + + Persons and home appliances + 4.2 + 0.3999999999999999 + 0.5000000000000001 + 0.10000000000000009 + + + 19.5 + + + 21.0 + 18.0 + + + 25.0 + + + 0 + + + + diff --git a/factories/occupancy_feeders/demo_occupancy_parameters.py b/factories/occupancy_feeders/demo_occupancy_parameters.py index 6cf204dc..56155e32 100644 --- a/factories/occupancy_feeders/demo_occupancy_parameters.py +++ b/factories/occupancy_feeders/demo_occupancy_parameters.py @@ -6,6 +6,7 @@ contributors Pilar Monsalvete pilar_monsalvete@yahoo.es """ import pandas as pd from factories.occupancy_feeders.helpers.occupancy_helper import OccupancyHelper +from enum import Enum class DemoOccupancyParameters: @@ -20,16 +21,19 @@ class DemoOccupancyParameters: occupancy = pd.read_excel(xls, sheet_name=OccupancyHelper.pluto_occupancy_function(building.function), skiprows=[0, 1, 2, 3], nrows=39, usecols="A:AA") # todo: should we save the data type? How? - for index in range(0, 13): + number_of_schedule_types = 13 + schedules_per_schedule_type = 3 + day_types = dict({'week_day': 0, 'saturday': 1, 'sunday': 2}) + for schedule_types in range(0, number_of_schedule_types): data = pd.DataFrame() columns_names = [] name = '' - for i in range(0, 3): - row = occupancy.iloc[3*index + i] - if i == 0: - name = row[0] - columns_names.append(row[2]) - data1 = row[3:] + for schedule_day in range(0, schedules_per_schedule_type): + row_cells = occupancy.iloc[schedules_per_schedule_type*schedule_types + schedule_day] + if schedule_day == day_types['week_day']: + name = row_cells[0] + columns_names.append(row_cells[2]) + data1 = row_cells[schedules_per_schedule_type:] data = pd.concat([data, data1], axis=1) data.columns = columns_names schedules[name] = data