pybend.algorithms package

This package provides:

  • a set of computational methods

  • plotting functions compliant with pyBenD datastructures

  • IO methods to import/export centerlines data

  • methods to generate synthetic bend centerlines

pybend.algorithms.synthetic_bends module

Synthetic bend generators.

pybend.algorithms.synthetic_bends.circular_bend(nb_pts: int, ampl: float = 1.0) ndarray[tuple[Any, ...], dtype[float64]]

Create a circular bend.

Parameters:
  • nb_pts (int) – number of points along bend centerline

  • ampl (float, optional) – amplitude of bends. Defaults to 1.

Returns:

point coordinates

Return type:

npt.NDArray[np.float64]

pybend.algorithms.synthetic_bends.kinoshita_bend(nb_pts: int, teta_max: float, Js: float, Jf: float) ndarray[tuple[Any, ...], dtype[float64]]

Create a Kinoshita bend.

Bend centerline follows the Kinoshita curve (Kinoshita, 1961):

\[\Theta = \Theta_0 \cos\left(\frac{2\pi s}{\lambda}\right) + \Theta_0^3\left(J_s \sin\left(3\frac{2\pi s}{\lambda}\right) - J_f \cos\left(3\frac{2\pi s}{\lambda}\right)\right)\]

where \(\Theta\) is the local angle from x axis, \(\Theta_0\) the maximum angle, \(s\) the curvilinear coordinate, \(\lambda\) the wavelength, \(J_s\) the skewness coefficient, and \(J_f\) the flattening coefficient.

Inflection point may be downstream the first point at \(\Theta = \Theta_0\), then the bend between inflection points is determined from:

  1. compute point coordinates over a bit more than a wavelength,

  2. find inflection points

  3. return coords in-between inflection points

Parameters:
  • nb_pts (int) – number of points along bend centerline

  • teta_max (float) – maximum angle (rad) from horizontal axis

  • Js (float) – skewness coefficient. If positive, bends are left skewed, if negative bends are right skewed.

  • Jf (float) – flatness coefficient. If positive, bends are more elongated, if negative bends are more flat.

Returns:

point coordinates

Return type:

npt.NDArray[np.float64]

pybend.algorithms.synthetic_bends.mirror(coords: ndarray[tuple[Any, ...], dtype[float64]], nb_pts: int) ndarray[tuple[Any, ...], dtype[float64]]

Function to add points at the beginning and end of the list.

Parameters:
  • coords (npt.NDArray[np.float64]) – input coordinates

  • nb_pts (int) – number of points to add

Returns:

new coordinates with added points

Return type:

npt.NDArray[np.float64]

pybend.algorithms.geometry_functions module

Useful geometry functions.

pybend.algorithms.geometry_functions.barycenter(l_val: list[float], l_pond: list[float]) float

Compute the weighted average of values in l_val.

Parameters:
  • l_val (list[float]) – List of values to compute the mean.

  • l_pond (list[float]) – List of weights for each value of l_val.

Returns:

weighted mean.

Return type:

float

pybend.algorithms.geometry_functions.compute_colinear(pt1: ndarray[tuple[Any, ...], dtype[float64]] | Sequence[float], pt2: ndarray[tuple[Any, ...], dtype[float64]] | Sequence[float], k: float) ndarray[tuple[Any, ...], dtype[float64]]

Return a point which is k times (pt2-pt1) from pt1.

Parameters:
  • pt1 (npt.NDArray[np.float64] | Sequence[float]) – Coordinates of the first point.

  • pt2 (npt.NDArray[np.float64] | Sequence[float]) – Coordinates of the second point.

  • k (float) – Factor

Returns:

Array with computed coordinates.

Return type:

NDArray[float]

pybend.algorithms.geometry_functions.distance(pt1: ndarray[tuple[Any, ...], dtype[float64]] | Sequence[float], pt2: ndarray[tuple[Any, ...], dtype[float64]] | Sequence[float], prec: int = 4) float

Distance between pt1 and pt2.

Parameters:
  • pt1 (npt.NDArray[np.float64] | Sequence[float]) – Coordinates of the first point.

  • pt2 (npt.NDArray[np.float64] | Sequence[float]) – Coordinates of the second point.

  • prec (int) – Precision to round distances (i.e., number of decimals)

Returns:

Distance between the 2 points.

Return type:

float

pybend.algorithms.geometry_functions.distance_arrays(pts1: ndarray[tuple[Any, ...], dtype[float64]], pts2: ndarray[tuple[Any, ...], dtype[float64]], prec: int = 4) ndarray[tuple[Any, ...], dtype[float64]]

