def run(self):

        self.output_bim = BimGraph()

        # MAP NODES

        for n in self.input_epjson.nodes:
            label = n.labels[0]
            if label in [
                    'Building', 'Zone', 'BuildingSurface:Detailed',
                    'FenestrationSurface:Detailed'
            ]:
                bim_label = EpjsonToBimMap.label_dict[label]
                n1 = self.output_bim.add_node(labels=bim_label)
                self._map_properties(n, n1)
class EpjsonToBimMap():
    "A mapping object to transfer gbXML to Bim"

    label_dict=\
        {'Building':'Building',
         'Zone':'Space',
         'BuildingSurface:Detailed':'Surface',
         'FenestrationSurface:Detailed':'Opening'
         }

    def __init__(self):
        self.input_epjson = None
        self.output_bim = None

    def _map_properties(self, epjson_node, bim_node):
        "Maps the node properties"
        bim_node.properties.update(epjson_node.properties)

    def run(self):

        self.output_bim = BimGraph()

        # MAP NODES

        for n in self.input_epjson.nodes:
            label = n.labels[0]
            if label in [
                    'Building', 'Zone', 'BuildingSurface:Detailed',
                    'FenestrationSurface:Detailed'
            ]:
                bim_label = EpjsonToBimMap.label_dict[label]
                n1 = self.output_bim.add_node(labels=bim_label)
                self._map_properties(n, n1)
Example #3
0
 def run(self):
     "Running the mapping, Bim object placed in self.output"
     
     o=self.output_bim=BimGraph()
     self._gbxml_dict={}
     self._bim_dict={}
     
     climate_out=o.add_node(labels='Climate')
     ground_out=o.add_node(labels='Ground')
     
     #Initial Node mappings
     for n in self.input_gbxml.nodes:
         id1=n.attributes.get('id')
         if id1: self._gbxml_dict[id1]=n
         label=n.labels[0]
         if label in ['Location','Building','Space',
                      'Surface','Opening',
                      'Construction','Layer','Material',
                      'WindowType','Glaze','Gap',
                      'Zone',
                      'Schedule','YearSchedule','WeekSchedule','DaySchedule'
                      ]:
             n1=o.add_node(labels=label)
             if id1: self._bim_dict[id1]=n1
             self._map_attributes(n,n1)
             self._map_child_nodes_text(n,n1)
             self._map_child_nodes_attributes(n,n1)
             self._map_keys(n1)
     
     #Edges and additional mapping
     for n in o.nodes:
         label=n.labels[0]
         if label in 'Building':
             self._map_building(n)
         elif label in 'Space':
             self._map_space(n)
             self._map_space_People(n)
             self._map_space_Light(n)
             self._map_space_Appliance(n)
         elif label in 'Zone':
             self._map_zone(n)
         elif label in 'Surface':
             self._map_surface(n,climate_out,ground_out)
         elif label in 'Opening':
             self._map_opening(n)
         elif label in 'Construction':
             self._map_construction(n)
         elif label in 'Material':
             self._map_material(n)
         elif label in 'WindowType':
             self._map_window_type(n)
         elif label in 'Glaze':
             self._map_glaze(n)
         elif label in 'Gap':
             self._map_gap(n)
         elif label in 'Schedule':
             self._map_schedule(n)
         for k,v in n.properties.items():
             try:
                 n.properties[k]=float(v)
             except ValueError:
                 pass
             except TypeError:
                 pass
 
     o.remove_orphan_nodes()
Example #4
0
                self._map_light_node(n)
            if 'Appliance' in labels:
                self._map_appliance_node(n)


# tests

if __name__ == '__main__':
    from pprint import pprint
    from bim_graph import BimGraph
    from energyplus_model import EnergyPlusModel

    print('TEST-BimToEpjsonMap.py')

    o = BimToIdfMap()
    g = BimGraph()
    g.read_pickle(r'../tests/bim_to_idf_map/detached_house.pickle')
    o.input_bim = g
    o.run()
    g1 = o.output_idf
    pprint(g1.graph_dict())

    g1.write_idf(r'../tests/bim_to_idf_map/detached_house.idf')

    o = EnergyPlusModel()
    epexe_fp = r'C:\EnergyPlusV8-9-0\EnergyPlus'
    idf_fp = r'../tests/bim_to_idf_map\detached_house.idf'
    epw_fp = r'C:\EnergyPlusV8-9-0\WeatherData\GBR_Birmingham.035340_IWEC.epw'
    out_fp = r'../tests/bim_to_idf_map\sim'
    o.run_energyplus(epexe_fp=epexe_fp,
                     idf_fp=idf_fp,
                self._map_space(bim_node, eso_node)
            elif 'Surface' in bim_node.labels:
                self._map_surface(bim_node, eso_node)
            elif 'RoomHeater' in bim_node.labels:
                self._map_roomHeater(bim_node, eso_node)


# tests

if __name__ == '__main__':
    from pprint import pprint
    from eso_graph import EsoGraph
    from bim_graph import BimGraph

    print('TEST-EsoToBimMap.py')

    eso = EsoGraph()
    eso.read_eso(r'../tests/eso_to_bim_map/eplusout.eso')

    bim = BimGraph()
    bim.read_pickle(r'../tests/eso_to_bim_map/detached_house.pickle')

    o = EsoToBimMap()
    o.input_eso = eso
    o.bim = bim
    o.run()
    pprint(o.bim.Climate[0].properties)
    pprint(o.bim.Space[0].properties)
    o.bim.write_pickle(
        r'../tests/eso_to_bim_map/detached_house_with_eso.pickle')
Example #6
0
            if e.name == 'next_to' and e.properties.get('type') == 'outer':
                return e.start_node
        return None


# TESTS

if __name__ == '__main__':
    from pprint import pprint
    from bim_graph import BimGraph
    import matplotlib.pyplot as plt

    print('TEST-BimGraph')

    print('TEST-INSTANTIATE GRAPH')
    o = BimGraph()
#    o.read_pickle(r'../tests/bim_graph/detached_house2.pickle')
#    print(o)
#
#    print('TEST-label_dict_of_nodes')
#    d=o.label_dict_of_ids()
#    pprint(d)
#
#    space=o.buildings[0].spaces[0]
#    d={}
#    for k,v in space.dfs.items():
#        d[k]=v.sum().iloc[0]/1000000
#    pprint(d)
#
#    print([n.id1 for n in space.surfaces])
#    print([n.id1 for n in space.external_surfaces])