예제 #1
0
    def __common_plotting(self,
                        fermi_surface,
                        plotter: pv.Plotter,
                        mode:str, 
                        text:str,
                        spin_texture:bool=False,
                        
                        camera_pos:List[float]=[1, 1, 1],
                        background_color:str or Tuple[float,float,float,float]="white",
                        perspective:bool=True,

                        show:bool=False,
                        save_2d:bool=None,
                        save_gif:str=None,
                        save_mp4:str=None,
                        save_3d:str=None):

        if mode != "plain" or spin_texture:
            plotter.add_scalar_bar(
                title=text,
                n_labels=6,
                italic=False,
                bold=False,
                title_font_size=None,
                label_font_size=None,
                position_x=0.4,
                position_y=0.01,
                color="black",)

        plotter.add_axes(
            xlabel="Kx", 
            ylabel="Ky", 
            zlabel="Kz", 
            line_width=6, 
            labels_off=False)

        if not perspective:
            plotter.enable_parallel_projection()

        plotter.set_background(background_color)
        if not show:
            plotter.show(cpos=camera_pos, screenshot=save_2d)
        if save_gif is not None:
            path = plotter.generate_orbital_path(n_points=36)
            plotter.open_gif(save_gif)
            plotter.orbit_on_path(path) 
        if save_mp4:
            path = plotter.generate_orbital_path(n_points=36)
            plotter.open_movie(save_mp4)
            plotter.orbit_on_path(path) 

        if save_3d is not None:
            plotter.save_meshio(save_3d,  fermi_surface)
예제 #2
0
def plot_boreholes_3d(df: pd.DataFrame,
                      plotter: pv.Plotter,
                      min_length: Union[float, int],
                      color_dict: dict,
                      show_labels=False,
                      labels=None,
                      ve=1,
                      **kwargs):
    """
    Plot boreholes in 3D
     df: pd.DataFrame containing the extracted borehole data
        min_length: float/int defining the minimum depth of boreholes to be plotted
        color_dict: dict containing the surface colors of the model
        labels: PyVista polydata object containing the name and coordinates of cities
        show_labels: bool for showing city labels

    Kwargs:
        radius: float/int of the radius of the boreholes plotted with PyVista, default = 10
    """

    # Checking if df is of a pandas DataFrame
    if not isinstance(df, pd.DataFrame):
        raise TypeError('Borehole data must be provided as Pandas DataFrame')

    # Checking that all necessary columns are present in the DataFrame
    if not pd.Series([
            'Index', 'Name', 'X', 'Y', 'Z', 'Altitude', 'Depth', 'formation'
    ]).isin(df.columns).all():
        raise ValueError(
            '[%s, %s, %s, %s, %s, %s, %s, %s] need to be columns in the provided DataFrame'
            %
            ('Index', 'Name', 'X', 'Y', 'Z', 'Altitude', 'Depth', 'formation'))

    # Checking that the min_limit is of type float or int
    if not isinstance(min_length, (float, int)):
        raise TypeError(
            'Minimum length for boreholes must be of type float or int')

    # Checking that the color_dict is of type dict
    if not isinstance(color_dict, dict):
        raise TypeError('Surface color dictionary must be of type dict')

    # Getting the radius for the tubes
    radius = kwargs.get('radius', 10)

    # Checking that the radius is of type int or float
    if not isinstance(radius, (int, float)):
        raise TypeError('The radius must be provided as int or float')

    # Checking if show_labels is of type bool
    if not isinstance(show_labels, bool):
        raise TypeError('Show_label must be of type bool')

    # Creating tubes for later plotting
    tubes, df_groups = create_borehole_tubes(df,
                                             min_length,
                                             color_dict,
                                             radius=radius)

    # Plotting labels
    if show_labels:
        tubes["Labels"] = labels
        plotter.add_point_labels(tubes, "Labels", point_size=5, font_size=10)

    # Plotting the borehole data
    for j in tqdm(range(len(tubes))):
        df_groups[j] = df_groups[j][1:]
        plotter.add_mesh(
            mesh=tubes[j],
            cmap=[color_dict[i] for i in df_groups[j]['formation'].unique()])

    # Setting plotting parameters
    plotter.set_scale(1, 1, ve)
    plotter.set_background(color='white')
    plotter.remove_scalar_bar()
    plotter.add_bounding_box(color='black')
    plotter.show_grid(color='black')