Compute the distance between points.

Parameters:
  • pts1 (NDArray[float]) – 2D array with coordinates of the first points, 1 point per row.

  • pts2 (NDArray[float]) – 2D array with coordinates of the second points, 1 point per row.

  • prec (int, optional) – Precision to round distances (i.e., number of decimals) Defaults to 4.

Returns:

1D array with computed distances between each pair of points.

Return type:

NDArray[float]

pybend.algorithms.geometry_functions.get_MP(dir_trans: ndarray[tuple[Any, ...], dtype[float64]] = array([1., 0.]), ref: ndarray[tuple[Any, ...], dtype[float64]] = array([1., 0.])) ndarray[tuple[Any, ...], dtype[float64]]

Get the rotation 2D matrix between ref and dir_trans.

Parameters:
  • dir_trans (NDArray[float], optional) – Direction. Defaults to np.array((1., 0.)).

  • ref (NDArray[float], optional) – Reference direction. Defaults to np.array((1., 0.)).

Returns:

Array corresponding to rotation 2D matrix.

Return type:

NDArray[float]

pybend.algorithms.geometry_functions.get_angle_between_vectors(vec1: ndarray[tuple[Any, ...], dtype[float64]], vec2: ndarray[tuple[Any, ...], dtype[float64]]) float

Get the oriented angle between two vectors.

Parameters:
  • vec1 (npt.NDArray[np.float64]) – first vector

  • vec2 (npt.NDArray[np.float64]) – second vector

Returns:

angle between the two vectors.

Return type:

float

pybend.algorithms.geometry_functions.normal(vec: ndarray[tuple[Any, ...], dtype[float64]]) ndarray[tuple[Any, ...], dtype[float64]]

Compute the normalized orthogonal vector to nput.

Parameters:

vec (NDArray[float]) – Coordinates of the vector.

Returns:

Coordinates of the normalized orthogonal vector.

Return type:

NDArray[float]

pybend.algorithms.geometry_functions.orthogonal_distance(pt: ndarray[tuple[Any, ...], dtype[float64]], seg_pt1: ndarray[tuple[Any, ...], dtype[float64]], seg_pt2: ndarray[tuple[Any, ...], dtype[float64]], prec: int = 4) float

Orthogonal distance between pt and its projection on segment.

Parameters:
  • pt (npt.NDArray[np.float64] | Sequence[float]) – Coordinates of the point.

  • seg_pt1 (npt.NDArray[np.float64] | Sequence[float]) – Coordinates of the first point of the segment.

  • seg_pt2 (npt.NDArray[np.float64] | Sequence[float]) – Coordinates of the second point of the segment.

  • prec (int) – Precision to round distances (i.e., number of decimals)

Returns:

Distance between the 2 points.

Return type:

float

pybend.algorithms.geometry_functions.perp(vec: ndarray[tuple[Any, ...], dtype[float64]]) ndarray[tuple[Any, ...], dtype[float64]]

Compute the orthogonal vector to input.

Parameters:

vec (2DArray[float]) – Coordinates of the vector.

Returns:

Coordinates of the orthogonal vector.

Return type:

2DArray[float]

pybend.algorithms.geometry_functions.project_orthogonal(pt: ndarray[tuple[Any, ...], dtype[float64]], pt1: ndarray[tuple[Any, ...], dtype[float64]], pt2: ndarray[tuple[Any, ...], dtype[float64]]) ndarray[tuple[Any, ...], dtype[float64]]

Compute the point, image of pt projected on the vector vec=(pt2-pt1).

Parameters:
  • pt (NDArray[float]) – Coordinates of the point to project.

  • pt1 (NDArray[float]) – Coordinates of the first point of the line.

  • pt2 (NDArray[float]) – Coordinates of the second point of the line.

Returns:

Coordinates of the projected point.

Return type:

NDArray[float]

pybend.algorithms.geometry_functions.seg_intersect(pt11: ndarray[tuple[Any, ...], dtype[float64]], pt12: ndarray[tuple[Any, ...], dtype[float64]], pt21: ndarray[tuple[Any, ...], dtype[float64]], pt22: ndarray[tuple[Any, ...], dtype[float64]]) ndarray[tuple[Any, ...], dtype[float64]]

Compute the intersection point to the segments (pt11,pt12), (pt21,pt22).

