vectorose.triangle_sphere#
Triangle-based Sphere Plotting.
This module provides the functions necessary to produce a triangle mesh of a sphere, with face colours corresponding to the point count in each face.
Classes#
Representation of a sphere constructed using equal-area triangles. |
Module Contents#
- class vectorose.triangle_sphere.TriangleSphere(number_of_subdivisions: int = 3, number_of_shells: int = 1, magnitude_range: Tuple[float, float] | None = None)[source]#
Bases:
vectorose.sphere_base.SphereBaseRepresentation of a sphere constructed using equal-area triangles.
Compute and visualise histograms using a sphere composed of equal-area triangles.
- _sphere: trimesh.primitives.Sphere#
Sphere mesh used to compute and visualise the histogram.
- _faces: pandas.DataFrame#
Data frame containing information about the mesh faces.
- _initial_vector_component_preparation(vectors: pandas.DataFrame) pandas.DataFrame[source]#
Prepare the vector components for histogram construction.
Override this method to include specific operations that should be performed on the vectors in order to construct the histogram in the specific implementation.
Warning
This function should not perform any tasks related to the vector spatial locations, if those are included in the data. Those are handled separately by
_initial_vector_data_preparation()which calls this function.
- _compute_orientation_binning(vectors: pandas.DataFrame) pandas.Series[source]#
Bin the provided vectors based on orientation.
- Parameters:
vectors – The vectors to place in orientation bins.
- Returns:
pandas.Seriesorpandas.DataFrame– The orientation bin(s) corresponding to each vector. The number of columns will depend on the specific sphere representation used.
- to_dataframe() pandas.DataFrame[source]#
Get the data frame representation of the sphere.
Notes
The produced table contains one row for each face in the triangulated sphere. The column headers are
x1,y1,z1,x2,y2,z2,x3,y3,z3, reflecting the Cartesian coordinates of each vertex forming the face.
- _construct_orientation_index() pandas.RangeIndex[source]#
Get the orientation index for the current triangulated sphere.
Produce the orientation index for the current triangulated sphere, containing all face indices for a given shell.
- Returns:
pandas.RangeIndex– Index containing all validfaceindices.
- create_mesh() pyvista.PolyData[source]#
Return the mesh representation of the current sphere.
- convert_vectors_to_cartesian_array(labelled_vectors: pandas.DataFrame, create_unit_vectors: bool = False, include_spatial_coordinates: bool = False) numpy.ndarray[source]#
Convert a set of labelled vectors into Cartesian coordinates.
Each concrete implementation of a sphere may internally represent the vectors differently. This abstract method converts from that implementation-specific formatting to Cartesian coordinates.
- Parameters:
labelled_vectors – The set of labelled
nlabelled vectors inddimensions, in the same format as produced bySphereBase.assign_histogram_bins().create_unit_vectors – Indicate where the returned vectors should be unit vectors. Depending on the implementation, this may either remove an extraneous normalisation step later, or add an extra normalisation step now.
include_spatial_coordinates – Indicate whether to include spatial coordinates in the new array. This option may only be called if the vectors have spatial coordinates.
- Returns:
numpy.ndarray– Array of shape(n, d)containing the vector components in Cartesian coordinates.
Warning
The option include_spatial_coordinates is only valid if the labelled_vectors include spatial coordinates.
- get_cell_indices(bins: pandas.DataFrame) pandas.Series[source]#
Get cell indices for specific bins.
Get the mesh cell index for specified orientation bins.
- Parameters:
bins – DataFrame containing the implementation-specific orientation bin information for the desired cells
- Returns:
Series– Indices of the mesh cells corresponding to the desired orientation bin.
See also
SphereBase.assign_histogram_binsassign specific orientations and magnitudes to histogram bins.