Commit 690bcd05 authored by Leon Pyka's avatar Leon Pyka
Browse files

separating runs in lists

parent b8cfd8c0
Loading
Loading
Loading
Loading
+25 −11
Original line number Diff line number Diff line
@@ -23,18 +23,22 @@ def get_broken_edges(filepath : str):
    for grouppath in grouppaths:
        with h5py.File(filepath_complete) as file:
            current_broken_edges = np.array(file[grouppath + "/logged_data/broken_edges"])  
        broken_edges.extend(current_broken_edges.tolist())
        broken_edges.append(current_broken_edges.tolist())
    return broken_edges

def get_vertical_edges_coordinates(edge_list, nx, ny):
    edges_coordinates_array = []
    for edge in edge_list:
    for run in edge_list:
        run_list = []
        for edge in run:
            node_1, node_2 = edge
            node_1_coordinates = [x_position(node_1,nx,ny), y_position(node_1,nx,ny), z_position(node_1,nx,ny)]  
            node_2_coordinates = [x_position(node_2,nx,ny), y_position(node_2,nx,ny), z_position(node_2,nx,ny)]  
            if node_1_coordinates[2] != node_2_coordinates[2]:
                edge_coordinates_entry = [*node_1_coordinates, *node_2_coordinates]
            edges_coordinates_array.append(edge_coordinates_entry)
                run_list.append(edge_coordinates_entry)
            
        edges_coordinates_array.append(run_list)
    return edges_coordinates_array

def get_data_dict(filepaths_dict : dict[int, str]) -> dict[int, list]:
@@ -44,20 +48,30 @@ def get_data_dict(filepaths_dict : dict[int, str]) -> dict[int, list]:
            broken_edges = []
            for filepath_i in filepath:
                current_broken_edges = get_broken_edges(filepath_i)
                broken_edges.extend(current_broken_edges)
                broken_edges.append(*current_broken_edges)
        else:
            broken_edges = get_broken_edges(filepath)
        offset_data_dict[offset] = broken_edges
    return offset_data_dict

def flatten_dict(dict_to_flatten : dict[int, list[list[int]]]) -> dict[int, list[int]]:
    new_dict = {}
    for key, val_list in dict_to_flatten.items():
        flat_list = []
        for inner_list in val_list:
            flat_list.extend(inner_list)
        new_dict[key] = flat_list
    return new_dict


def plot_distribution_of_height(edges_coordinates_dict : dict[int, list[int, int, int, int, int, int]]):
def plot_distribution_of_height(edges_coordinates_dict : dict[int, list[list[int, int, int, int, int, int]]]):
    nx = len(edges_coordinates_dict)
    width = 3
    depth = math.ceil(nx / 3)
    fig, axs = plt.subplots(depth,width)
    fig.tight_layout(pad=1.0)
    for i, (offset, edges_coordinates) in  enumerate(edges_coordinates_dict.items()): 
    edges_coordinates_dict_flat = flatten_dict(edges_coordinates_dict)
    for i, (offset, edges_coordinates) in  enumerate(edges_coordinates_dict_flat.items()): 
        z_list = [ min(edge[2], edge[5]) for edge in edges_coordinates]
        z_min = min(z_list)
        z_max = max(z_list)