Parameters:
  • pt11 (NDArray[float]) – Coordinates of the 1st point of the first line

  • pt12 (NDArray[float]) – Coordinates of the 2nd point of the first line

  • pt21 (NDArray[float]) – Coordinates of the 1st point of the second line

  • pt22 (NDArray[float]) – Coordinates of the 2nd second of the second line

Returns:

Coordinates of the intersection point.

Return type:

NDArray[float]

pybend.algorithms.centerline_process_functions module

Algorithms for centerline processing.

pybend.algorithms.centerline_process_functions.clpoints2coords(cl_pts: list[ClPoint]) ndarray[tuple[Any, ...], dtype[float64]]

Transform a list of ClPoint into a numpy array (1 point per row).

Parameters:

cl_pts (list[ClPoint]) – List of ClPoint.

Returns:

Array of point coordinates.

Return type:

NDArray[float]

pybend.algorithms.centerline_process_functions.compute_curvature(XY: ndarray[tuple[Any, ...], dtype[float64]]) ndarray[tuple[Any, ...], dtype[float64]]

Compute curvature of an ensemble of points.

Code was modified from https://github.com/zsylvester/curvaturepy/blob/master/cline_analysis.py

Parameters:

XY (npt.NDArray[np.float64]) – 2D array with XY coordinates.

Returns:

curvature at each points

Return type:

npt.NDArray[np.float64]

pybend.algorithms.centerline_process_functions.compute_curvature_at_point(pt1: ndarray[tuple[Any, ...], dtype[float64]], pt2: ndarray[tuple[Any, ...], dtype[float64]], pt3: ndarray[tuple[Any, ...], dtype[float64]]) float

Compute curvature from 3 points.

Parameters:
  • pt1 (NDArray[float]) – Coordinates of the first point.

  • pt2 (NDArray[float]) – Coordinates of the second point.

  • pt3 (NDArray[float]) – Coordinates of the third point.

Returns:

Value of the curvature.

Return type:

float

pybend.algorithms.centerline_process_functions.compute_curvature_at_point_Menger(pt1: ndarray[tuple[Any, ...], dtype[float64]], pt2: ndarray[tuple[Any, ...], dtype[float64]], pt3: ndarray[tuple[Any, ...], dtype[float64]]) float

Compute curvature from 3 points according to Menger formula.

Parameters:
  • pt1 (NDArray[float]) – Coordinates of the first point.

  • pt2 (NDArray[float]) – Coordinates of the second point.

  • pt3 (NDArray[float]) – Coordinates of the third point.

Returns:

Absolute value of the curvature.

Return type:

float

pybend.algorithms.centerline_process_functions.compute_curvature_at_point_flumy(pt1: ndarray[tuple[Any, ...], dtype[float64]], pt2: ndarray[tuple[Any, ...], dtype[float64]], pt3: ndarray[tuple[Any, ...], dtype[float64]]) float

Compute the curvature according to the formula used in Flumy.

Parameters:
  • pt1 (NDArray[float]) – Coordinates of the first point.

  • pt2 (NDArray[float]) – Coordinates of the second point.

  • pt3 (NDArray[float]) – Coordinates of the third point.

Returns:

Value of the curvature.

Return type:

float

pybend.algorithms.centerline_process_functions.compute_cuvilinear_abscissa(XY: ndarray[tuple[Any, ...], dtype[float64]]) ndarray[tuple[Any, ...], dtype[float64]]

Compute curvilinear abscissa from cartesian XY coordinates.

Parameters:

XY (NDArray[float]) – 2D array with XY coordinates.

Returns:

Array of curvilinear abscissa values.

Return type:

NDArray[float]

pybend.algorithms.centerline_process_functions.compute_esperance(curvature: ndarray[tuple[Any, ...], dtype[float64]], curv_abscissa: ndarray[tuple[Any, ...], dtype[float64]], n: float) float

Get average abscissa using curvature distribution as weighting function.

Parameters:
  • curvature (npt.NDArray[np.float64]) – curvature distrution function

  • curv_abscissa (npt.NDArray[np.float64]) – curvilinear abscissa

  • n (float) – exponent

Returns:

average abscissa.

Return type:

float

pybend.algorithms.centerline_process_functions.compute_half_angle_variation(normal: ndarray[tuple[Any, ...], dtype[float64]], shift: int = 0) int

Get the index of half path angle variation.

Parameters:
  • normal (npt.NDArray[np.float64]) – normal vectors to channel path

  • shift (int) – first and last point shift to compute angle deviation

Returns:

index of median curvature

Return type:

int

pybend.algorithms.centerline_process_functions.compute_kurtosis(curvature: ndarray[tuple[Any, ...], dtype[float64]], curv_abscissa: ndarray[tuple[Any, ...], dtype[float64]], n: float) float

