From 249ca4058d444f140ccf0fdd04fcd6ba1a14a639 Mon Sep 17 00:00:00 2001 From: Iosefa Percival Date: Fri, 20 Sep 2024 13:20:14 -1000 Subject: [PATCH] Remove Mayavi dependency and 3D plotting function Mayavi and the associated 3D plotting function have been removed to simplify the codebase and dependency management. This change also updates the `requirements.txt`, `setup.py`, and refines the imports and function implementations in `visualize.py`. --- pyforestscan/visualize.py | 46 --------------------------------------- requirements.txt | 1 - setup.py | 1 - 3 files changed, 48 deletions(-) diff --git a/pyforestscan/visualize.py b/pyforestscan/visualize.py index 10f572e..ad8d814 100644 --- a/pyforestscan/visualize.py +++ b/pyforestscan/visualize.py @@ -1,8 +1,6 @@ import matplotlib.pyplot as plt import numpy as np -from mayavi import mlab - def plot_2d(points, x_dim='X', y_dim='Z', color_map='viridis', alpha=1.0, point_size=1, fig_size=None): """ @@ -53,47 +51,6 @@ def plot_2d(points, x_dim='X', y_dim='Z', color_map='viridis', alpha=1.0, point_ plt.show() -def plot_3d(arrays, z_dim='Z', fig_size=None): - """ - Plots a 3D visualization of the given array data. - - :param arrays: A list of dictionaries containing point data with keys 'X', 'Y', and specified z_dim. - :type arrays: list - :param z_dim: Dimension to be used for the Z-axis. Must be 'Z' or 'HeightAboveGround'. Defaults to 'Z'. - :type z_dim: str, optional - :param fig_size: Size of the figure to be plotted. If None, the size will be computed automatically based on data. - :type fig_size: tuple, optional - :return: None - :rtype: None - :raises ValueError: If the provided z_dim is not in the list of valid dimensions. - """ - valid_dims = ['Z', 'HeightAboveGround'] - if z_dim not in valid_dims: - raise ValueError(f"Invalid dimensions. Choose from: {valid_dims}") - - points = arrays[0] - x = points['X'] - y = points['Y'] - z = points[z_dim] - colors = points['HeightAboveGround'] - - if fig_size is None: - aspect_ratio = (np.max(x) - np.min(x)) / (np.max(y) - np.min(y)) - fig_size = (800 * aspect_ratio, 800) - - max_fig_size = 1600 # pixels - if max(fig_size) > max_fig_size: - scale_factor = max_fig_size / max(fig_size) - fig_size = (fig_size[0] * scale_factor, fig_size[1] * scale_factor) - - fig = mlab.figure(size=fig_size) - - pts = mlab.points3d(x, y, z, colors, colormap='viridis', scale_mode='none', scale_factor=0.5) - mlab.axes() - mlab.title('3D Point Cloud Colored by Height Above Ground') - mlab.show() - - def plot_pai(pai, extent, cmap='viridis', fig_size=None): """ Plots the Plant Area Index (PAI) using the provided data and configuration. @@ -152,9 +109,6 @@ def plot_pad_2d(pad, slice_index, axis='x', cmap='viridis', hag_values=None, hor :return: None :rtype: None """ - import matplotlib.pyplot as plt - import numpy as np - # Validate the axis parameter if axis not in ['x', 'y']: raise ValueError(f"Invalid axis: '{axis}'. Choose from 'x' or 'y'.") diff --git a/requirements.txt b/requirements.txt index 3b0abad..0619b80 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,5 +7,4 @@ shapely~=2.0.6 pandas~=2.2.2 numpy~=2.1.1 matplotlib~=3.9.2 -mayavi~=4.8.2 scipy~=1.14.1 diff --git a/setup.py b/setup.py index bbdd6e1..1273744 100644 --- a/setup.py +++ b/setup.py @@ -32,7 +32,6 @@ 'numpy>=2.1.1', 'matplotlib>=3.9.2', 'scipy>=1.14.1', - 'mayavi>=4.8.2', ], extras_require={ 'dev': [