Commit b8cfd8c0 authored by Leon Pyka's avatar Leon Pyka
Browse files

automated plotting of subplots

parent 32e5d726
Loading
Loading
Loading
Loading
+12 −7
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@ import mechnet as mn
import matplotlib.pyplot as plt
import numpy as np
import os
import math

def x_position(node, nx, ny):
    return (node%nx)
@@ -52,17 +53,19 @@ def get_data_dict(filepaths_dict : dict[int, str]) -> dict[int, list]:

def plot_distribution_of_height(edges_coordinates_dict : dict[int, list[int, int, int, int, int, int]]):
    nx = len(edges_coordinates_dict)
    fig, axs = plt.subplots(1,nx)
    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()): 
        z_list = [ min(edge[2], edge[5]) for edge in edges_coordinates]
        z_min = min(z_list)
        z_max = max(z_list)
        z_range = z_max - z_min
        axs[i].set_title(f"Offset {offset}")
        axs[i].hist(z_list, bins=z_range)
        axs[i].set_xlabel("z position")
        axs[i].set_ylabel("Broken edges")
        axs[i//width, i%width].set_title(f"Offset {offset}")
        axs[i//width, i%width].hist(z_list, bins=z_range+1)
        axs[i//width, i%width].set_xlabel("z position")
        axs[i//width, i%width].set_ylabel("Broken edges")
    plt.show()

def plot_edges(edges_coordinates : [int, int, int, int, int, int] ):
@@ -81,10 +84,12 @@ if __name__ == "__main__":
    filepaths = [ "/offset_1/FDB_PARSOL_SIRC-FCVC_SOG_HFBA_CPC-NIC_-_{}.h5".format(number) for number in range(1000,1010)]
    filepath_2 = "/offset_5/FDB_PARSOL_SIRC-FCVC_SOG_HFBA_CPC-NIC.h5"
    
    filepaths_dict = { 1 : [ "/offset_1/FDB_PARSOL_SIRC-FCVC_SOG_HFBA_CPC-NIC_-_{}.h5".format(number) for number in range(1000,1010)],
    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",
                    }

    data_dict = get_data_dict(filepaths_dict)