Compute the kurtosis coefficient of curvature distribution function.

Parameters:
  • curvature (npt.NDArray[np.float64]) – curvature distrution function

  • curv_abscissa (npt.NDArray[np.float64]) – curvilinear abscissa

  • n (float) – exponent

Returns:

kurtosis coefficient.

Return type:

float

pybend.algorithms.centerline_process_functions.compute_median_curvature_index(curvature: ndarray[tuple[Any, ...], dtype[float64]], n: float) int

Get median abscissa using curvature distribution as weighting function.

Parameters:
  • curvature (npt.NDArray[np.float64]) – curvature array

  • n (float) – exponent value

Returns:

index of median curvature

Return type:

int

pybend.algorithms.centerline_process_functions.compute_point_displacements(l_pt: list[ndarray[tuple[Any, ...], dtype[float64]]], dir_trans: ndarray[tuple[Any, ...], dtype[float64]] = array([1., 0.]), ref: ndarray[tuple[Any, ...], dtype[float64]] = array([1., 0.])) tuple[ndarray[tuple[Any, ...], dtype[float64]], ndarray[tuple[Any, ...], dtype[float64]]]

Compute the displacements of a serie of points.

Parameters:
  • l_pt (list[NDArray[float]]) – List of point coordinates.

  • dir_trans (NDArray[float], optional) – Direction. Defaults to np.array((1., 0.)).

  • ref (NDArray[float], optional) – Reference direction. Defaults to np.array((1., 0.)).

Returns:

tuple containing:
  • Displacement in-between each successive points of the serie.

  • Displacement between first and last points of the serie.

Return type:

tuple[NDArray[float], NDArray[float]]

pybend.algorithms.centerline_process_functions.compute_skewness(curvature: ndarray[tuple[Any, ...], dtype[float64]], curv_abscissa: ndarray[tuple[Any, ...], dtype[float64]], n: float) float

Compute Pearson’s skewness coeff of curvature distribution function.

Parameters:
  • curvature (npt.NDArray[np.float64]) – curvature distrution function

  • curv_abscissa (npt.NDArray[np.float64]) – curvilinear abscissa

  • n (float) – exponent

Returns:

skewness coefficient.

Return type:

float

pybend.algorithms.centerline_process_functions.compute_variance(curvature: ndarray[tuple[Any, ...], dtype[float64]], curv_abscissa: ndarray[tuple[Any, ...], dtype[float64]], n: float) tuple[float, float]

Get variance abscissa from curvature distribution as weighting function.

Parameters:
  • curvature (npt.NDArray[np.float64]) – curvature distrution function

  • curv_abscissa (npt.NDArray[np.float64]) – curvilinear abscissa

  • n (float) – exponent

Returns:

tuple containing the variance and std deviation.

Return type:

tuple[float, float]

pybend.algorithms.centerline_process_functions.filter_consecutive_indices(values: ndarray[tuple[Any, ...], dtype[int64]], lag: int) ndarray[tuple[Any, ...], dtype[int64]]

Filter consecutive indices.

Parameters:
  • values (npt.NDArray[np.int64]) – indices to filter

  • lag (int) – lag between 2 consecutive indices

Returns:

filtered indices

Return type:

npt.NDArray[np.int64]

pybend.algorithms.centerline_process_functions.find_2_closest_points(dataset2: DataFrame, x_prop: str, y_prop: str, j1: int, pt_new: ndarray[tuple[Any, ...], dtype[float64]]) tuple[int, int, float, float]

Find the 2 closest points from dataset1 in dataset2.

Parameters:
  • dataset2 (DataFrame) – DataFrame containing x,y coordinates where to find the closest points.

  • x_prop (str, optional) – Column name of x coordinate. Defaults to “X”.

  • y_prop (str, optional) – Column name of y coordinate. Defaults to “Y”.

  • j1 (int) – index of previous found point for optimization.

  • pt_new (NDArray[float]) – Reference points from which to compute the distances.

Returns:

tuple containing the following values:
  • index1: index of the closest (first) point in dataset2

  • index2: index of the second closest point in dataset2

  • d1: distance to the closest point

  • d2: distance to the second closest point

Return type:

tuple[int, int, float, float]

pybend.algorithms.centerline_process_functions.find_2_closest_points_mono_proc(dataset1: DataFrame, dataset2: DataFrame, x_prop: str = 'X', y_prop: str = 'Y') DataFrame

