Commit 7ef00c1f authored by Leon Pyka's avatar Leon Pyka
Browse files

plots broken edges with errorbars

parent aad09cf2
Loading
Loading
Loading
Loading
+47 −7
Original line number Diff line number Diff line
@@ -54,6 +54,27 @@ def get_data_dict(filepaths_dict : dict[int, str]) -> dict[int, list]:
        offset_data_dict[offset] = broken_edges
    return offset_data_dict

def get_average_heights_dict(run_list : list[list[int]]):
    heights_dict = {}
    no_of_runs = len(run_list)
    for run, edge_coord_list in enumerate(run_list):
        run_list_new = []
        for edge_coord in edge_coord_list:
            z = min(edge_coord[2],edge_coord[5])
            if z not in heights_dict.keys():
                heights_dict[z] = [0 for _ in  range(no_of_runs)]
                heights_dict[z][run] += 1
            else:
                heights_dict[z][run] += 1
    average_heights_dict = {}
    for height, broken_edges in heights_dict.items():
        avg_no = np.mean(broken_edges) 
        y_error = np.std(broken_edges)
        average_heights_dict[height] = {"avg" : avg_no, "yerror" : y_error}
    return average_heights_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():
@@ -92,6 +113,19 @@ def plot_distribution_of_height(edges_coordinates_dict : dict[int, list[list[int
        axs[index].set_ylabel("Broken edges")
    plt.show()

def plot_average_per_height(average_heights_dict):
    graph_num, width, depth = set_matplotlib_dims(average_heights_dict)
    fig, axs = plt.subplots(depth, width)
    fig.tight_layout(pad=1.0)
    for i, offset in enumerate(average_heights_dict.keys()):
        index = get_index(i, graph_num, width)
        for height, subdict in average_heights_dict[offset].items():
            axs[index].plot(int(height), subdict['avg'], "x")
            axs[index].errorbar(int(height), subdict['avg'], yerr = subdict['yerror'])
    plt.show()



def plot_edges(edges_coordinates : [int, int, int, int, int, int] ):
    fig = plt.figure()
    ax = fig.add_subplot(111, projection='3d')
@@ -109,11 +143,11 @@ if __name__ == "__main__":
    filepath_2 = "/offset_5/FDB_PARSOL_SIRC-FCVC_SOG_HFBA_CPC-NIC.h5"
    
    filepaths_dict = { 0 :  [ "/offset_0/FDB_PARSOL_SIRC-FCVC_SOG_HFBA_CPC-NIC_-_{}.h5".format(number) for number in range(1000,1010)],
                       1 : [ "/offset_1/FDB_PARSOL_SIRC-FCVC_SOG_HFBA_CPC-NIC_-_{}.h5".format(number) for number in range(1000,1010)],
                       2 :  "/offset_2/FDB_PARSOL_SIRC-FCVC_SOG_HFBA_CPC-NIC.h5",
                       3 :  "/offset_3/FDB_PARSOL_SIRC-FCVC_SOG_HFBA_CPC-NIC.h5",
                       5 :  "/offset_5/FDB_PARSOL_SIRC-FCVC_SOG_HFBA_CPC-NIC.h5",
                       10 :  "/offset_10/FDB_PARSOL_SIRC-FCVC_SOG_HFBA_CPC-NIC.h5",
                      # 1 : [ "/offset_1/FDB_PARSOL_SIRC-FCVC_SOG_HFBA_CPC-NIC_-_{}.h5".format(number) for number in range(1000,1010)],
                      # 2 :  "/offset_2/FDB_PARSOL_SIRC-FCVC_SOG_HFBA_CPC-NIC.h5",
                      # 3 :  "/offset_3/FDB_PARSOL_SIRC-FCVC_SOG_HFBA_CPC-NIC.h5",
                      # 5 :  "/offset_5/FDB_PARSOL_SIRC-FCVC_SOG_HFBA_CPC-NIC.h5",
                      # 10 :  "/offset_10/FDB_PARSOL_SIRC-FCVC_SOG_HFBA_CPC-NIC.h5",
                    }

    data_dict = get_data_dict(filepaths_dict)
@@ -127,9 +161,15 @@ if __name__ == "__main__":
    nx = 64
    ny = 64
    broken_edges_coordinates_dict = {}
    average_heights_dict = {}
    for offset, broken_edges in data_dict.items():
        broken_edges_coordinates_dict[offset] = get_vertical_edges_coordinates(broken_edges, nx, ny)
        average_heights_dict[offset] = get_average_heights_dict(broken_edges_coordinates_dict[offset])
    
        
    
    plot_average_per_height(average_heights_dict)
    
    plot_distribution_of_height(broken_edges_coordinates_dict) 
    #plot_distribution_of_height(broken_edges_coordinates_dict) 
    #plot_edges(broken_edges_coordinates)
    print("cutoff prev")
 No newline at end of file