def create_network_layout(self, connected_buildings, network_type,
                              network_name):
        # Make sure that project path is correct
        self.config.project = self.project

        # Set config to scenario of plot
        self.config.scenario_name = self.scenario

        # Modify config inputs for this function
        self.config.network_layout.network_type = network_type
        self.config.network_layout.connected_buildings = connected_buildings

        # Ignore demand and creating plants for layouts in map
        self.config.network_layout.consider_only_buildings_with_demand = False
        self.config.network_layout.create_plant = False

        if network_name != 'today' or network_name == 'today' and newer_network_layout_exists(
                self.locator, network_type, network_name):
            network_layout = NetworkLayout(
                network_layout=self.config.network_layout)
            layout_network(network_layout,
                           self.locator,
                           output_name_network=network_name)

        # Output paths
        path_output_edges = self.locator.get_network_layout_edges_shapefile(
            network_type, network_name)
        path_output_nodes = self.locator.get_network_layout_nodes_shapefile(
            network_type, network_name)

        return path_output_edges, path_output_nodes
    def create_network_layout(self, connected_buildings, network_type, network_name):

        # Modify config inputs for this function
        self.config.network_layout.network_type = network_type
        self.config.network_layout.connected_buildings = connected_buildings
        network_layout = NetworkLayout(network_layout=self.config.network_layout)
        layout_network(network_layout, self.locator, output_name_network=network_name)

        # Output paths
        path_output_edges = self.locator.get_network_layout_edges_shapefile(network_type, network_name)
        path_output_nodes = self.locator.get_network_layout_nodes_shapefile(network_type, network_name)

        return path_output_edges, path_output_nodes
Exemplo n.º 3
0
def get_network(config, network_type, trigger_abort=True):
    # TODO: Get a list of names and send all in the json
    try:
        locator = cea.inputlocator.InputLocator(config.scenario)
        building_connectivity = get_building_connectivity(locator)
        network_type = network_type.upper()
        connected_buildings = building_connectivity[building_connectivity[
            '{}_connectivity'.format(network_type)] ==
                                                    1]['Name'].values.tolist()
        network_name = 'base'

        # Do not calculate if no connected buildings
        if len(connected_buildings) < 2:
            return None, [], None

        edges = locator.get_network_layout_edges_shapefile(
            network_type, network_name)
        nodes = locator.get_network_layout_nodes_shapefile(
            network_type, network_name)
        supply_system = locator.get_building_supply()

        no_network_file = not os.path.isfile(edges) or not os.path.isfile(
            nodes)
        supply_system_modified = os.path.getmtime(supply_system)

        # Generate network files
        if no_network_file or supply_system_modified > os.path.getmtime(
                edges) or supply_system_modified > os.path.getmtime(nodes):
            config.network_layout.network_type = network_type
            config.network_layout.connected_buildings = connected_buildings
            network_layout = NetworkLayout(
                network_layout=config.network_layout)
            layout_network(network_layout,
                           locator,
                           output_name_network=network_name)

        network_json, crs = df_to_json(edges, trigger_abort=trigger_abort)
        nodes_json, _ = df_to_json(nodes, trigger_abort=trigger_abort)
        network_json['features'].extend(nodes_json['features'])
        network_json['properties'] = {
            'connected_buildings': connected_buildings
        }
        return network_json, connected_buildings, crs
    except IOError as e:
        print(e)
        return None, [], None
Exemplo n.º 4
0
    def run_thermal_network():
        import cea.technologies.thermal_network.thermal_network as thermal_network
        from cea.technologies.network_layout.main import NetworkLayout, layout_network

        config = cea.config.Configuration(cea.config.DEFAULT_CONFIG)
        locator = cea.inputlocator.InputLocator(
            scenario=REFERENCE_CASES['open'])
        config.scenario = locator.scenario
        config.multiprocessing = True
        config.thermal_network.start_t = 100
        config.thermal_network.stop_t = 200
        config.thermal_network.network_type = 'DH'
        config.network_layout.network_type = 'DH'

        # first, create the network layout
        network_layout = NetworkLayout(config.network_layout)
        layout_network(network_layout, locator, [])
        thermal_network.main(config)
Exemplo n.º 5
0
def get_network(config, network_type, trigger_abort=True):
    # TODO: Get a list of names and send all in the json
    try:
        locator = cea.inputlocator.InputLocator(config.scenario)
        building_connectivity = get_building_connectivity(locator)
        network_type = network_type.upper()
        connected_buildings = building_connectivity[building_connectivity[
            '{}_connectivity'.format(network_type)] ==
                                                    1]['Name'].values.tolist()
        network_name = 'today'

        # Do not calculate if no connected buildings
        if len(connected_buildings) < 2:
            return None, [], None

        # Generate network files
        if newer_network_layout_exists(locator, network_type, network_name):
            config.network_layout.network_type = network_type
            config.network_layout.connected_buildings = connected_buildings
            # Ignore demand and creating plants for layout in map
            config.network_layout.consider_only_buildings_with_demand = False
            config.network_layout.create_plant = False
            network_layout = NetworkLayout(
                network_layout=config.network_layout)
            layout_network(network_layout,
                           locator,
                           output_name_network=network_name)

        edges = locator.get_network_layout_edges_shapefile(
            network_type, network_name)
        nodes = locator.get_network_layout_nodes_shapefile(
            network_type, network_name)

        network_json, crs = df_to_json(edges, trigger_abort=trigger_abort)
        nodes_json, _ = df_to_json(nodes, trigger_abort=trigger_abort)
        network_json['features'].extend(nodes_json['features'])
        network_json['properties'] = {
            'connected_buildings': connected_buildings
        }
        return network_json, connected_buildings, crs
    except IOError as e:
        print(e)
        return None, [], None
Exemplo n.º 6
0
def thermal_network_layout_to_shapefile(config, input_path_name, locator):
    connected_building_names = [
    ]  # Placeholder, this is only used in Network optimization
    network_layout = NetworkLayout(network_layout=config.network_layout)
    layout_network(network_layout, locator, connected_building_names,
                   input_path_name)