Find the 2 closest points from dataset1 in dataset2 using monoproc.

Parameters:
  • dataset1 (DataFrame) – DataFrame containing x,y coordinates

  • dataset2 (DataFrame) – DataFrame containing x,y coordinates where to find the closest points.

  • x_prop (str, optional) – Column name of x coordinate. Defaults to “X”.

  • y_prop (str, optional) – Column name of y coordinate. Defaults to “Y”.

Returns:

DataFrame of size (dataset1.shape[0], 4) where columns are:
  • index1: index of the closest (first) point in dataset2

  • index2: index of the second closest point in dataset2

  • d1: distance to the closest point

  • d2: distance to the second closest point

Return type:

DataFrame

pybend.algorithms.centerline_process_functions.find_2_closest_points_multi_proc(dataset1: DataFrame, dataset2: DataFrame, x_prop: str = 'X', y_prop: str = 'Y', nb_procs: int = 1) DataFrame

Find the 2 closest points from dataset1 in dataset2 using multiproc.

Parameters:
  • dataset1 (DataFrame) – DataFrame containing x,y coordinates

  • dataset2 (DataFrame) – DataFrame containing x,y coordinates where to find the closest points.

  • x_prop (str, optional) – Column name of x coordinate. Defaults to “X”.

  • y_prop (str, optional) – Column name of y coordinate. Defaults to “Y”.

  • nb_procs (int, optional) – Number of processor to use. Defaults to 1.

Returns:

DataFrame of size (dataset1.shape[0], 4) where columns are:
  • index1: index of the closest (first) point in dataset2

  • index2: index of the second closest point in dataset2

  • d1: distance to the closest point

  • d2: distance to the second closest point

Return type:

DataFrame

pybend.algorithms.centerline_process_functions.find_inflection_points(curvature: ndarray[tuple[Any, ...], dtype[float64]], lag: int) ndarray[tuple[Any, ...], dtype[int64]]

Find inflection points from curvature array.

Inflection points are determine such as the curvature change of sign. A given point at index i is an inflection point if the following condition is met: \(sign(C_{i-1}+C_{i}) != sign(C_{i}+C_{i+1})\).

Parameters:
  • curvature (NDArray[np.float64]) – List of inflection point indexes.

  • lag (int) – number of points between two consecutive inflection points

Returns:

inflection point indices

Return type:

npt.NDArray[np.int64]

pybend.algorithms.centerline_process_functions.find_inflection_points_from_peaks(curvature: ndarray[tuple[Any, ...], dtype[float64]], curv_threshold: float = 0.1) ndarray[tuple[Any, ...], dtype[int64]]

Find inflection points from curvature array.

Inflection points are determine such as the opposite of absolute values of curvature reach local maxima using scipy.signal.find_peaks function.

Parameters:
  • curvature (NDArray[np.float64]) – curvature of each point.

  • curv_threshold (float) – curvature threshold for peak detection. Defaults to 0.001.

Returns:

inflection point indices

Return type:

npt.NDArray[np.int64]

pybend.algorithms.centerline_process_functions.get_keys_from_to(all_keys: list[str], key_min: int = 0, key_max: int = 999999, sort_reverse: bool = False) list[str]

Extract keys from key_min to key_max from the list all_keys.

Parameters:
  • all_keys (list[str]) – List of keys that can be cast to int values.

  • key_min (int, optional) – Minimum key. Defaults to 0.

  • key_max (int, optional) – Maximum key. Defaults to 999999.

  • sort_reverse (bool, optional) – If True, sorting is descending. Defaults to False.

Returns:

List of extracted keys.

Return type:

list

pybend.algorithms.centerline_process_functions.resample_path(x: ndarray[tuple[Any, ...], dtype[float64]], y: ndarray[tuple[Any, ...], dtype[float64]], nb_pts: int = 0, s: float = 0) ndarray[tuple[Any, ...], dtype[float64]]

Resample coordinates with nb_pts points according to spline function.

Parameters:
  • x (NDArray[float]) – x coordinates

  • y (NDArray[float]) – y coordinates

  • nb_pts (int, optional) – Number of points to return. If nb_pts equals 0, return (x,y) points without resampling. Defaults to 0.

  • s (float, optional) – Smoothing parameter of B-spline interpolation. Defaults to 0.

Returns:

Coordinates of the new points.

Return type:

NDArray[float] | tuple[NDArray[float], NDArray[float]]

pybend.algorithms.centerline_process_functions.sort_key(labels: list[str], reverse: bool = False) list[str]

Sort the labels.

Parameters:
  • labels (list[str]) – List of labels that can be cast to int/float values

  • reverse (bool, optional) – if True, sorting is descending. Defaults to False.

Returns:

List of sorted labels.

Return type:

labels2 (list[str])

pybend.algorithms.plot_functions module

Plotting helpers for pybend.

pybend.algorithms.plot_functions._get_keys_to_plot(all_keys: ndarray[tuple[Any, ...], dtype[int64]], nb_cl: int) ndarray[tuple[Any, ...], dtype[int64]]

Get keys to plot according to the number of centerlines.

Parameters:
  • all_keys (npt.NDArray[np.int64]) – All centerline ages

  • nb_cl (int) – Number of centerlines

Returns:

list of centerline ages to plot

Return type:

npt.NDArray[np.int64]

pybend.algorithms.plot_functions._plot_bend_evol_trajectories(ax: Axes, bend_evol: BendEvolution, plot_apex_trajec: bool, plot_middle_trajec: bool, plot_centroid_trajec: bool) None

Plot BendEvolution characteristic point trajectories if needed.

Parameters:
  • ax (Axes) – Axes where to plot

  • bend_evol (BendEvolution) – BendEvolution object

  • plot_apex_trajec (bool, optional) – if True, plot bend apex trajectory.

  • plot_middle_trajec (bool, optional) – if True, plot bend middle point trajectory.

  • plot_centroid_trajec (bool, optional) – if True, plot bend centroid trajectory.

pybend.algorithms.plot_functions._plot_warping(ax: Axes, cl_collec: CenterlineCollection, indexes: dict[int, tuple[int, int]] = {}) None

Plot centerline warping.

Parameters:
  • ax (Axes) – Axes where to plot

  • cl_collec (CenterlineCollection) – CenterlineCollection object

  • indexes (dict[int, tuple[int, int]]) – dictionnary containing a list of indexes of centerline points to plot for each ages Defaults to empty dictionnary.

pybend.algorithms.plot_functions._update_plot_properties(filepath: str, domain: tuple[tuple[float, float], tuple[float, float]], show: bool = False) None

Update plot properties.

Parameters:
  • filepath (str) – directory where to export figure if not empty

  • domain (tuple[tuple[float, float], tuple[float, float]]) – plot limits ((xmin, xmax), (ymin, ymax))

  • show (bool, optional) – if True, show figure. Defaults to False.

pybend.algorithms.plot_functions.plot_bend_evol(ax: Axes, cl_collec: tuple[CenterlineCollection], bend_evol: BendEvolution, nb_cl: int = 999, domain: tuple[tuple[float, float], tuple[float, float]] = ((), ()), annotate: bool = False, plot_apex: bool = True, plot_inflex: bool = False, plot_middle: bool = False, plot_centroid: bool = False, plot_centroid_trajec: bool = False, plot_apex_trajec: bool = False, plot_middle_trajec: bool = False, plot_section: bool = False, plot_warping: bool = False, color_bend: bool = False, markersize: float = 2, cmap_name: str = 'Blues') None

Plot BendEvolution object.

Parameters:
  • ax (Axes) – Axes where to plot.

  • cl_collec (tuple[CenterlineCollection]) – CenterlineCollection object

  • bend_evol (BendEvolution) – BendEvolution object to plot.

  • nb_cl (int, optional) – Number of centerline to plot. Defaults to 999 (i.e., plot all centerlines).

  • domain (tuple[tuple[float, float],tuple[float, float]]) – display domain

  • annotate (bool, optional) – if True, add bend ids. Defaults to False.

  • plot_apex (bool, optional) – if True, plot bend apex. Defaults to True.

  • plot_inflex (bool, optional) – if True, plot inflection points. Defaults to False.

  • plot_middle (bool, optional) – if True, plot bend middle point. Defaults to False.

  • plot_centroid (bool, optional) – if True, plot bend centroid. Defaults to False.

  • plot_centroid_trajec (bool, optional) – if True, plot bend centroid trajectory. Defaults to False.

  • plot_apex_trajec (bool, optional) – if True, plot bend apex trajectory. Defaults to False.

  • plot_middle_trajec (bool, optional) – if True, plot bend middle point trajectory. Defaults to False.

  • plot_section (bool, optional) – if True, plot section lines. Defaults to False.

  • plot_warping (bool, optional) – if True, plot channel point trajectories. Defaults to False.

  • annot_text_size (float, optional) – Text size for annotations. Defaults to 10.

  • color_bend (bool, optional) – if True, bends are colored in blue and red according to UP and DOWN side respectively. Defaults to True.

  • linewidth (float, optional) – Line width. Defaults to 1.

  • markersize (float, optional) – Marker size.

  • cmap_name (str, optional) – Name of the color map to use. Defaults to “Blues”.

pybend.algorithms.plot_functions.plot_bends(ax: Axes, cl_points: tuple[list[ClPoint]], bends: list[Bend], domain: tuple[tuple[float, float], tuple[float, float]] = ((), ()), annotate: bool = False, plot_apex: bool = True, plot_inflex: bool = False, plot_middle: bool = False, plot_centroid: bool = False, plot_normal: bool = False, scale_normal: float = 1.0, annot_text_size: float = 10, color_bend: bool = False, alpha: float = 1, linewidth: float = 1, markersize: float = 2, cl_color: str | tuple[float, float, float, float] | None = None, plot_apex_proba: bool = False, plot_property: bool = False, property_name: str = '', rotate: bool = False) None

Plot Bend objects.

Parameters:
  • ax (Axes) – Axes where to plot.

  • cl_points (tuple[list[ClPoint]]) – list of ClPoint objects

  • bends (list[Bend]) – list of Bend objects to plot.

  • domain (tuple[tuple[float, float], tuple[float, float]]) – display domain

  • annotate (bool, optional) – if True, add bend ids. Defaults to False.

  • plot_apex (bool, optional) – if True, plot bend apex. Defaults to True.

  • plot_inflex (bool, optional) – if True, plot inflection points. Defaults to False.

  • plot_middle (bool, optional) – if True, plot bend middle point. Defaults to False.

  • plot_centroid (bool, optional) – if True, plot bend centroid. Defaults to False.

  • plot_normal (bool, optional) – if True, plot normal vector of channel points. Defaults to False.

  • scale_normal (float, optional) – Scale for normal vectors. Defaults to 1.0.

  • annot_text_size (float, optional) – Text size for annotations. Defaults to 10.

  • color_bend (bool, optional) – if True, bends are colored in blue and red according to UP and DOWN side respectively. Defaults to True.

  • alpha (float, optional) – Transparency. Defaults to 1.0.

  • linewidth (float, optional) – Line width. Defaults to 1.

  • markersize (float, optional) – Marker size.

  • cl_color (Optional[tuple[Any]]) – Centerline color. If plot_bend is set to True, centerline color is overwrite. Defaults to None.

  • plot_apex_proba (bool, optional) – If True, color channel points with apex probability property values. Defaults to False.

  • plot_property (bool, optional) – If True, color channel points with input property values. Defaults to False.

  • property_name (str, optional) – If plot_property is True, name if the property to plot. Defaults to “”.

  • rotate (bool, optional) – if True, rotate bend such as inflection points are aligned along horizontal axis. Defaults to False.

pybend.algorithms.plot_functions.plot_centerline_collection(filepath: str, cl_collec: CenterlineCollection, domain: tuple[tuple[float, float], tuple[float, float]], nb_cl: int = 999, show: bool = False, annotate: bool = False, plot_apex: bool = True, plot_inflex: bool = False, plot_middle: bool = False, plot_centroid: bool = False, annot_text_size: int = 10, color_bend: bool = False, plot_apex_trajec: bool = False, plot_middle_trajec: bool = False, plot_centroid_trajec: bool = False, plot_normal: bool = False, scale_normal: float = 1.0, plot_section: bool = False, plot_warping: bool = True, cmap_name: str = 'Blues') None

Function to plot CenterlineCollection object.

Parameters:
  • filepath (str) – path to export figures if not empty.

  • cl_collec (CenterlineCollection) – CenterlineCollection object to plot

  • domain (tuple[tuple[float, float],tuple[float, float]]) – display domain

  • nb_cl (int, optional) – Number of centerline to show. Defaults to 999 (i.e., plot all centerlines).

  • show (bool, optional) – if True, show the figure. Defaults to False.

  • annotate (bool, optional) – if True, add bend ids. Defaults to False.

  • plot_apex (bool, optional) – if True, plot bend apex. Defaults to True.

  • plot_inflex (bool, optional) – if True, plot inflection points. Defaults to False.

  • plot_middle (bool, optional) – if True, plot bend middle point. Defaults to False.

  • plot_centroid (bool, optional) – if True, plot bend centroid. Defaults to False.

  • annot_text_size (int, optional) – Text size for annotations. Defaults to 10.

  • color_bend (bool, optional) – if True, bends are colored in blue and red according to UP and DOWN side respectively. Defaults to False.

  • plot_apex_trajec (bool, optional) – if True, plot apex trajectory. Defaults to False.

  • plot_middle_trajec (bool, optional) – if True, plot middle trajectory. Defaults to False.

  • plot_centroid_trajec (bool, optional) – if True, plot bend centroid trajectory. Defaults to False.

  • plot_normal (bool, optional) – if True, plot normal vector of channel points. Defaults to False.

  • scale_normal (float, optional) – Scale for normal vectors. Defaults to 1.0.

  • plot_section (bool, optional) – if True, plot section lines. Defaults to False.

  • plot_warping (bool, optional) – if True, plot channel point trajectory. Defaults to True.

  • cmap_name (str, optional) – Name of the color map to use. Defaults to “Blues”.

pybend.algorithms.plot_functions.plot_centerline_single(filepath: str, cl_points: tuple[list[ClPoint]], bends: list[Bend], domain: tuple[tuple[float, float], tuple[float, float]], show: bool = False, annotate: bool = False, plot_apex: bool = True, plot_inflex: bool = False, plot_middle: bool = False, plot_centroid: bool = False, plot_pt_start: bool = False, plot_apex_proba: bool = False, plot_normal: bool = False, scale_normal: float = 1.0, annot_text_size: float = 10, color_bend: bool = True, linewidth: float = 1, markersize: float = 2, ax0: Axes | None = None) None

Plot a single centerline.

Parameters:
  • filepath (str) – path to export figures if not empty.

  • cl_points (tuple[list[ClPoint]]) – list of ClPoint objects.

  • bends (list[Bend]) – list of Bend objects to plot

  • domain (tuple[tuple[float, float],tuple[float, float]]) – display domain

  • show (bool, optional) – if True, show the figure. Defaults to False.

  • annotate (bool, optional) – if True, add bend ids. Defaults to False.

  • plot_apex (bool, optional) – if True, plot bend apex. Defaults to True.

  • plot_inflex (bool, optional) – if True, plot inflection points. Defaults to False.

  • plot_middle (bool, optional) – if True, plot bend middle point. Defaults to False.

  • plot_centroid (bool, optional) – if True, plot bend centroid. Defaults to False.

  • plot_pt_start (bool, optional) – if True, plot centerline starting point Defaults to False.

  • plot_apex_proba (bool, optional) – If True, color channel points with apex probability property values. Defaults to False.

  • plot_normal (bool, optional) – if True, plot normal vector of channel points. Defaults to False.

  • scale_normal (float, optional) – Scale for normal vectors. Defaults to 1.0.

  • annot_text_size (float, optional) – Text size for annotations. Defaults to 10.

  • color_bend (bool, optional) – if True, bends are colored in blue and red according to UP and DOWN side respectively. Defaults to True.

  • linewidth (float, optional) – Line width. Defaults to 1.

  • markersize (float, optional) – Marker size. Defaults to 2.

  • ax0 (Optional[Axes], optional) – Axes where to plot. Defaults to None.

pybend.algorithms.plot_functions.plot_section(section: Section, ax: Axes, norm_hor: float = 1, norm_vert: float = 1, color_same_bend: bool = True, cmap_name: str = '') None

Plot Section object.

Parameters:
  • section (Section) – Section object to plot

  • ax (Axes) – Axes where to plot

  • norm_hor (float, optional) – Horizontal normalization. Defaults to 1.

  • norm_vert (float, optional) – Vertical normalization. Defaults to 1.

  • color_same_bend (bool, optional) – If True, use a color for isolines that belongs to the last bend and another for the other isolines. Defaults to None.

  • cmap_name (str, optional) – name of the color map. Defaults to “”.

pybend.algorithms.plot_functions.plot_versus_curvilinear(work_dir: str, abscissa: ndarray[tuple[Any, ...], dtype[float64]], curves1: list[ndarray[tuple[Any, ...], dtype[float64]]], labels1: list[str], curves2: list[ndarray[tuple[Any, ...], dtype[float64]]], labels2: list[str], show: bool = False) None

Plot 2 set of properties against abscissa.

Parameters:
  • work_dir (str) – file name to save the figure if not empty.

  • abscissa (npt.NDArray[np.float64]) – abscissa values

  • curves1 (list[npt.NDArray[np.float64]]) – first set of curves

  • labels1 (list[str]) – labels of first set of curves

  • curves2 (list[npt.NDArray[np.float64]]) – second set of curves

  • labels2 (list[str]) – labels of second set of curves

  • show (bool, optional) – if True, show the figure. Defaults to False.